REFERENCE GUIDE

Pwntools tubes and reliable exploit-client synchronization

A tube abstracts process or network I/O, but the application protocol still determines when to send and receive.

Also known as: tubes · sendlineafter

pwntools-tubestooling

Mechanism

A tube abstracts process or network I/O, but the application protocol still determines when to send and receive. Reliable clients wait for explicit prompts or delimiters, preserve binary payloads, and separate local debugging from remote configuration. Hardcoded sleeps make state errors look like exploit failures.

Practical method

Capture the prompt sequence and implement one interaction at a time. Use receive-until only for delimiters confirmed by the protocol, then inspect exact bytes. Keep addresses and offsets derived from supplied artifacts separate from transport handling. Add bounded timeouts and clear diagnostics for unexpected state.

from pwn import process
io = process(["./challenge"])
io.sendlineafter(b"name: ", b"lab-user")
reply = io.recvline(timeout=2)

Interpreting evidence

A client should reach the same protocol state repeatedly before adding a corruption payload. Record the last confirmed prompt and received bytes when synchronization fails.

Pitfalls and limits

A sendline appends a newline and may invalidate binary length fields. A timeout is not necessarily EOF. Debug logging can disclose secrets or overwhelm useful state information.

Sources & further reading

  1. Tubes API ↗pwntools

Content license: CC-BY-4.0. Source-derived sections retain their cited licenses and redistribution notices. How this reference is compiled →