#challenge #reverse-engineering #ctf #exploitation #pwntools #memory #process

rust_pwntools

A Rust crate inspired by Pwntools, providing powerful tools for binary exploitation, reverse engineering, and CTF challenges

1 unstable release

Uses new Rust 2024

new 0.1.0 Mar 12, 2025

#2 in #pwntools

Download history 87/week @ 2025-03-07

87 downloads per month

MIT license

15KB
307 lines

Rust PwnTools

Rust PwnTools is a Rust crate inspired by Pwntools in Python, providing powerful tools for binary exploitation, reverse engineering, and CTF challenges. The crate supports:

  • Process Handling
  • Network Communication
  • ELF & Binary Analysis
  • ROP & Exploit Development
  • Memory Operations
  • Utilities

Getting Started

Add this to your Cargo.toml:

[dependencies]
rust_pwntools = "0.1.0"

Usage

Process Handling

use rust_pwntools::process::Process;

let mut process = Process::new("ls", &["-l"]).expect("Failed to spawn process");
let output = process.read_output().expect("Failed to read output");
println!("Output: {}", output);

Network Communication

use rust_pwntools::network::Remote;
use tokio::runtime::Runtime;

let rt = Runtime::new().unwrap();
rt.block_on(async {
    let mut remote = Remote::connect_tcp("example.com:80").await.expect("Failed to connect");
    remote.send(b"GET / HTTP/1.0\r\n\r\n").await.expect("Failed to send data");
    let mut buffer = [0u8; 1024];
    let n = remote.receive(&mut buffer).await.expect("Failed to receive data");
    println!("Received {} bytes", n);
});

Binary Analysis

use rust_pwntools::binary::Binary;
use std::path::Path;

let binary = Binary::parse(Path::new("/bin/ls")).expect("Failed to parse binary");
for symbol in binary.symbols() {
    println!("Symbol: {}", symbol);
}

ROP & Exploit Development

use rust_pwntools::exploit::RopChain;

let mut rop_chain = RopChain::new();
rop_chain.add_gadget(0xdeadbeef);
let payload = rop_chain.generate_payload(4);
println!("Payload: {:?}", payload);

Memory Operations

use rust_pwntools::memory::Memory;

let pid = 12345; // Replace with a real PID for testing
let memory = Memory::attach(pid).expect("Failed to attach to process");
let mut buffer = [0u8; 4];
memory.read(0x7fffffffdfd0, &mut buffer).expect("Failed to read memory");
println!("Memory: {:?}", buffer);
memory.detach().expect("Failed to detach from process");

License

This project is licensed under the MIT License.

Dependencies

~5–11MB
~110K SLoC