Establishing Connection
Pwntools establishes a standard interface for connecting to binaries, both locally and remotely. This is accomplished via the pwnlib.tubes
module.
Connecting to a Remote Process
Use remote()
for easy connection to remote processes.
You can also use a listener to connect to a remote process.
Connecting to a Local Process
Use process()
for easy connection to local processes.
Using GDB with Pwntools
We can use gdb.debug()
to run a local process within gdb
. This takes a secondary argument, gdbscript
, which is a string of commands to run in gdb
. This is useful for setting breakpoints, etc.
People commonly use a separate variable for their gdbscript
because it's easier to read. Using a separate string allows you to use triple quotes, which makes it easier to write multi-line scripts.
This allowed us to write commands without using the newline character. It also generally makes the code easier to read.
We can use gdb.attach()
to attach to a process. It takes the target to attach to (which, under the hood, is the process ID).
Last updated