forked from interference-security/DVWS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command-execution.php
executable file
·67 lines (60 loc) · 1.44 KB
/
command-execution.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
62
63
64
65
66
67
<?php
$page_data = <<<EOT
<div class="page-header">
<h1>Command Execution</h1>
</div>
<div class="row">
<div class="col-md-12">
<p>
Enter an IP address to ping:
<div class="form-group">
<input type="text" class="form-control" id="ipaddr" name="ipaddr" placeholder="IP Address">
</div>
<button type="submit" class="btn btn-success" id="send">Ping Me!</button>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p id="result">
</p>
</div>
</div>
EOT;
$page_script= <<<EOT
$(document).ready(function(){
//Open a WS server connection
var wsUri = "ws://dvws.local:8080/command-execution";
websocket = new WebSocket(wsUri);
//Connected to WS server
websocket.onopen = function(ev)
{
console.log('Connected to server');
}
//Close WS server connection
websocket.onclose = function(ev)
{
console.log('Disconnected from server');
};
//Message received from WS server
websocket.onmessage = function(ev)
{
console.log('Message: '+ev.data);
document.getElementById("result").innerHTML = "<pre>" + ev.data + "</pre>";
};
//Error
websocket.onerror = function(ev)
{
console.log('Error: '+ev.data);
};
//Send value to WS
$('#send').click(function()
{
var field_value = document.getElementById('ipaddr').value;
console.log(field_value);
websocket.send(field_value);
});
});
EOT;
?>
<?php require_once('includes/template.php'); ?>