-
Notifications
You must be signed in to change notification settings - Fork 17
/
callbacks.js
78 lines (62 loc) · 2.36 KB
/
callbacks.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
const {fail,succ,warn,info,gstart,bstart,ystart,rstart,colstop} = require('./pretty.js')
class TriggerHandler{
/*
* This class contains and handles events triggered by the document.
* catchRedirect, catchRedirectJS, catchXSS, catchLoadFailure, catchNormal
*
*/
constructor(oHandler){
this.outputHandler = oHandler
}
catchRedirect(thread, chain){
this.outputHandler.write(`${ystart}[${thread.status}] [REDIRECT-HTTP] ${thread.url}${thread.pld}`)
for(var i=0;i<chain.length;i++){
this.outputHandler.write(` ${" ".repeat(i)}|--> ${chain[i].response().url()}`)
}
this.outputHandler.write(colstop)
this.outputHandler.bLastOutputImportant=true
}
//not implemented yet, lost when refactoring from electron to puppeteer
catchRedirectJS(thread, target){
return
if(thread.wasHTTPRedirect){
thread.wasHTTPRedirect=false;
return
}
initCallback('redirect-js')
this.outputHandler.write(`${bstart}[200] [REDIRECT-JS] ${thread.url}${thread.pld}`)
this.outputHandler.write(` |--> ${target}`)
this.outputHandler.write(colstop)
}
catchXSS(thread, href){
this.outputHandler.write(`${rstart}[${thread.id}][${200}] [XSS] ${href} ${colstop}`)
this.outputHandler.bLastOutputImportant=true
pendingOutput.push({
url:href,
payload:thread.pld
})
//xss windows tend to get load looped, but not sure if needed
thread.evaluate(() => window.stop());
}
catchLoadFailure(thread){
this.outputHandler.write(`${bstart}[${thread.id}][${thread.status}] [FAILURE] ${thread.url} ${colstop}`, 5000)
this.outputHandler.bLastOutputImportant=true
}
catchNormal(thread){
if(thread.justRedirected){
thread.justRedirected=false
return
}
this.outputHandler.write(`${gstart}[${thread.id}][${thread.status}] ${colstop} ${thread.url}`)
if(thread.status==200){
this.outputHandler.bLastOutputImportant=false
}else{
if(status)this.outputHandler.bLastOutputImportant=true
else this.outputHandler.bLastOutputImportant=false
}
return
}
}
module.exports ={
TriggerHandler: TriggerHandler
}