Skip to content

Shellcode

Shellcode

This module implements functionality that allows for the execution of a small amount of code in the context of the inferior.

exec_shellcode(blob, restore_context=True, capture=None, disable_breakpoints=False)

Tries executing the given blob of machine code in the current context of the inferior, optionally restoring the values of the registers as they were before the shellcode ran, as a means to allow for execution of the inferior to continue uninterrupted. The value of the program counter is always restored.

Additionally, the caller may specify an object to be called before the context is restored, so that information stored in the registers after the shellcode finishes can be retrieved. The return value of that call will be returned by this function.

Safety

Seeing as this function injects code directly into the inferior and runs it, the caller must be careful to inject code that will (1) terminate and (2) not cause the inferior to misbehave. Otherwise, it is fairly easy to crash or currupt the memory in the inferior.

exec_syscall(syscall, arg0=None, arg1=None, arg2=None, arg3=None, arg4=None, arg5=None, arg6=None, disable_breakpoints=False)

Tries executing the given syscall in the context of the inferior.