pwnlib.util.proc
— Working with /proc/
¶
-
pwnlib.util.proc.
ancestors
(pid) → int list[source]¶ Parameters: pid (int) – PID of the process. Returns: List of PIDs of whose parent process is pid or an ancestor of pid.
-
pwnlib.util.proc.
children
(ppid) → int list[source]¶ Parameters: pid (int) – PID of the process. Returns: List of PIDs of whose parent process is pid.
-
pwnlib.util.proc.
cmdline
(pid) → str list[source]¶ Parameters: pid (int) – PID of the process. Returns: A list of the fields in /proc/<pid>/cmdline
.
-
pwnlib.util.proc.
cwd
(pid) → str[source]¶ Parameters: pid (int) – PID of the process. Returns: The path of the process’s current working directory. I.e. what /proc/<pid>/cwd
points to.
-
pwnlib.util.proc.
descendants
(pid) → dict[source]¶ Parameters: pid (int) – PID of the process. Returns: Dictionary mapping the PID of each child of pid to it’s descendants.
-
pwnlib.util.proc.
exe
(pid) → str[source]¶ Parameters: pid (int) – PID of the process. Returns: The path of the binary of the process. I.e. what /proc/<pid>/exe
points to.
-
pwnlib.util.proc.
name
(pid) → str[source]¶ Parameters: pid (int) – PID of the process. Returns: Name of process as listed in /proc/<pid>/status
.Example
>>> pid = pidof('init')[0] >>> name(pid) == 'init' True
-
pwnlib.util.proc.
parent
(pid) → int[source]¶ Parameters: pid (int) – PID of the process. Returns: Parent PID as listed in /proc/<pid>/status
underPPid
, or 0 if there is not parent.
-
pwnlib.util.proc.
pid_by_name
(name) → int list[source]¶ Parameters: name (str) – Name of program. Returns: List of PIDs matching name sorted by lifetime, youngest to oldest. Example
>>> os.getpid() in pid_by_name(name(os.getpid())) True
-
pwnlib.util.proc.
pidof
(target) → int list[source]¶ Get PID(s) of target. The returned PID(s) depends on the type of target:
str
: PIDs of all processes with a name matching target.pwnlib.tubes.process.process
: singleton list of the PID of target.pwnlib.tubes.sock.sock
: singleton list of the PID at the remote end of target if it is running on the host. Otherwise an empty list.
Parameters: target (object) – The target whose PID(s) to find. Returns: A list of found PIDs.
-
pwnlib.util.proc.
starttime
(pid) → float[source]¶ Parameters: pid (int) – PID of the process. Returns: The time (in seconds) the process started after system boot
-
pwnlib.util.proc.
stat
(pid) → str list[source]¶ Parameters: pid (int) – PID of the process. Returns: A list of the values in /proc/<pid>/stat
, with the exception that(
and)
has been removed from around the process name.
-
pwnlib.util.proc.
state
(pid) → str[source]¶ Parameters: pid (int) – PID of the process. Returns: State of the process as listed in /proc/<pid>/status
. See proc(5) for details.Example
>>> state(os.getpid()) 'R (running)'
-
pwnlib.util.proc.
status
(pid) → dict[source]¶ Get the status of a process.
Parameters: pid (int) – PID of the process. Returns: The contents of /proc/<pid>/status
as a dictionary.