This repository was archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsend_command.php
More file actions
61 lines (50 loc) · 1.64 KB
/
send_command.php
File metadata and controls
61 lines (50 loc) · 1.64 KB
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
include_once ('settings.php');
// Check if the user has the correct header value
if (@$_SERVER['HTTP_CONSOLE'] !== $console_password) {
// If they don't have the correct header value, display a message
echo "Unauthorized access!";
exit;
}
// If they do have the correct header value, continue with the program
// Set the variables for the API request
// Set the API endpoint URL
$url = "$address/v1/server/exec";
// Set the POST data for the API request
$command = $_POST["command"];
// Set the API endpoint URL
$url = "$address/v1/server/exec";
// Set the POST data for the API request
$data = array(
"command" => $command,
"time" => "1"
);
// Set the headers for the API request
$headers = array(
"accept: */*",
"key: $key",
"Content-Type: application/x-www-form-urlencoded"
);
// Create the cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Add the CURLOPT_VERBOSE option to capture the raw payload
curl_setopt($ch, CURLOPT_VERBOSE, true);
$verbose = fopen('php://temp', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
// Execute the cURL request and get the response
$response = curl_exec($ch);
// Check if there was an error with the cURL request
if (curl_errno($ch)) {
echo "<div class='container'>Error: " . curl_error($ch) . "</div>";
exit;
}
// Close the cURL request
curl_close($ch);
// Display the API response
echo "<div class='container'><pre>" . htmlspecialchars($response) . "</pre></div>";
?>