pwnlib.args — Magic Command-Line Arguments

Pwntools exposes several magic command-line arguments and environment variables when operating in from pwn import * mode.

The arguments extracted from the command-line and removed from sys.argv.

Arguments can be set by appending them to the command-line, or setting them in the environment prefixed by PWNLIB_.

The easiest example is to enable more verbose debugging. Just set DEBUG.

$ PWNLIB_DEBUG=1 python
$ python DEBUG

These arguments are automatically extracted, regardless of their name, and exposed via pwnlib.args.args, which is exposed as the global variable args. Arguments which pwntools reserves internally are not exposed this way.

$ python -c 'from pwn import *; print(args)' A=1 B=Hello HOST= DEBUG
defaultdict(<type 'str'>, {'A': '1', 'HOST': '', 'B': 'Hello'})

This is very useful for conditional code, for example determining whether to run an exploit locally or to connect to a remote server. Arguments which are not specified evaluate to an empty string.

if args['REMOTE']:
    io = remote('', 4141)
    io = process('./pwnable')

Arguments can also be accessed directly with the dot operator, e.g.:

if args.REMOTE:

Any undefined arguments evaluate to an empty string, ''.

The full list of supported “magic arguments” and their effects are listed below.

class pwnlib.args.PwnlibArgs[source]

list of weak references to the object (if defined)


Sets the logging verbosity to debug which displays much more information, including logging each byte sent by tubes.


Sets path to local libc-database via context.local_libcdb, e.g. LOCAL_LIBCDB='/path/to/libc-databse'


Sets a log file to be used via context.log_file, e.g. LOG_FILE=./log.txt


Sets the logging verbosity used via context.log_level, e.g. LOG_LEVEL=debug.


Disables ASLR via context.aslr


Disables facilities which require ptrace such as gdb.attach() statements, via context.noptrace.


Disables pretty terminal settings and animations.


Enables randomization of various pieces via context.randomize


Sets the logging verbosity to error which silences most output.


Sends logging to stderr by default, instead of stdout


Sets a timeout for tube operations (in seconds) via context.timeout, e.g. TIMEOUT=30


Convert a string to its boolean value


Helper function to check whether a string is a valid identifier, as passed in on the command-line.