Python CTF framework and exploit development library for binary exploitation, shellcode generation, and ROP chain building.
python3 -c "from pwn import *; {command}" ๐ command โ python3 -c "from pwn import *; {command}" Sandbox: execFile · Timeout: 120s
exploit.development shellcode.generation rop.chain binary.analysis reverse.patching | 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 |
Inputs
file.binary Binary to analyze
Outputs
exploit.script Python exploit script
exploit.shellcode Generated shellcode bytes
process_spawnnetwork_traffic Produces
exploit.scriptexploit.shellcodeConsumes
file.binary| Resource | Value |
|---|---|
| CPU | medium |
| Memory | 256 MB |
| Network | low |
| Disk I/O | low |
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 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.
| 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 |
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()