ptrace Package

cpu_info Module

Constants about the CPU:

  • CPU_BIGENDIAN (bool)
  • CPU_64BITS (bool)
  • CPU_WORD_SIZE (int)
  • CPU_MAX_UINT (int)
  • CPU_PPC32 (bool)
  • CPU_PPC64 (bool)
  • CPU_I386 (bool)
  • CPU_X86_64 (bool)
  • CPU_INTEL (bool)
  • CPU_POWERPC (bool)

ctypes_errno Module

Function get_errno(): get the current errno value.

Try different implementations:
  • ctypes_support.get_errno() function
  • __errno_location_sym symbol from the C library
  • PyErr_SetFromErrno() from the C Python API
FingerPrint.ptrace.ctypes_errno.get_errno()[source]

Read errno using Python C API: raise an exception with PyErr_SetFromErrno and then read error code ‘errno’.

This function may raise an RuntimeError.

ctypes_libc Module

Load the system C library. Variables:
  • LIBC_FILENAME: the C library filename
  • libc: the loaded library

ctypes_tools Module

FingerPrint.ptrace.ctypes_tools.bytes2array(bytes, basetype, size)[source]

Cast a bytes string to an array of objets of the specified type and size.

FingerPrint.ptrace.ctypes_tools.bytes2type(bytes, type)[source]

Cast a bytes string to an objet of the specified type.

FingerPrint.ptrace.ctypes_tools.bytes2word(bytes)[source]

Convert a bytes string to an unsigned integer (a CPU word).

FingerPrint.ptrace.ctypes_tools.formatAddress(address)[source]

Format an address to hexadecimal. Return “NULL” for zero.

FingerPrint.ptrace.ctypes_tools.formatAddressRange(start, end)[source]

Format an address range, eg. “0x80004000-0x8000ffff”.

FingerPrint.ptrace.ctypes_tools.formatUintHex16(value)[source]

Format an 16 bits unsigned integer.

FingerPrint.ptrace.ctypes_tools.formatUintHex32(value)[source]

Format an 32 bits unsigned integer.

FingerPrint.ptrace.ctypes_tools.formatUintHex64(value)[source]

Format an 64 bits unsigned integer.

FingerPrint.ptrace.ctypes_tools.formatWordHex(value)

Format an 64 bits unsigned integer.

FingerPrint.ptrace.ctypes_tools.int2uint(value)

Convert a signed 32 bits integer into an unsigned 32 bits integer.

FingerPrint.ptrace.ctypes_tools.int2uint32(value)[source]

Convert a signed 32 bits integer into an unsigned 32 bits integer.

FingerPrint.ptrace.ctypes_tools.int2uint64(value)[source]

Convert a signed 64 bits integer into an unsigned 64 bits integer.

FingerPrint.ptrace.ctypes_tools.long2ulong(value)

Convert a signed 64 bits integer into an unsigned 64 bits integer.

FingerPrint.ptrace.ctypes_tools.ntoh_uint(value)[source]

Convert an unsigned integer from network endiant to host endian.

FingerPrint.ptrace.ctypes_tools.ntoh_ushort(value)[source]

Convert an unsigned short integer from network endiant to host endian.

FingerPrint.ptrace.ctypes_tools.truncateWord(value)

Truncate an unsigned integer to 64 bits.

FingerPrint.ptrace.ctypes_tools.truncateWord32(value)[source]

Truncate an unsigned integer to 32 bits.

FingerPrint.ptrace.ctypes_tools.truncateWord64(value)[source]

Truncate an unsigned integer to 64 bits.

FingerPrint.ptrace.ctypes_tools.uint2int(value)

Convert an unsigned 32 bits integer into a signed 32 bits integer.

FingerPrint.ptrace.ctypes_tools.uint2int32(value)[source]

Convert an unsigned 32 bits integer into a signed 32 bits integer.

FingerPrint.ptrace.ctypes_tools.uint2int64(value)[source]

Convert an unsigned 64 bits integer into a signed 64 bits integer.

FingerPrint.ptrace.ctypes_tools.ulong2long(value)

Convert an unsigned 64 bits integer into a signed 64 bits integer.

FingerPrint.ptrace.ctypes_tools.word2bytes(word)[source]

Convert an unsigned integer (a CPU word) to a bytes string.

error Module

exception FingerPrint.ptrace.error.PtraceError(message, errno=None, pid=None)[source]

Bases: exceptions.Exception

Ptrace error: have the optional attributes errno and pid.

func Module

FingerPrint.ptrace.func.WPTRACEEVENT(status)[source]
FingerPrint.ptrace.func.ptrace(command, pid=0, arg1=0, arg2=0, check_errno=False)[source]
FingerPrint.ptrace.func.ptrace_attach(pid)[source]
FingerPrint.ptrace.func.ptrace_cont(pid, signum=0)[source]
FingerPrint.ptrace.func.ptrace_detach(pid, signal=0)[source]
FingerPrint.ptrace.func.ptrace_geteventmsg(pid)[source]
FingerPrint.ptrace.func.ptrace_getfpregs(pid)[source]
FingerPrint.ptrace.func.ptrace_getregs(pid)[source]
FingerPrint.ptrace.func.ptrace_getsiginfo(pid)[source]
FingerPrint.ptrace.func.ptrace_kill(pid)[source]
FingerPrint.ptrace.func.ptrace_peekdata(pid, address)[source]
FingerPrint.ptrace.func.ptrace_peektext(pid, address)[source]
FingerPrint.ptrace.func.ptrace_peekuser(pid, address)[source]
FingerPrint.ptrace.func.ptrace_pokedata(pid, address, word)[source]
FingerPrint.ptrace.func.ptrace_poketext(pid, address, word)[source]
FingerPrint.ptrace.func.ptrace_pokeuser(pid, address, word)[source]
FingerPrint.ptrace.func.ptrace_setfpregs(pid, fpregs)[source]
FingerPrint.ptrace.func.ptrace_setoptions(pid, options)[source]
FingerPrint.ptrace.func.ptrace_setregs(pid, regs)[source]
FingerPrint.ptrace.func.ptrace_setsiginfo(pid, info)[source]
FingerPrint.ptrace.func.ptrace_singlestep(pid)[source]
FingerPrint.ptrace.func.ptrace_syscall(pid, signum=0)[source]
FingerPrint.ptrace.func.ptrace_traceme()[source]

linux_struct Module

class FingerPrint.ptrace.linux_struct.siginfo[source]

Bases: _ctypes.Structure

pad

Structure/Union member

si_code

Structure/Union member

si_errno

Structure/Union member

si_signo

Structure/Union member

class FingerPrint.ptrace.linux_struct.user_fpregs_struct[source]

Bases: _ctypes.Structure

cwd

Structure/Union member

fop

Structure/Union member

ftw

Structure/Union member

mxcr_mask

Structure/Union member

mxcsr

Structure/Union member

padding

Structure/Union member

rdp

Structure/Union member

rip

Structure/Union member

st_space

Structure/Union member

swd

Structure/Union member

xmm_space

Structure/Union member

class FingerPrint.ptrace.linux_struct.user_regs_struct[source]

Bases: _ctypes.Structure

cs

Structure/Union member

ds

Structure/Union member

eflags

Structure/Union member

es

Structure/Union member

fs

Structure/Union member

fs_base

Structure/Union member

gs

Structure/Union member

gs_base

Structure/Union member

orig_rax

Structure/Union member

r10

Structure/Union member

r11

Structure/Union member

r12

Structure/Union member

r13

Structure/Union member

r14

Structure/Union member

r15

Structure/Union member

r8

Structure/Union member

r9

Structure/Union member

rax

Structure/Union member

rbp

Structure/Union member

rbx

Structure/Union member

rcx

Structure/Union member

rdi

Structure/Union member

rdx

Structure/Union member

rip

Structure/Union member

rsi

Structure/Union member

rsp

Structure/Union member

ss

Structure/Union member

os_tools Module

Constants about the operating system:

  • RUNNING_PYPY (bool)
  • RUNNING_WINDOWS (bool)
  • RUNNING_LINUX (bool)
  • RUNNING_FREEBSD (bool)
  • RUNNING_OPENBSD (bool)
  • RUNNING_MACOSX (bool)
  • RUNNING_BSD (bool)
  • HAS_PROC (bool)
  • HAS_PTRACE (bool)

signames Module

Name of process signals.

SIGNAMES contains a dictionary mapping a signal number to it’s name. But you should better use signalName() instead of SIGNAMES since it returns a string even if the signal is unknown.

FingerPrint.ptrace.signames.getSignalNames()[source]

Create signal names dictionay (eg. 9 => ‘SIGKILL’) using dir(signal). If multiple signal names have the same number, use the first matching name in PREFERRED_NAME to select preferred name (eg. SIGIOT=SIGABRT=17).

FingerPrint.ptrace.signames.signalName(signum)[source]

Get the name of a signal

>>> from signal import SIGINT
>>> signalName(SIGINT)
'SIGINT'
>>> signalName(404)
'signal<404>'