@ 2017-07-04T08:58:50Z #!/usr/bin/hhvm
<?php
# set up a new session
$imei = '000999999999999999';
$source_id = '0000000099';
$source_key = "\x24\x73\xAB\x7F\x88\x4F\x4B\x2F";
$host = $argv[1];
$port = $argv[2];
# set up a new session
$c_request = $imei."".$source_id;
$enc_c_request = Crypt::encrypt( $c_request, Crypt::COMMON_KEY);
$url = 'http://'.$host.':'.$port.'/sw-system/sloc8r/public/c.php';
//$url = 'http://'.$host.':'.$port.'/V2.7.2/c.php';
$response = send_request($url, $enc_c_request);
$result = split(',', $response,3);
$session_data = split(',', Crypt::decrypt($result[2], $source_key), 2);
$session_id = sprintf("%020d", $session_data[0]);
$session_key = $session_data[1];
//print "session_id: $session_id\n";
# send a location block
$time = time();
$dataFiles = scandir ($argv[3]);
foreach($dataFiles as $dataFile){
if(strlen($dataFile)<5) continue;
print_r($dataFile);echo "\n";
$reqData = fopen($argv[3]."/".$dataFile, "r");
$file_name = preg_replace('/[^0-9]/', '', $dataFile);
$url = 'http://'.$host.':'.$port.'/sw-system/sloc8r/public/d.php';
//$url = 'http://'.$host.':'.$port.'/V2.7.2/d.php';
$sleepTime = 3;
if (isset($argv[4])){
$sleepTime = $argv[4];
}
while (!feof($reqData)){
$line = fgets($reqData);
if(strlen($line)<120) continue;
//echo $line."\n";
$line = explode(",",$line,3);
//print_r($line);exit;
$d_request_data = $line[2];
//$d_request_data = $line;
$enc_d_request = Crypt::encrypt(gzencode($d_request_data), $session_key);
$request = $session_id.$enc_d_request;
#print "request: $request\n";
file_put_contents('/tmp/request.post', $request);
# response from d.php
$response = send_request($url, $request);
#print "raw response:\n";
//var_dump($response);
#print "\n\n";
if (preg_match('/^\$UP/', $response)){
$uncompressed = $response;
} else {
$decrypted = Crypt::decrypt($response, $session_key);
$stripped = substr($decrypted,10,-8);
$uncompressed = gzinflate( $stripped );
}
$d_response = split(',',$uncompressed);
# var_dump($d_response);
if ($d_response[0] == "\$UP" && ($d_response[1] == "1")){
print $file_name.",$uncompressed\n";
} else {
print "response: ".implode(',',$d_response)."\n";
}
//print "sleeping for $sleepTime seconds\n";
sleep($sleepTime);
}
}
##############################################
function printStrHex($string) {
echo "begin hex dump\n";
for ($i = 0; $i < strlen($string); $i++) {
echo dechex(ord($string[$i]));
}
echo "\nEnd hex dump\n";
}
function send_request($url, $request) {
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-Length: " . strlen($request) . "\r\n"
. "Expect: \r\n",
'method' => 'POST',
'content' => $request,
),
);
$context = stream_context_create($options);
if ( $result = file_get_contents($url, false, $context) ) {
return $result;
} else {
print "Couldnt conenct to $url ($result)\n";
exit(2);
}
}
class Crypt {
const COMMON_KEY = "\xb5\xfb\xf4\x70\xd8\xd4\xf9\xb9";
static public function decrypt($str, $key)
{
$str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB);
$pad = ord($str[($len = strlen($str)) - 1]); //last byte contains amount of padding applied
return substr($str, 0, strlen($str) - $pad);
}
static public function encrypt($str, $key)
{
$block = mcrypt_get_block_size('rijndael_128', 'ecb');
$pad = $block - (strlen($str) % $block);
$str .= str_repeat(chr($pad), $pad);
return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB);
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.29 , 8.1.0 - 8.1.20 , 8.2.0 - 8.2.7 Warning: Undefined array key 1 in /in/ibh47 on line 9
Warning: Undefined array key 2 in /in/ibh47 on line 10
Fatal error: Uncaught Error: Call to undefined function mcrypt_get_block_size() in /in/ibh47:149
Stack trace:
#0 /in/ibh47(15): Crypt::encrypt('000999999999999...', '\xB5\xFB\xF4p\xD8\xD4\xF9\xB9')
#1 {main}
thrown in /in/ibh47 on line 149
Process exited with code 255 . Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.34 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 Notice: Undefined offset: 1 in /in/ibh47 on line 9
Notice: Undefined offset: 2 in /in/ibh47 on line 10
Fatal error: Uncaught Error: Call to undefined function mcrypt_get_block_size() in /in/ibh47:149
Stack trace:
#0 /in/ibh47(15): Crypt::encrypt('000999999999999...', '\xB5\xFB\xF4p\xD8\xD4\xF9\xB9')
#1 {main}
thrown in /in/ibh47 on line 149
Process exited with code 255 . Output for 5.6.0 - 5.6.40 Notice: Undefined offset: 1 in /in/ibh47 on line 9
Notice: Undefined offset: 2 in /in/ibh47 on line 10
Fatal error: Call to undefined function mcrypt_get_block_size() in /in/ibh47 on line 149
Process exited with code 255 . preferences:dark mode live preview ace vim emacs key bindings
63.82 ms | 409 KiB | 5 Q