forked from gwen001/pentest-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
phantom-xss.js
81 lines (68 loc) · 2.03 KB
/
phantom-xss.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
70
71
72
73
74
75
76
77
78
79
80
81
var system = require('system');
var args = system.args;
//console.log(args.length);
var page = require('webpage').create();
page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0';
if( args.length < 3 || args.length > 6 ) {
console.log( 'Usage: phantomjs xss.js <method> <url> [<post_params>] [<cookies> <domain>]');
phantom.exit();
}
var method = atob( args[1] );
var url = atob( args[2] );
if( args.length > 3 ) {
var post = atob( args[3] );
} else {
var post = '';
}
phantom.clearCookies();
if( args.length >= 5 ) {
var cookies = atob( args[4] ).split(';');
var domain = atob( args[5] );
for( var i=0 ; i<cookies.length ; i++ ) {
c = cookies[i].trim().split( '=' );
//console.log( c[0]+' -> '+c[1] );
phantom.addCookie( {'name':c[0],'value':c[1],'domain':'.'+domain} );
}
} else {
var cookies = '';
var domain = '';
}
/*console.log( '========== DEBUG PHANTOM ==========' );
console.log( 'METHOD= '+method );
console.log( 'URL= '+url );
console.log( 'POST= '+post );
console.log( 'COOKIES= '+cookies );
console.log( 'DOMAIN= '+domain );*/
////////////////////////////////////////////////////////////////////////////////
page.onAlert = function(str) {
console.log('alert() called: '+str);
phantom.exit();
};
page.onConfirm = function(str) {
console.log('confirm() called: '+str);
phantom.exit();
};
page.onPrompt = function(str) {
console.log('prompt() called: '+str);
phantom.exit();
};
////////////////////////////////////////////////////////////////////////////////
function run( page, method, url, post )
{
console.log( 'Testing: '+url );
page.open( url, method, post, function (status) {
//console.log("Status: " + status);
//page.render('poc.png');
/*console.log("Status: " + status);
var cookies = page.cookies;
console.log('Listing cookies:');
for(var i in cookies) {
console.log(cookies[i].name + '=' + cookies[i].value);
}*/
phantom.exit();
});
}
setTimeout( run(page,method,url,post), 0 );
setTimeout(function() {
phantom.exit();
}, 5000);