Fixed die()
This commit is contained in:
parent
7e12263e1b
commit
47f8937030
60
lib/api/send
60
lib/api/send
|
@ -6,40 +6,50 @@
|
||||||
|
|
||||||
// will send the request using `auth` for cyclic hash
|
// will send the request using `auth` for cyclic hash
|
||||||
|
|
||||||
/* [1] Fetch useful data
|
function api_send(){
|
||||||
=========================================================*/
|
|
||||||
/* (1) Fetch target url */
|
|
||||||
$url = @file_get_contents(URL_CONF);
|
|
||||||
|
|
||||||
if( $url === false )
|
/* [1] Fetch useful data
|
||||||
die(1);
|
=========================================================*/
|
||||||
|
/* (1) Fetch target url */
|
||||||
|
$url = @file_get_contents(URL_CONF);
|
||||||
|
|
||||||
/* (2) Fetch cyclic hash */
|
if( $url === false )
|
||||||
$hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/hash');
|
return 127;
|
||||||
echo $hash;
|
|
||||||
|
|
||||||
die(0);
|
/* (2) Fetch cyclic hash */
|
||||||
|
$hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/hash');
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
/* [1] Create httpRequest basis
|
/* (4) Decrement the hash */
|
||||||
=========================================================*/
|
var_dump( 'decr: ',syscall(SOURCE_DIR.'/lib/cyclic-hash/decr') );
|
||||||
/* (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 */
|
/* [1] Create httpRequest basis
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
=========================================================*/
|
||||||
|
/* (1) Set URL */
|
||||||
|
$curl = curl_init($url);
|
||||||
|
|
||||||
/* (4) Section Title */
|
/* (2) Set HTTP method -> POST */
|
||||||
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
|
|
||||||
|
/* (3) Set headers */
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
||||||
|
'Content-Type: multipart/form-data; boundary='
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo api_send();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,48 +25,68 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* [2] Fetch necessary data
|
|
||||||
=========================================================*/
|
|
||||||
/* (1) Fetch secret file */
|
|
||||||
$secret = @file_get_contents(SECRET_CONF);
|
|
||||||
|
|
||||||
/* (2) Check secret file format */
|
|
||||||
if( !is_string($secret) || !preg_match("/^(.{250}):(\d+)$/", $secret, $match) ){
|
|
||||||
|
|
||||||
// Generate new secret
|
function cyclichash_decr(){
|
||||||
$secret = generate_secret().':1000';
|
|
||||||
|
|
||||||
// Try to override the secret file
|
/* [2] Fetch necessary data
|
||||||
@file_put_contents(SECRET_CONF, $secret) && die(0) || die(127);
|
=========================================================*/
|
||||||
}
|
|
||||||
|
|
||||||
/* (3) Extract data */
|
/* (1) Fetch secret file */
|
||||||
$key = (string) $match[1];
|
$secret = @file_get_contents(SECRET_CONF);
|
||||||
$depth = (int) $match[2];
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] If can decrement, decrement
|
|
||||||
=========================================================*/
|
|
||||||
if( $depth > 1 ){
|
|
||||||
|
|
||||||
/* (1) Decrement the depth */
|
|
||||||
$depth--;
|
|
||||||
|
|
||||||
/* (2) Try to override the secret file */
|
|
||||||
@file_put_contents(SECRET_CONF, "$key:$depth") && die(0) || die(127);
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] If cannot decrement, generate new password
|
|
||||||
=========================================================*/
|
|
||||||
}else{
|
|
||||||
|
|
||||||
// Generate new secret
|
/* (2) Check secret file format */
|
||||||
$secret = generate_secret().':1000';
|
if( !is_string($secret) || !preg_match("/^(.{250}):(\d+)$/", $secret, $match) ){
|
||||||
|
|
||||||
|
// Generate new secret
|
||||||
|
$secret = generate_secret().':1000';
|
||||||
|
|
||||||
|
// Try to override the secret file
|
||||||
|
if( @file_put_contents(SECRET_CONF, $secret) )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 127;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (3) Extract data */
|
||||||
|
$key = (string) $match[1];
|
||||||
|
$depth = (int) $match[2];
|
||||||
|
|
||||||
|
|
||||||
|
/* [3] If can decrement, decrement
|
||||||
|
=========================================================*/
|
||||||
|
if( $depth > 1 ){
|
||||||
|
|
||||||
|
/* (1) Decrement the depth */
|
||||||
|
$depth--;
|
||||||
|
|
||||||
|
/* (2) Try to override the secret file */
|
||||||
|
if( @file_put_contents(SECRET_CONF, "$key:$depth") )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 127;
|
||||||
|
|
||||||
|
|
||||||
|
/* [4] If cannot decrement, generate new password
|
||||||
|
=========================================================*/
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// Generate new secret
|
||||||
|
$secret = generate_secret().':999';
|
||||||
|
|
||||||
|
// Try to override the secret file
|
||||||
|
if( @file_put_contents(SECRET_CONF, $secret) )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 127;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Try to override the secret file
|
|
||||||
file_put_contents(SECRET_CONF, $secret) && die(0) || die(127);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo cyclichash_decr();
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -5,28 +5,36 @@
|
||||||
require_once __DIR__.'/../include/const';
|
require_once __DIR__.'/../include/const';
|
||||||
|
|
||||||
|
|
||||||
/* [1] Fetch necessary data
|
function cyclichash_hash(){
|
||||||
=========================================================*/
|
|
||||||
/* (1) Fetch secret file */
|
|
||||||
$secret = @file_get_contents(SECRET_CONF);
|
|
||||||
|
|
||||||
/* (2) Check secret file format */
|
|
||||||
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) )
|
|
||||||
die(127);
|
|
||||||
|
|
||||||
/* (3) Extract data for hashing from @secret */
|
/* [1] Fetch necessary data
|
||||||
$key = (string) $match[1];
|
=========================================================*/
|
||||||
$depth = (int) $match[2];
|
/* (1) Fetch secret file */
|
||||||
|
$secret = @file_get_contents(SECRET_CONF);
|
||||||
|
|
||||||
|
/* (2) Check secret file format */
|
||||||
|
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) )
|
||||||
|
return 127;
|
||||||
|
|
||||||
|
/* (3) Extract data for hashing from @secret */
|
||||||
|
$key = (string) $match[1];
|
||||||
|
$depth = (int) $match[2];
|
||||||
|
|
||||||
|
|
||||||
/* [2] Hash data
|
/* [2] Hash data
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Initialize with data */
|
/* (1) Initialize with data */
|
||||||
$hash = $key;
|
$hash = $key;
|
||||||
|
|
||||||
/* (2) Hash @depth times */
|
/* (2) Hash @depth times */
|
||||||
for( $d = 0 ; $d < $depth ; $d++ )
|
for( $d = 0 ; $d < $depth ; $d++ )
|
||||||
$hash = hash('sha512', $hash);
|
$hash = hash('sha512', $hash);
|
||||||
|
|
||||||
echo $hash;
|
return $hash;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo cyclichash_hash();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -5,33 +5,39 @@
|
||||||
require_once __DIR__.'/../include/const';
|
require_once __DIR__.'/../include/const';
|
||||||
|
|
||||||
|
|
||||||
/* [1] Fetch necessary data
|
function cyclichash_new(){
|
||||||
=========================================================*/
|
|
||||||
/* (1) Fetch secret file */
|
|
||||||
$secret = @file_get_contents(SECRET_CONF);
|
|
||||||
|
|
||||||
/* (2) Check secret file format */
|
|
||||||
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) )
|
|
||||||
die(127);
|
|
||||||
|
|
||||||
/* (3) Extract data for hashing from @secret */
|
/* [1] Fetch necessary data
|
||||||
$key = (string) $match[1];
|
=========================================================*/
|
||||||
$depth = (int) $match[2];
|
/* (1) Fetch secret file */
|
||||||
|
$secret = @file_get_contents(SECRET_CONF);
|
||||||
|
|
||||||
|
/* (2) Check secret file format */
|
||||||
|
if( !is_string($secret) || !preg_match("/^(.{".SECRET_SIZE."}):(\d+)$/", $secret, $match) )
|
||||||
|
return 127;
|
||||||
|
|
||||||
|
/* (3) Extract data for hashing from @secret */
|
||||||
|
$key = (string) $match[1];
|
||||||
|
$depth = (int) $match[2];
|
||||||
|
|
||||||
|
|
||||||
/* (4) Die if not token not changed */
|
/* (4) Die if not token not changed */
|
||||||
if( $depth < 1000 )
|
if( $depth < 999 )
|
||||||
die(0);
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
/* [2] If hash have just been created (original depth = 1000)
|
/* [2] If hash have just been created (original depth = 1000)
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Return new hash */
|
/* (1) Return new hash */
|
||||||
$newhash = $key;
|
$newhash = $key;
|
||||||
|
|
||||||
/* (2) Hash @depth times = 1000 */
|
/* (2) Hash @depth times = 1000 */
|
||||||
for( $d = 0 ; $d < 1000 ; $d++ )
|
for( $d = 0 ; $d < 1000 ; $d++ )
|
||||||
$newhash = hash('sha512', $newhash);
|
$newhash = hash('sha512', $newhash);
|
||||||
|
|
||||||
die($newhash);
|
return $newhash;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo cyclichash_new();
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
2wFkoxlQvF8S3twsVAm705_8HuUCV3dYzTiXpDNUiWLmohOjR9qRfq_XUUyPYMMxE3u3HgXZbIkAZ7TQhjHwJHsCA0ryNc4rgyuXOrW_8fz7nsYELEatkC5VDwspJwR_3kXSMSRU7q1uSZ8CDi5XVbSxIkXrQNqU7mMTeDNl2OPVMYxofCl9OdHvxDWmpmgwI1pWEbhHZ5BL378iKusxH82dLZAakQH2S5ZvgfbflN_oU8HEC8bjgew1c5:992
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# RESET OUTPUT BUFFER
|
# RESET OUTPUT BUFFER
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/* [1] Launches external script
|
||||||
|
=========================================================*/
|
||||||
function syscall($callable=null){
|
function syscall($callable=null){
|
||||||
|
ini_set('display_errors', 'On');
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
/* (1) Check file */
|
/* (1) Check file */
|
||||||
if( !file_exists($callable) )
|
if( is_null($callable) || !file_exists($callable) )
|
||||||
return null;
|
return false;
|
||||||
|
|
||||||
/* (2) Call and catch output */
|
/* (2) Call and catch output */
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
include $callable;
|
include $callable;
|
||||||
|
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
|
|
||||||
/* (3) Manage content */
|
/* (3) Remove unnecessary (#!/usr/bin/php) from input */
|
||||||
if( $out == 0 ) return true;
|
$out = preg_replace("/^(\s*#!\/usr\/bin\/php\s*)*/", "", $out);
|
||||||
elseif( is_numeric($out) ) return false;
|
$out = preg_replace("/\s$/", "", $out);
|
||||||
else return $out;
|
|
||||||
|
|
||||||
|
/* (4) Manage result */
|
||||||
|
if( is_numeric($out) ) return ($out==0);
|
||||||
|
else return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue