libdebug.interfaces package#

Submodules#

libdebug.interfaces.debugging_interface module#

class libdebug.interfaces.debugging_interface.DebuggingInterface[source]#

Bases: ABC

The interface used by _InternalDebugger to communicate with the available debugging backends, such as ptrace or gdb.

abstract reset() None[source]#

Resets the state of the interface.

abstract run() None[source]#

Runs the specified process.

abstract attach(pid: int) None[source]#

Attaches to the specified process.

Parameters:

pid (int) – the pid of the process to attach to.

abstract detach() None[source]#

Detaches from the process.

abstract kill() None[source]#

Instantly terminates the process.

abstract cont() None[source]#

Continues the execution of the process.

abstract wait() None[source]#

Waits for the process to stop.

abstract migrate_to_gdb() None[source]#

Migrates the current process to GDB.

abstract migrate_from_gdb() None[source]#

Migrates the current process from GDB.

abstract step(thread: ThreadContext) None[source]#

Executes a single instruction of the specified thread.

Parameters:

thread (ThreadContext) – The thread to step.

abstract step_until(thread: ThreadContext, address: int, max_steps: int) None[source]#

Executes instructions of the specified thread until the specified address is reached.

Parameters:
  • thread (ThreadContext) – The thread to step.

  • address (int) – The address to reach.

  • max_steps (int) – The maximum number of steps to execute.

abstract finish(thread: ThreadContext, heuristic: str) None[source]#

Continues execution until the current function returns or the process stops.

The command requires a heuristic to determine the end of the function. The available heuristics are: - backtrace: The debugger will place a breakpoint on the saved return address found on the stack and continue execution on all threads. - step-mode: The debugger will step on the specified thread until the current function returns. This will be slower.

Parameters:
  • thread (ThreadContext) – The thread to finish.

  • heuristic (str, optional) – The heuristic to use. Defaults to “backtrace”.

abstract maps() list[MemoryMap][source]#

Returns the memory maps of the process.

abstract set_breakpoint(bp: Breakpoint) None[source]#

Sets a breakpoint at the specified address.

Parameters:

bp (Breakpoint) – The breakpoint to set.

abstract unset_breakpoint(bp: Breakpoint) None[source]#

Restores the original instruction flow at the specified address.

Parameters:

bp (Breakpoint) – The breakpoint to restore.

abstract set_syscall_hook(hook: SyscallHook) None[source]#

Sets a syscall hook.

Parameters:

hook (SyscallHook) – The syscall hook to set.

abstract unset_syscall_hook(hook: SyscallHook) None[source]#

Unsets a syscall hook.

Parameters:

hook (SyscallHook) – The syscall hook to unset.

abstract set_signal_hook(hook: SignalHook) None[source]#

Sets a signal hook.

Parameters:

hook (SignalHook) – The signal hook to set.

abstract unset_signal_hook(hook: SignalHook) None[source]#

Unsets a signal hook.

Parameters:

hook (SignalHook) – The signal hook to unset.

abstract peek_memory(address: int) int[source]#

Reads the memory at the specified address.

Parameters:

address (int) – The address to read.

Returns:

The read memory value.

Return type:

int

abstract poke_memory(address: int, data: int) None[source]#

Writes the memory at the specified address.

Parameters:
  • address (int) – The address to write.

  • data (int) – The value to write.

libdebug.interfaces.interface_helper module#

libdebug.interfaces.interface_helper.provide_debugging_interface(interface: AvailableInterfaces = AvailableInterfaces.PTRACE) DebuggingInterface[source]#

Returns an instance of the debugging interface to be used by the _InternalDebugger class.

libdebug.interfaces.interfaces module#

class libdebug.interfaces.interfaces.AvailableInterfaces(value)[source]#

Bases: Enum

An enumeration of the available backend interfaces.

PTRACE = 1#

Module contents#