path: pwntools_4.15.0-1/CHANGELOG.md - [#1104][1104] Add `DynELF.dump()` for dumping remote ELF files - [#1101][1101] Set `context.os` via `context.binary`, useful for Android exploitation - [5fdc08][5fdc08] Work around broken `pidof` on Android - [63dfed][63dfed] Print warning when Corefile deletion fails instead of throwing an exception - [#1094][1094] Make hexdump output alignment more consistent path: pwntools_4.15.0-1/pwnlib/util/proc.py all_pids = psutil.pids def pidof(target): """pidof(target) -> int list path: pwntools_4.15.0-1/pwnlib/util/proc.py >>> l = tubes.listen.listen() >>> p = process(['curl', '-s', 'http://127.0.0.1:%d'%l.lport]) >>> pidof(p) == pidof(l) == pidof(('127.0.0.1', l.rport)) True """ path: pwntools_4.15.0-1/pwnlib/util/proc.py def pidof(target): """pidof(target) -> int list Get PID(s) of `target`. The returned PID(s) depends on the type of `target`: path: pwntools_4.15.0-1/pwnlib/util/net.py Given two addresses, returns a function comparing address pairs from psutil library against these two. Useful for filtering done in :func:`pwnlib.util.proc.pidof`. """ def sockinfos(addr, f, t): path: pwntools_4.15.0-1/pwnlib/gdb.py elif isinstance(target, str): # pidof picks the youngest process pidof = proc.pidof if context.os == 'android': path: pwntools_4.15.0-1/pwnlib/gdb.py elif isinstance(target, tubes.sock.sock): pids = proc.pidof(target) if not pids: log.error('Could not find remote process (%s:%d) on this machine' % path: pwntools_4.15.0-1/pwnlib/gdb.py if context.os == 'android': pidof = adb.pidof pids = list(pidof(target)) path: pwntools_4.15.0-1/pwnlib/gdb.py pid = target elif isinstance(target, str): # pidof picks the youngest process pidof = proc.pidof path: pwntools_4.15.0-1/pwnlib/gdb.py def findexe(): for spid in proc.pidof(target): sexe = proc.exe(spid) name = os.path.basename(sexe) path: pwntools_4.15.0-1/pwnlib/gdb.py elif isinstance(target, tubes.process.process): pid = proc.pidof(target)[0] exe = exe or target.executable elif isinstance(target, tuple) and len(target) == 2: path: pwntools_4.15.0-1/pwnlib/gdb.py pidof = adb.pidof pids = list(pidof(target)) if not pids: log.error('No such process: %s', target) path: pwntools_4.15.0-1/pwnlib/protocols/adb/__init__.py from pwnlib.util.misc import size from pwnlib.util.packing import p32 from pwnlib.util.proc import pidof from pwnlib.util.sh_string import sh_string path: pwntools_4.15.0-1/pwn/toplevel.py from pwnlib.util.misc import * from pwnlib.util.packing import * from pwnlib.util.proc import pidof from pwnlib.util.sh_string import sh_string, sh_prepare, sh_command_with from pwnlib.util.splash import * path: pwntools_4.15.0-1/pwnlib/windbg.py (target, pid)) elif isinstance(target, tubes.process.process): pid = proc.pidof(target)[0] else: log.error("don't know how to attach to target: %r", target) path: pwntools_4.15.0-1/pwnlib/windbg.py elif isinstance(target, str): # pidof picks the youngest process pids = list(proc.pidof(target)) if not pids: log.error('No such process: %s', target) path: pwntools_4.15.0-1/pwnlib/windbg.py pid = target elif isinstance(target, str): # pidof picks the youngest process pids = list(proc.pidof(target)) if not pids: path: pwntools_4.15.0-1/pwnlib/commandline/debug.py target = pidof(args.process) # pidof() returns a list if not target: log.error("Could not find a PID for %r", args.process) path: pwntools_4.15.0-1/pwnlib/commandline/debug.py target = target[0] # pidof will sometimes return all PIDs, including init if target == 1: log.error("Got PID 1 from pidof. Check the process name, or use --pid 1 to debug init") path: pwntools_4.15.0-1/pwnlib/commandline/debug.py target = adb.pidof(args.process) else: target = pidof(args.process) # pidof() returns a list path: pwntools_4.15.0-1/pwnlib/commandline/debug.py elif args.process: if context.os == 'android': target = adb.pidof(args.process) else: target = pidof(args.process) path: pwntools_4.15.0-1/pwnlib/commandline/debug.py # pidof will sometimes return all PIDs, including init if target == 1: log.error("Got PID 1 from pidof. Check the process name, or use --pid 1 to debug init") else: parser.print_usage() path: pwntools_4.15.0-1/pwnlib/adb/adb.py """Returns a list of PIDs for the named process.""" with context.quiet: # Older devices have a broken 'pidof', apparently. # Try pgrep first. io = process(['pgrep', name]) path: pwntools_4.15.0-1/pwnlib/adb/adb.py if 'not found' in data: io = process(['pidof', name]) data = io.recvall() path: pwntools_4.15.0-1/pwnlib/adb/adb.py @with_device def pidof(name): """Returns a list of PIDs for the named process.""" with context.quiet: path: pwntools_4.15.0-1/pwnlib/tubes/ssh.py b'LOLOLOL\x00/proc/self/cmdline\x00' >>> sh = s.process(executable='/bin/sh') >>> str(sh.pid).encode() in s.pidof('sh') # doctest: +SKIP True >>> io = s.process(['pwd'], cwd='/tmp')