8
8
9
9
def passive_tests (url , headers ):
10
10
root = host (url )
11
- acao_header , acac_header = headers [ 'access-control-allow-origin' ] , headers .get ('access-control-allow-credentials' , None )
11
+ acao_header , acac_header = headers . get ( 'access-control-allow-origin' , None ) , headers .get ('access-control-allow-credentials' , None )
12
12
if acao_header == '*' :
13
13
info = details ['wildcard value' ]
14
14
info ['acao header' ] = acao_header
@@ -23,10 +23,12 @@ def passive_tests(url, headers):
23
23
24
24
25
25
def active_tests (url , root , scheme , header_dict , delay ):
26
- headers = requester (url , scheme , header_dict , 'example.com' )
26
+ origin = scheme + '://' + root
27
+ headers = requester (url , scheme , header_dict , origin )
27
28
if headers :
28
- acao_header , acac_header = headers ['access-control-allow-origin' ], headers .get ('access-control-allow-credentials' , None )
29
- if acao_header and acao_header == (scheme + 'example.com' ):
29
+ origin = root + '://' + 'example.com'
30
+ acao_header , acac_header = headers .get ('access-control-allow-origin' , None ), headers .get ('access-control-allow-credentials' , None )
31
+ if acao_header and acao_header == (origin ):
30
32
info = details ['origin reflected' ]
31
33
info ['acao header' ] = acao_header
32
34
info ['acac header' ] = acac_header
@@ -35,44 +37,49 @@ def active_tests(url, root, scheme, header_dict, delay):
35
37
return
36
38
time .sleep (delay )
37
39
38
- headers = requester (url , scheme , header_dict , root + '.example.com' )
39
- acao_header , acac_header = headers ['access-control-allow-origin' ], headers .get ('access-control-allow-credentials' , None )
40
- if acao_header and acao_header == (scheme + root + '.example.com' ):
40
+ origin = scheme + '://' + root + '.example.com'
41
+ headers = requester (url , scheme , header_dict , origin )
42
+ acao_header , acac_header = headers .get ('access-control-allow-origin' , None ), headers .get ('access-control-allow-credentials' , None )
43
+ if acao_header and acao_header == (origin ):
41
44
info = details ['post-domain wildcard' ]
42
45
info ['acao header' ] = acao_header
43
46
info ['acac header' ] = acac_header
44
47
return {url : info }
45
48
time .sleep (delay )
46
49
47
- headers = requester (url , scheme , header_dict , 'd3v' + root )
48
- acao_header , acac_header = headers ['access-control-allow-origin' ], headers .get ('access-control-allow-credentials' , None )
49
- if acao_header and acao_header == (scheme + 'd3v' + root ):
50
+ origin = scheme + '://d3v' + root
51
+ headers = requester (url , scheme , header_dict , origin )
52
+ acao_header , acac_header = headers .get ('access-control-allow-origin' , None ), headers .get ('access-control-allow-credentials' , None )
53
+ if acao_header and acao_header == (origin ):
50
54
info = details ['pre-domain wildcard' ]
51
55
info ['acao header' ] = acao_header
52
56
info ['acac header' ] = acac_header
53
57
return {url : info }
54
58
time .sleep (delay )
55
59
56
- headers = requester (url , '' , header_dict , 'null' )
57
- acao_header , acac_header = headers ['access-control-allow-origin' ], headers .get ('access-control-allow-credentials' , None )
60
+ origin = 'null'
61
+ headers = requester (url , '' , header_dict , origin )
62
+ acao_header , acac_header = headers .get ('access-control-allow-origin' , None ), headers .get ('access-control-allow-credentials' , None )
58
63
if acao_header and acao_header == 'null' :
59
64
info = details ['null origin allowed' ]
60
65
info ['acao header' ] = acao_header
61
66
info ['acac header' ] = acac_header
62
67
return {url : info }
63
68
time .sleep (delay )
64
69
65
- headers = requester (url , scheme , header_dict , root + '_.example.com' )
66
- acao_header , acac_header = headers ['access-control-allow-origin' ], headers .get ('access-control-allow-credentials' , None )
67
- if acao_header and '_.example.com' in acao_header :
70
+ origin = scheme + '://' + root + '_.example.com'
71
+ headers = requester (url , scheme , header_dict , origin )
72
+ acao_header , acac_header = headers .get ('access-control-allow-origin' , None ), headers .get ('access-control-allow-credentials' , None )
73
+ if acao_header and acao_header == origin :
68
74
info = details ['unrecognized underscore' ]
69
75
info ['acao header' ] = acao_header
70
76
info ['acac header' ] = acac_header
71
77
return {url : info }
72
78
time .sleep (delay )
73
79
74
- headers = requester (url , scheme , header_dict , root + '%60.example.com' )
75
- acao_header , acac_header = headers ['access-control-allow-origin' ], headers .get ('access-control-allow-credentials' , None )
80
+ origin = scheme + '://' + root + '%60.example.com'
81
+ headers = requester (url , scheme , header_dict , origin )
82
+ acao_header , acac_header = headers .get ('access-control-allow-origin' , None ), headers .get ('access-control-allow-credentials' , None )
76
83
if acao_header and '`.example.com' in acao_header :
77
84
info = details ['broken parser' ]
78
85
info ['acao header' ] = acao_header
@@ -81,17 +88,18 @@ def active_tests(url, root, scheme, header_dict, delay):
81
88
time .sleep (delay )
82
89
83
90
if root .count ('.' ) > 1 :
84
- spoofed_root = root .replace ('.' , 'x' , 1 )
85
- headers = requester (url , scheme , header_dict , spoofed_root )
86
- acao_header , acac_header = headers [ 'access-control-allow-origin' ] , headers .get ('access-control-allow-credentials' , None )
87
- if acao_header and host ( acao_header ) == spoofed_root :
91
+ origin = scheme + '://' + root .replace ('.' , 'x' , 1 )
92
+ headers = requester (url , scheme , header_dict , origin )
93
+ acao_header , acac_header = headers . get ( 'access-control-allow-origin' , None ) , headers .get ('access-control-allow-credentials' , None )
94
+ if acao_header and acao_header == origin :
88
95
info = details ['unescaped regex' ]
89
96
info ['acao header' ] = acao_header
90
97
info ['acac header' ] = acac_header
91
98
return {url : info }
92
99
time .sleep (delay )
93
- headers = requester (url , 'http' , header_dict , root )
94
- acao_header , acac_header = headers ['access-control-allow-origin' ], headers .get ('access-control-allow-credentials' , None )
100
+ origin = 'http://' + root
101
+ headers = requester (url , 'http' , header_dict , origin )
102
+ acao_header , acac_header = headers .get ('access-control-allow-origin' , None ), headers .get ('access-control-allow-credentials' , None )
95
103
if acao_header and acao_header .startswith ('http://' ):
96
104
info = details ['http origin allowed' ]
97
105
info ['acao header' ] = acao_header
0 commit comments