forked from Destru/JOSHUA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcell.sudo.php
75 lines (70 loc) · 2.03 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
<?php // su-su-sussdio
// sudo
if($command == "sudo") {
if(empty($option)) error('password');
else {
if($dump == "sudo make me a sandwich") output('<p class="joshua">'.$joshua.'Okay.</p>');
else {
if(hash('sha512', $option) == '289f1f350289cc9493ce6c83d378e068c7c481e3dd8c8572e084dc532468a5e0f462f003612098d11618910294008e063b868edc845cd95a68cee5af3a71fcbf') {
$_SESSION['sudo'] = 1;
output('<p class="joshua">'.$joshua.'Authentification successful.</p>');
}
else {
unset($_SESSION['sudo']);
error('password');
}
}
}
}
// reply
if($command == "reply") {
if(isset($_SESSION['sudo'])) {
$storage = "msg.data";
$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);
print '<div class="prompt">'.$command.'</div><p class="joshua">'.$joshua.'Reply stored.</p>';
$output = 1;
}
else output('<p class="error">'.$joshua.'Reply can\'t be empty.</p>');
}
else error('auth');
}
// invalid commands
if($command == "invalid") {
if(isset($_SESSION['sudo'])) {
$storage = "invalid.data";
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));
}
}
else error('auth');
}
// various *nix commands
$nix = array('ls', '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');
if(in_array($command, $nix)) {
if(isset($_SESSION['sudo'])) {
if($command == "ll") {
$return = run("ls -al");
}
elseif($command == "df") {
$return = run("df -h");
}
if(isset($return) && !empty($return)) {
output('<pre>'.$return.'</pre>');
}
else error('noreturn');
}
else error('auth');
}
?>