Python: writing to another process memory under Linux

How to write to another process address space using python under Ubuntu Linux? My attempts:

1) Using the virtual file / proc / $ PID / mem and finding the address. I have successfully used it to read memory, but trying to write raises an IOError:

fd=open("/proc/"+pid+"/mem","r+")
fd.seek(address,0)
fd.write("ABC")

Conclusion:

IOError: [Errno 22] Invalid argument

2) An attempt to use the python-ptrace library, as suggested in other threads. However, I cannot find good documentation or sample code.

Note. This is not a root privilege issue, it produces the same behavior.

+5
source share
1 answer

Found a solution here: http://tito.googlecode.com/svn-history/r2/trunk/draft/fakefs.py

ctypes libc, libc.ptrace POKEDATA .

+2

All Articles