Fixed die()

This commit is contained in:
xdrm-brackets 2017-01-27 15:54:30 +01:00
parent 7e12263e1b
commit 47f8937030
7 changed files with 160 additions and 113 deletions

View File

@ -6,23 +6,31 @@
// will send the request using `auth` for cyclic hash
function api_send(){
/* [1] Fetch useful data
=========================================================*/
/* (1) Fetch target url */
$url = @file_get_contents(URL_CONF);
if( $url === false )
die(1);
return 127;
/* (2) Fetch cyclic hash */
$hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/hash');
echo $hash;
die(0);
var_dump($hash);
if( strlen($hash) != 128 )
return 127;
/* (3) Try new hash if available */
$new = syscall(SOURCE_DIR.'/lib/cyclic-hash/new');
var_dump('new'); var_dump($new);
/* (4) Decrement the hash */
var_dump( 'decr: ',syscall(SOURCE_DIR.'/lib/cyclic-hash/decr') );
@ -31,15 +39,17 @@
/* (1) Set URL */
$curl = curl_init($url);
/* (2) Specify that we want to catch result instead of displaying it */
curl_setopt($curl, CURLOPT_RETURNTRANSFERER, true);
/* (3) Set HTTP method -> POST */
/* (2) Set HTTP method -> POST */
curl_setopt($curl, CURLOPT_POST, true);
/* (4) Section Title */
/* (3) Set headers */
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Content-Type: multipart/form-data; boundary='
]);
}
echo api_send();

View File

@ -25,8 +25,12 @@
}
function cyclichash_decr(){
/* [2] Fetch necessary data
=========================================================*/
/* (1) Fetch secret file */
$secret = @file_get_contents(SECRET_CONF);
@ -37,7 +41,10 @@
$secret = generate_secret().':1000';
// Try to override the secret file
@file_put_contents(SECRET_CONF, $secret) && die(0) || die(127);
if( @file_put_contents(SECRET_CONF, $secret) )
return 0;
else
return 127;
}
/* (3) Extract data */
@ -53,7 +60,10 @@
$depth--;
/* (2) Try to override the secret file */
@file_put_contents(SECRET_CONF, "$key:$depth") && die(0) || die(127);
if( @file_put_contents(SECRET_CONF, "$key:$depth") )
return 0;
else
return 127;
/* [4] If cannot decrement, generate new password
@ -61,12 +71,22 @@
}else{
// Generate new secret
$secret = generate_secret().':1000';
$secret = generate_secret().':999';
// Try to override the secret file
file_put_contents(SECRET_CONF, $secret) && die(0) || die(127);
if( @file_put_contents(SECRET_CONF, $secret) )
return 0;
else
return 127;
}
return 0;
}
echo cyclichash_decr();
?>

View File

@ -5,6 +5,8 @@
require_once __DIR__.'/../include/const';
function cyclichash_hash(){
/* [1] Fetch necessary data
=========================================================*/
/* (1) Fetch secret file */
@ -12,7 +14,7 @@
/* (2) Check secret file format */
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) )
die(127);
return 127;
/* (3) Extract data for hashing from @secret */
$key = (string) $match[1];
@ -28,5 +30,11 @@
for( $d = 0 ; $d < $depth ; $d++ )
$hash = hash('sha512', $hash);
echo $hash;
return $hash;
}
echo cyclichash_hash();
?>

View File

@ -5,6 +5,8 @@
require_once __DIR__.'/../include/const';
function cyclichash_new(){
/* [1] Fetch necessary data
=========================================================*/
/* (1) Fetch secret file */
@ -12,7 +14,7 @@
/* (2) Check secret file format */
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) )
die(127);
return 127;
/* (3) Extract data for hashing from @secret */
$key = (string) $match[1];
@ -20,8 +22,8 @@
/* (4) Die if not token not changed */
if( $depth < 1000 )
die(0);
if( $depth < 999 )
return 0;
/* [2] If hash have just been created (original depth = 1000)
@ -33,5 +35,9 @@
for( $d = 0 ; $d < 1000 ; $d++ )
$newhash = hash('sha512', $newhash);
die($newhash);
return $newhash;
}
echo cyclichash_new();
?>

View File

@ -1 +0,0 @@
2wFkoxlQvF8S3twsVAm705_8HuUCV3dYzTiXpDNUiWLmohOjR9qRfq_XUUyPYMMxE3u3HgXZbIkAZ7TQhjHwJHsCA0ryNc4rgyuXOrW_8fz7nsYELEatkC5VDwspJwR_3kXSMSRU7q1uSZ8CDi5XVbSxIkXrQNqU7mMTeDNl2OPVMYxofCl9OdHvxDWmpmgwI1pWEbhHZ5BL378iKusxH82dLZAakQH2S5ZvgfbflN_oU8HEC8bjgew1c5:992

1
lib/include/const Normal file → Executable file
View File

@ -1,5 +1,4 @@
#!/usr/bin/php
<?php
# RESET OUTPUT BUFFER

21
lib/include/func Normal file → Executable file
View File

@ -1,23 +1,28 @@
#!/usr/bin/php
<?php
/* [1] Launches external script
=========================================================*/
function syscall($callable=null){
ini_set('display_errors', 'On');
error_reporting(E_ALL);
/* (1) Check file */
if( !file_exists($callable) )
return null;
if( is_null($callable) || !file_exists($callable) )
return false;
/* (2) Call and catch output */
ob_start();
include $callable;
$out = ob_get_clean();
/* (3) Manage content */
if( $out == 0 ) return true;
elseif( is_numeric($out) ) return false;
/* (3) Remove unnecessary (#!/usr/bin/php) from input */
$out = preg_replace("/^(\s*#!\/usr\/bin\/php\s*)*/", "", $out);
$out = preg_replace("/\s$/", "", $out);
/* (4) Manage result */
if( is_numeric($out) ) return ($out==0);
else return $out;
}