pwnlib.log and — Logging stuff

Logging module for printing status during an exploit, and internally within pwntools.

Exploit Developers

By using the standard from pwn import *, an object named log will be inserted into the global namespace. You can use this to print out status messages during exploitation.

For example,:'Hello, world!')


[*] Hello, world!

Additionally, there are some nifty mechanisms for performing status updates on a running job (e.g. when brute-forcing).:

p = log.progress('Working')
p.status('Reticulating splines')
p.success('Got a shell!')

The verbosity of logging can be most easily controlled by setting context.log_level on the global context object.:"No you see me")
context.log_level = 'error'"Now you don't")

Pwnlib Developers

A module-specific logger can be imported into the module via:

log = logging.getLogger(__name__)

This provides an easy way to filter logging programmatically or via a configuration file for debugging.

There’s no need to expressly import this log module.

When using progress, you should use the with keyword to manage scoping, to ensure the spinner stops if an exception is thrown.

class pwnlib.log.Logger(*args, **kwargs)[source]

Specialization of logging.Logger which uses pwnlib.context.context.log_level to infer verbosity.

Also adds some pwnlib flavor via:

Adds pwnlib-specific information for coloring and indentation to the log records passed to the logging.Formatter.


Permits prepending a string to each message, by means of msg_prefix. This is leveraged for progress messages.

Logs a debug message.


To be called outside an exception handler.

Logs an error message, then raises a PwnlibException.


Logs a failure message. If the Logger is animated, the animation is stopped.

indented(message, level=logging.INFO)[source]

Log an info message without the line prefix.

Parameters:level (int) – Alternate log level at which to set the indented message.

Logs an info message.


Logs an info message. The same message is never printed again.

progress(self) → Logger[source]

Creates a Logger with a progress animation, which can be stopped via success(), and failure().

The Logger returned is also a scope manager. Using scope managers ensures that the animation is stopped, even if an exception is thrown.

with log.progress(‘Trying something...’) as p:
for i in range(10):
p.status(“At %i” % i) time.sleep(0.5)

x = 1/0


Logs a success message. If the Logger is animated, the animation is stopped.


Logs a warning message.


Logs a warning message. The same message is never printed again.