-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSendKeyCommand.html
54 lines (49 loc) · 1.52 KB
/
SendKeyCommand.html
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
<?php
error_reporting(0);
if(isset($_POST['function'])) {
if(!($sock = socket_create(AF_INET, SOCK_STREAM, 0))) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Unable to create socket - [Error Code $errorcode] \n");
}
//getting client ip (just because)
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
//Connecting to server
if(!socket_connect($sock , '127.0.0.1' , 5555)) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Unable to connect to specified server - [Error Code $errorcode] \n");
}
if(!socket_send($sock , ($_POST['function'] . "\n" . (ucfirst($_POST['username']))), strlen(($_POST['function'] . " " . (ucfirst($_POST['username'])))) , 0)) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Unable to send data to specified server - [Error Code $errorcode] \n");
}
echo "Key command: " . htmlentities(ucfirst($_POST['function'])) . " sent.";
} else {
echo "Please issue a command.";
}
?>
<html>
<head>
<title>Send a key</title>
</head>
<body>
<form method="POST" action="">
<br>
<table width="300px">
<tr>
<tr>
<td valign="top">
<input type="submit" value="Send Key" />
</td>
</tr>
</form>
</body>
</html>