-
Notifications
You must be signed in to change notification settings - Fork 2
/
cell.sudo.php
82 lines (76 loc) · 2.38 KB
/
cell.sudo.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php // sudo
if ($command == "sudo") {
if (empty($option)) error('password');
else {
if ($dump == "sudo make me a sandwich") output('<p class="joshua">'.$joshua.'Okay.');
else {
if (hash('sha512', $option) == $keys['sudo']) {
$_SESSION['sudo'] = 1;
output('<p class="joshua">'.$joshua.'Authentification successful.');
}
else {
unset($_SESSION['sudo']);
error('password');
}
}
}
}
// pseudo
$pseudo = array('reply', 'invalid', 'update');
if (in_array($command, $pseudo)) {
if (isset($_SESSION['sudo'])) {
// reply
if ($command == "reply") {
$storage = "msg.data";
if (!file_exists($storage)) file_put_contents($storage, null);
$message = trim(str_replace($command, '', $dump));
if (strlen($message) > 0) {
$fp = fopen($storage, 'a');
fwrite($fp, date("d/m/y").'^<span class="light">'.$message.'</span>^127.0.0.1'."\n");
fclose($fp);
output('<p class="joshua">'.$joshua.'Reply stored.');
}
else output('<p class="error">'.$joshua.'Reply can\'t be empty.');
}
// invalid
else if ($command == "invalid") {
$storage = "invalid.data";
if (!file_exists($storage)) file_put_contents($storage, null);
if (isset($option) && $option == "clear") {
$fp = fopen($storage, 'w');
fclose($fp);
output('<p class="joshua">'.$joshua.'Invalid command log cleared.');
}
else {
$db = dbFile($storage);
array_unique($db);
output(implodeHuman($db));
}
}
// update
else if ($command == "update") {
update(true);
output('<p class="joshua">'.$joshua.'Updated static data.');
}
}
else error('auth');
}
// *nix
$nix = array('ls', 'ps', 'cd', 'top', 'rm', 'cp', 'who', 'kill', 'll', 'df', 'mkdir',
'grep', 'man', 'wget', 'rsync', 'cat', 'tail', 'ifconfig', 'ipconfig', 'del',
'make', 'wget', 'curl', 'pwd', 'dir', 'mysql', 'su', 'netstat', 'login', 'ssh',
'irssi', 'shutdown', 'mail', 'email', 'vi', 'vim', 'emacs', 'subl');
if (in_array($command, $nix)) {
if (isset($_SESSION['sudo'])) {
if ($command == "ll") $output = run('ls -al');
elseif ($command == "df") $output = run('df -h');
elseif ($command == "pwd") $output = run('pwd');
elseif ($command == "ifconfig") $output = run('ifconfig');
elseif ($command == "who") $output = run('who');
elseif ($command == "ps") $output = run('ps aux');
else $output = 'Command not implemented.';
output('<pre>'.$output.'</pre>');
}
else error('auth');
}
?>