Convert Figma logo to code with AI

Gallopsled logopwntools

CTF framework and exploit development library

11,880
1,690
11,880
130

Top Related Projects

Some setup scripts for security research tools.

RSA attack tool (mainly for ctf) - retrieve private key from weak public key and/or uncipher data

This tool lets you search your gadgets on your binaries to facilitate your ROP exploitation. ROPgadget supports ELF, PE and Mach-O format on x86, x64, ARM, ARM64, PowerPC, SPARC, MIPS, RISC-V 64, and RISC-V Compressed architectures.

6,807

GEF (GDB Enhanced Features) - a modern experience for GDB with advanced debugging capabilities for exploit devs & reverse engineers on Linux

5,843

PEDA - Python Exploit Development Assistance for GDB

20,310

UNIX-like reverse engineering framework and command-line toolset

Quick Overview

Pwntools is a CTF framework and exploit development library. It is designed to be a one-stop-shop for CTF players and exploit developers, providing a wide range of tools and utilities to streamline the process of writing exploits and solving challenges.

Pros

  • Comprehensive toolkit for exploit development and CTF challenges
  • Easy-to-use Python API for common exploitation tasks
  • Extensive documentation and active community support
  • Cross-platform compatibility (Linux, macOS, Windows)

Cons

  • Steep learning curve for beginners
  • Can be overkill for simple tasks or small projects
  • Some features may not work as expected on Windows
  • Requires Python knowledge to use effectively

Code Examples

  1. Connecting to a remote service:
from pwn import *

# Connect to a remote service
conn = remote('example.com', 1337)
conn.recvuntil('> ')
conn.sendline('Hello, pwntools!')
response = conn.recvline()
print(response)
conn.close()
  1. Generating a cyclic pattern for buffer overflow:
from pwn import *

# Generate a cyclic pattern
pattern = cyclic(100)
print(pattern)

# Find the offset of a substring in the pattern
offset = cyclic_find('aaac')
print(f"Offset: {offset}")
  1. Packing and unpacking data:
from pwn import *

# Pack an integer as little-endian 32-bit
packed = p32(0x41424344)
print(packed)

# Unpack a byte string as big-endian 64-bit
unpacked = u64(b'\x00\x00\x00\x00\x41\x42\x43\x44', endian='big')
print(hex(unpacked))

Getting Started

To get started with pwntools:

  1. Install pwntools:

    pip install pwntools
    
  2. Import pwntools in your Python script:

    from pwn import *
    
  3. Start using pwntools functions:

    # Example: Create a process and interact with it
    p = process('/bin/sh')
    p.sendline('echo "Hello, pwntools!"')
    print(p.recvline())
    p.interactive()
    

For more detailed information and tutorials, refer to the official documentation at https://docs.pwntools.com/.

Competitor Comparisons

Some setup scripts for security research tools.

Pros of ctf-tools

  • Comprehensive collection of various CTF tools, not limited to exploitation
  • Easy installation and management of multiple tools through a unified interface
  • Regularly updated with new tools and community contributions

Cons of ctf-tools

  • Less focused on exploitation-specific tasks compared to pwntools
  • May require more setup time and disk space due to the wide range of tools
  • Not as deeply integrated or optimized for specific exploitation tasks

Code Comparison

While a direct code comparison is not particularly relevant due to the different nature of these projects, here's a brief example of how they might be used:

ctf-tools:

./ctf-tools/bin/manage-tools install pwntools
./ctf-tools/bin/manage-tools install radare2

pwntools:

from pwn import *
r = remote('example.com', 1337)
r.sendline(asm(shellcraft.sh()))
r.interactive()

pwntools provides a more streamlined and Python-centric approach for exploitation tasks, while ctf-tools offers a broader set of utilities for various CTF challenges.

RSA attack tool (mainly for ctf) - retrieve private key from weak public key and/or uncipher data

Pros of RsaCtfTool

  • Specialized for RSA cryptography attacks and analysis
  • Includes a wide range of RSA-specific attack methods
  • User-friendly command-line interface for quick RSA operations

Cons of RsaCtfTool

  • Limited scope, focusing only on RSA cryptography
  • Less versatile for general-purpose exploitation tasks
  • Smaller community and fewer updates compared to pwntools

Code Comparison

RsaCtfTool:

from RsaCtfTool.RsaCtfTool import RsaCtfTool

rsa_ctf_tool = RsaCtfTool()
result = rsa_ctf_tool.attack(n=modulus, e=public_exponent)

pwntools:

from pwn import *

conn = remote('target.com', 1337)
payload = asm(shellcraft.sh())
conn.sendline(payload)
conn.interactive()

RsaCtfTool is focused on RSA operations, while pwntools offers a broader set of exploitation tools. RsaCtfTool is ideal for CTF challenges involving RSA cryptography, whereas pwntools is more versatile for general exploitation tasks, including binary exploitation, networking, and cryptography.

This tool lets you search your gadgets on your binaries to facilitate your ROP exploitation. ROPgadget supports ELF, PE and Mach-O format on x86, x64, ARM, ARM64, PowerPC, SPARC, MIPS, RISC-V 64, and RISC-V Compressed architectures.

Pros of ROPgadget

  • Specialized tool focused solely on ROP gadget discovery and exploitation
  • Lightweight and easy to use for quick gadget analysis
  • Supports a wide range of architectures (x86, x86-64, ARM, MIPS, PowerPC, etc.)

Cons of ROPgadget

  • Limited functionality compared to pwntools' comprehensive exploit development toolkit
  • Lacks advanced features like shellcode generation and remote exploitation capabilities
  • Not actively maintained (last commit over 2 years ago)

Code Comparison

ROPgadget (searching for gadgets):

from ROPGadget.ROPGadget import *
gadgets = ROPGadget(binary="./vulnerable_binary")
gadgets.dump_gadgets()

pwntools (equivalent functionality):

from pwn import *
elf = ELF("./vulnerable_binary")
rop = ROP(elf)
for gadget in rop.gadgets:
    print(hex(gadget.address), gadget.insns)

Both tools can search for ROP gadgets, but pwntools offers a more comprehensive suite of exploit development tools, including shellcode generation, remote exploitation, and debugging capabilities. ROPgadget is more focused and lightweight, making it suitable for quick gadget analysis, while pwntools is better suited for full exploit development workflows.

6,807

GEF (GDB Enhanced Features) - a modern experience for GDB with advanced debugging capabilities for exploit devs & reverse engineers on Linux

Pros of GEF

  • Integrated directly into GDB, providing a seamless debugging experience
  • Offers a rich set of commands and features specifically tailored for exploit development and reverse engineering
  • Provides a user-friendly interface with colorized output and helpful visualizations

Cons of GEF

  • Limited to GDB and cannot be used as a standalone library or in scripts
  • May have a steeper learning curve for users not familiar with GDB
  • Less portable across different platforms compared to pwntools

Code Comparison

GEF (within GDB):

gef> checksec
[+] checksec for '/path/to/binary'
Canary                        : ✓
NX                            : ✓
PIE                           : ✓
Fortify                       : ✓
RelRO                         : Full

pwntools:

from pwn import *
elf = ELF('/path/to/binary')
print(elf.checksec())

Both tools offer powerful features for binary analysis and exploit development. GEF excels in providing an enhanced GDB experience, while pwntools offers more flexibility as a Python library for various exploitation tasks.

5,843

PEDA - Python Exploit Development Assistance for GDB

Pros of PEDA

  • Lightweight and easy to integrate with GDB
  • Provides colorful and informative display during debugging
  • Offers useful commands for memory analysis and exploitation

Cons of PEDA

  • Limited to GDB environment, not as versatile for general exploitation tasks
  • Less comprehensive documentation compared to pwntools
  • Fewer features for automating exploit development

Code Comparison

PEDA (used within GDB):

gdb-peda$ checksec
CANARY    : disabled
FORTIFY   : disabled
NX        : ENABLED
PIE       : disabled
RELRO     : Partial

pwntools:

from pwn import *
elf = ELF('./binary')
print(elf.checksec())

Both tools provide security checks, but pwntools offers a more programmatic approach that can be integrated into larger scripts and exploit development workflows. PEDA is primarily used interactively within GDB, while pwntools can be used for a wider range of tasks, including exploit development, binary analysis, and CTF solving.

PEDA excels in providing a user-friendly debugging environment with enhanced visualization, while pwntools offers a more comprehensive suite of tools for exploit development and binary analysis that can be used both inside and outside of a debugger.

20,310

UNIX-like reverse engineering framework and command-line toolset

Pros of radare2

  • More comprehensive reverse engineering framework with a wider range of tools
  • Supports a larger number of architectures and file formats
  • Offers both CLI and GUI interfaces for flexibility

Cons of radare2

  • Steeper learning curve due to its complexity and extensive feature set
  • Less focused on exploit development compared to pwntools
  • Can be overwhelming for beginners or those primarily interested in binary exploitation

Code Comparison

radare2:

r2 -d ./binary
[0x00400500]> pdf @ main
[0x00400500]> px 32 @ rsp

pwntools:

from pwn import *
p = process('./binary')
p.recvuntil('> ')
p.sendline('payload')

Summary

radare2 is a comprehensive reverse engineering framework suitable for various tasks, while pwntools is more specialized for exploit development and CTF challenges. radare2 offers broader functionality but may be more complex, whereas pwntools provides a streamlined experience for binary exploitation tasks.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

pwntools - CTF toolkit

pwntools logo

PyPI Docs GitHub Workflow Status (dev) Coveralls MIT License Packaging status Discord Twitter

Pwntools is a CTF framework and exploit development library. Written in Python, it is designed for rapid prototyping and development, and intended to make exploit writing as simple as possible.

from pwn import *
context(arch = 'i386', os = 'linux')

r = remote('exploitme.example.com', 31337)
# EXPLOIT CODE GOES HERE
r.send(asm(shellcraft.sh()))
r.interactive()

Documentation

Our documentation is available at docs.pwntools.com

A series of tutorials is also available online

To get you started, we've provided some example solutions for past CTF challenges in our write-ups repository.

Installation

Pwntools is best supported on 64-bit Ubuntu LTS releases (14.04, 16.04, 18.04, and 20.04). Most functionality should work on any Posix-like distribution (Debian, Arch, FreeBSD, OSX, etc.).

Python3 is suggested, but Pwntools still works with Python 2.7. Most of the functionality of pwntools is self-contained and Python-only. You should be able to get running quickly with

sudo apt-get update
sudo apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pwntools

However, some of the features (assembling/disassembling foreign architectures) require non-Python dependencies. For more information, see the complete installation instructions here.

Contribution

See CONTRIBUTING.md

Contact and Community

If you have any questions not worthy of a bug report, join the Discord server at https://discord.gg/96VA2zvjCB