security enabled verified medium v1.0.0

pwntools

Python CTF framework and exploit development library for binary exploitation, shellcode generation, and ROP chain building.

📋 Live Preview
python3 -c "from pwn import *; {command}"
๐ŸŒ command โ†’
python3 -c "from pwn import *; {command}"

Sandbox: execFile · Timeout: 120s

Capabilities

exploit.development
shellcode.generation
rop.chain
binary.analysis
reverse.patching

Parameters

Name Type Required Default Description Aliases
checksec boolean No - Check binary security hardening (via checksec script) checksec
asm string No - Assemble instructions to bytes asm
disasm string No - Disassemble bytes to instructions disasm
cyclic integer No - Generate cyclic pattern of given length cyclic
hex string No - Convert bytes to hex string hex
unhex string No - Convert hex string to bytes unhex
constgrep string No - Search for constants by regex constgrep
errno string No - Look up errno values errno
update boolean No - Update pwntools to the latest version update
file string No - Binary file to analyze --file

Contract

Inputs

file.binary

Binary to analyze

Outputs

exploit.script

Python exploit script

exploit.shellcode

Generated shellcode bytes

Side effects: process_spawnnetwork_traffic

Workflow Edges

Produces

exploit.scriptexploit.shellcode

Consumes

file.binary

Resource Profile

ResourceValue
CPUmedium
Memory256 MB
Networklow
Disk I/Olow

Examples

Check binary security mitigations

python3 -m pwn checksec /bin/ls

Generate cyclic pattern

python3 -c "from pwn import *; print(cyclic(100))"

Disassemble bytes

python3 -c "from pwn import *; print(disasm(b'\\x90\\x90'))"

Assemble instructions

python3 -c "from pwn import *; print(asm('nop'))"

Convert hex to bytes and back

python3 -c "from pwn import *; print(unhex('48656c6c6f')); print(hex(b'Hello'))"

Build and send a ROP chain

python3 exploit.py

Documentation

pwntools โ€” CTF Exploit Development Framework

pwntools is a Python library designed for CTF (Capture The Flag) binary exploitation. It streamlines common tasks such as assembling shellcode, building ROP chains, connecting to remote services, and debugging exploits locally.

Key Modules

Module Purpose
pwn.asm Assemble and disassemble instructions
pwn.elf ELF binary parsing and patching
pwn.rop Automatic ROP chain building
pwn.shellcraft Shellcode template generation
pwn.cyclic Pattern generation for offset discovery

Common Pattern

from pwn import *

elf = ELF('./vuln')
rop = ROP(elf)
rop.call('system', [next(elf.search(b'/bin/sh'))])
io = process('./vuln')
io.sendline(rop.chain())
io.interactive()

Dependencies

python3

Related Tools

gdbropgadgetchecksecpwndbg