D
D
domanskiy2020-07-10 15:06:07
Python
domanskiy, 2020-07-10 15:06:07

Is it possible to write a script in Python that changes data in the RAM of a specific running application?

Actually a question in a subject.
How and with what library, in Python, to write a script that changes data in the RAM of a specific running application?
You need to find and change specific data. For example, a year.
Now I do it with my hands in HDX. But I want to automate the process,
Google did not help (

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2020-07-10
@domanskiy

With ctypes :

import sys
import ctypes
import ctypes.wintypes as wintypes


PROCESS_ALL_ACCESS = 0x1F0FFF

kernel32 = ctypes.windll.kernel32

kernel32.OpenProcess.restype = wintypes.HANDLE
kernel32.OpenProcess.argtypes = [
    wintypes.DWORD,
    wintypes.BOOL,
    wintypes.DWORD
]

kernel32.CloseHandle.restype = wintypes.BOOL
kernel32.CloseHandle.argtypes = [ wintypes.HANDLE ]

kernel32.WriteProcessMemory.restype = wintypes.BOOL
kernel32.WriteProcessMemory.argtypes = [ 
    wintypes.HANDLE,
    wintypes.LPVOID,
    wintypes.LPCVOID,
    ctypes.c_size_t,
    ctypes.POINTER(ctypes.c_size_t)
]


pid = int(sys.argv[1])
addr = int(sys.argv[2], 16)

val = 42
buf = (val).to_bytes(4, byteorder='little')
buf_ptr = ctypes.c_char_p(buf)

ph = kernel32.OpenProcess(PROCESS_ALL_ACCESS, False, pid)
kernel32.WriteProcessMemory(ph, addr, buf_ptr, len(buf), None)
kernel32.CloseHandle(ph)

F
FlensT, 2020-08-07
@FlensT

Pyme library

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question