forked from interference-security/DVWS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stored-xss.php
executable file
·106 lines (92 loc) · 2.53 KB
/
stored-xss.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
$page_data = <<<EOT
<div class="page-header">
<h1>Stored XSS</h1>
</div>
<div class="row">
<div class="col-md-12">
<p>
Enter your name:
<div class="form-group">
<input type="text" class="form-control" id="name" name="name" placeholder="Your name">
</div>
Enter your comment:
<div class="form-group">
<textarea class="form-control" id="comment" name="comment" placeholder="Your comment"></textarea>
</div>
<button type="submit" class="btn btn-success" id="send">Post Comment</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/post-comments";
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 = document.getElementById("result").innerHTML + ev.data;
};
//Error
websocket.onerror = function(ev)
{
console.log('Error: '+ev.data);
};
//Send value to WS
$('#send').click(function()
{
var name_field_value = document.getElementById('name').value;
var comment_field_value = document.getElementById('comment').value;
var field_value = '{"name":"'+name_field_value+'","comment":"'+comment_field_value+'"}';
console.log(field_value);
websocket.send(field_value);
});
//Show comments
//Open a WS server connection
var wsUri2 = "ws://dvws.local:8080/show-comments";
websocket2 = new WebSocket(wsUri2);
//Connected to WS server
websocket2.onopen = function(ev)
{
console.log('Connected to server: show-comments');
}
//Close WS server connection
websocket2.onclose = function(ev)
{
console.log('Disconnected from server: show-comments');
};
//Message received from WS server
websocket2.onmessage = function(ev)
{
console.log('Message: show-comments : '+ev.data);
document.getElementById("result").innerHTML = ev.data;
};
//Error
websocket2.onerror = function(ev)
{
console.log('Error: show-comments : '+ev.data);
};
setTimeout(function() { websocket2.send("showComments"); }, 2000);
});
EOT;
?>
<?php require_once('includes/template.php'); ?>