Skip to main content

Overview

The chain command automatically builds ROP chains to achieve specific goals like spawning a shell or calling functions with controlled arguments.

Usage

Arguments

  • path - Path to the binary to analyze

Options

  • -t, --target - Target goal for the ROP chain (required)
  • -f, --fast - Skip optimization for faster chain generation

Target Goals

The -t/--target option specifies what the ROP chain should accomplish:

execve

Generate a ROP chain that calls execve("/bin/sh", 0, 0) to spawn a shell.
  • Looks for execve in PLT or symbols
  • Searches for /bin/sh string in the binary
  • If /bin/sh is not found, writes it to writable memory first

system

Generate a ROP chain that calls system("sh") to spawn a shell.
  • Requires the binary to have a system function in PLT or symbols
  • Searches for sh string in the binary

arg1, arg2, arg3, arg4

Generate a ROP chain to call a function at address 0xdeadbeef with 1, 2, 3, or 4 arguments set to 0x41414141. Useful for testing argument-passing gadgets or calling specific functions.

Fast Mode

By default, the chain command optimizes gadgets after finding them, which can take time. Use the -f/--fast flag to skip optimization:
This generates chains faster but they may be longer or less reliable.

Output Format

The command outputs Python code using pwntools-style syntax:
You can copy this code directly into your exploit scripts.

Example: execve Chain

Performance

Like the dump command, chain uses cached gadgets from /tmp to speed up subsequent runs on the same binary. Optimization (when not using -f) runs in parallel using all available CPU cores.