forked from bruterobbie/knoxss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknoxss.js
69 lines (55 loc) · 1.73 KB
/
knoxss.js
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
var server = require('webserver').create();
var agent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/48.0';
console.log('Server running at http://0.0.0.0:1337');
server.listen('1337', function(req, res) {
var page = require('webpage').create();
var xss = false;
var myJSON = JSON.parse(req.postRaw);
var target = myJSON.target.replace("%25%75", "%u");
var myHeaders = JSON.stringify(myJSON.headers);
var myData = myJSON.data;
var myMethod = myData ? "POST" : "GET";
if (target) {
page.resourceTimeout = 10000;
page.settings.loadImages = 0;
page.settings.userAgent = agent;
page.onAlert = function (msg) {
if (msg == 1) {
xss = true;
}
};
page.onConfirm = function (msg) {
if (msg == 1) {
xss = true;
}
};
page.customHeaders = myJSON.headers;
page.onLoadStarted = function() {
page.customHeaders = {};
};
page.open(target, myMethod, myData, function() {
page.sendEvent('mousemove');
res.statusCode = 200;
if (xss) {
res.write('TRUE\n');
} else {
res.write('FALSE\n');
}
page.close();
res.close();
});
page.onLongRunningScript = function() {
page.stopJavaScript();
};
page.onResourceTimeout = function() {
res.write('TIMEOUT\n');
page.close();
res.close();;
};
// page.onError = function() {}
} else {
res.statusCode = 200;
res.write('No data.\n');
res.close();
}
});