Skip to main content

Guide: Local Exploit

Let's go through solving a CTF challenge on your local machine using pwntools.

Example Code for Local Exploitation

Here's an example Python script using pwntools to launch the local exploitation against the local binary.

exp_local.py
from pwn import *

# Specify the path to the local binary
# Replace 'binary_name' with the actual binary filename
binary_path = './binary_name'

# Start the local binary process
process = process(binary_path)

# Send input to the binary (example: process.sendline(b'input'))
process.sendline(b'input')

# Receive and print the output
output = process.recvline()
print(output.decode())

# Close the process
process.close()

Launch the Local Exploit!

Save the code above as exp_local.py, and then run it.

python3 exp_local.py

Using this local example, we showed how to perform the following jobs using pwntools.

  • Run the binary on your local machine
  • Send inputs to the binary
  • Receive outputs from the binary

You will need to customize this script to develop your exploit based on the specific challenge.