Modifying external running process using python

Nobody nobody at nowhere.com
Fri Sep 30 22:20:52 CEST 2011


On Thu, 29 Sep 2011 23:02:55 -0700, bingbang wrote:

> Beginner here. I am trying to figure out how to modify a running
> process on a linux system using Python.

> I looked up trace and some other modules but they all seem to do with
> following the currently executing python process.

ptrace() is the system call which programs such as gdb, strace, ltrace,
etc use to monitor or control another process. You wil probably need to
use ctypes to access this function from Python.

> Let's assume I have sudo/root privileges and that the POC code "only
> needs to work in linux".

You don't need root privilege to ptrace() a process which you own and
which isn't privileged (a process which starts out setuid/setgid is still
treated as privileged even if it reverts to the real user/group IDs).




More information about the Python-list mailing list