-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecompiler.php
66 lines (52 loc) · 1.44 KB
/
decompiler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
error_reporting(E_ALL);
define('HOST', 'api.showmycode.com');
define('ENDPOINT', 'api/');
define('WS_KEY', '');
define('SECRET', '');
// Getting encoded file contents:
$contents = getFileContents('/home/liudvikas/Documents/SocketServer_test.exe');
// Sending request:
$response = callRemote($contents);
// Decoded file:
echo $response['data'];
//** You do not need to edit bellow **//
function getFileContents($path)
{
$filename = basename($path);
$contents = file_get_contents($path);
if ($contents != FALSE)
{
return array(
'filename'=>base64_encode($filename),
'contents'=>base64_encode($contents)
);
}
}
function createMessageSig($contents,$secret)
{
ksort($contents);
$data = '';
foreach ($contents as $key => $value)
{
$data .= "$key{$value}";
}
$sig = hash_hmac('md5', $data, $secret);
return $sig;
}
function callRemote($contents)
{
$url = sprintf('http://%s/%s?wsKey=%s&sig=%s', HOST, ENDPOINT,
WS_KEY, createMessageSig($contents, SECRET));
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $contents);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 4);
$result = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
return array('http' => $httpCode, 'data' => $result);
}
?>