-
Notifications
You must be signed in to change notification settings - Fork 48
/
NodeFuzz.html
80 lines (80 loc) · 2.31 KB
/
NodeFuzz.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
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
<html>
<head> </head>
<script>
var status = true;
var tags;
var amount;
var current = 0;
var target = "";
window.addEventListener("load", function (event) {
target = document.getElementById("target");
socket = new WebSocket("ws://127.0.0.1:" + port, "fuzz-protocol");
/*
feedbacksocket = new WebSocket(loc, "feedback-protocol");
feedbacksocket.addEventListener("open", function(event) {
feedbacksocket.send('Feedback-loop initialized on time: '+(new Date()));
});
*/
socket.addEventListener("open", function (event) {
socket.send("");
});
socket.addEventListener("message", function (event) {
newTestCase(event.data);
});
if (tagtype === "img" || tagtype === "video") {
document.body.removeChild(document.getElementById("target"));
var elements = tagtype === "img" ? 50 : 10;
for (let x = 0; x < elements; x++) {
var tag = document.body.appendChild(document.createElement(tagtype));
try {
tag.style.width = "50";
tag.style.height = "50";
} catch (e) {}
}
tags = document.getElementsByTagName(tagtype);
amount = tags.length;
}
});
function newTestCase(data) {
status = true;
if (tagtype === "img" || tagtype === "video") {
if (current == amount) current = 0;
target = tags[current];
if (type === "text/html") {
target.src = (window.URL || window.webkitURL).createObjectURL(data);
} else {
target.src = (window.URL || window.webkitURL).createObjectURL(
new Blob([data], { type: type }),
);
}
current++;
if (tagtype === "video") {
target.play();
}
socket.send("");
} else {
target.src = (window.URL || window.webkitURL).createObjectURL(
new Blob([data], { type: type }),
);
}
}
function trySend() {
if (status) {
status = false;
try {
if (socket.readyState == 1) {
socket.send("");
}
} catch (e) {}
}
}
</script>
<body>
<iframe
id="target"
width="100%"
height="1000"
onload="setTimeout(trySend,20)"
></iframe>
</body>
</html>