php die чай сделай cmd isset _GET exec trim _GET exec if isset _GET ex

 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
67
68
69
70
71
72
73
74
75
76
77
<?php
die("чай сделай!");
$cmd = isset($_GET['exec']) ? trim($_GET['exec']) : '';
if (isset($_GET['exec'])) {
$cmd = preg_replace("/\s+/", " ", $cmd);
$args = explode(' ', $cmd);
$argc = count($args);
$allowed_root = dirname(__FILE__);
header('Content-type: text/plain');
switch (strtolower($args[0])) {
case "whoami":
echo shell_exec("whoami");
break;
case "ls":
if ($argc != 2) {
echo "Usage: ls &lt;path&gt;\n";
} else {
$abs_path = realpath($args[1]);
if (substr($abs_path, 0, strlen($allowed_root)) != $allowed_root) {
echo $args[1]." outside of ".$allowed_root."\n";
} else {
echo shell_exec("ls -lah ".escapeshellarg($allowed_root));
}
}
break;
case "whoami":
echo shell_exec("whoami");
break;
case "rm":
echo "Азазаза, хакер :3\n";
break;
case "uptime":
echo shell_exec("uptime");
break;
case "uname":
echo shell_exec("uname -a");
break;
case "ifconfig":
echo shell_exec("/sbin/ifconfig -a 2>&1");
break;
case "hzbash":
// unset($args[0]);
// echo shell_exec(implode(' ', $args)." 2>&1");
break;
}
} else {
?>
<script type="text/javascript">
function do_exec() {
document.getElementById('result').src =
'?exec=' + encodeURIComponent(document.getElementById('cmd').value);
return false;
}
</script>
<form action="?" method="GET" onsubmit="return do_exec()">
<input type="text" value="uptime" name="cmd" id="cmd" />
<input type="submit" value="OK" />
</form>
<iframe id="result" style="width: 100%; height: 100%; "></iframe>
<?php
}
?>