arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Logging and Context

hashtag
Logging

Logging is a very useful feature of pwntools that lets you know where in your code you've gotten up to, and you can log in different ways for different types of data.

hashtag
log.info(text)

hashtag
log.success(text)

hashtag
log.error(text)

hashtag
Context

context is a 'global' variable in pwntools that allows you to set certain values once and all future functions automatically use that data.

Now every time you generate shellcode or use the p64() and u64() functions it will be specifically designed to use the context variables, meaning it will just work. The power of pwntools.

If you think that's a lot of setup, make it even simpler.

This enables you to do a lot more things as well - for example, if you run

it will automatically use the context binary and you will not have to specify it again.

>>> log.info('Binary Base is at 0x400000')
[*] Binary Base is at 0x400000
>>> log.success('ASLR bypassed! Libc base is at 0xf7653000')
[+] ASLR bypassed! Libc base is at 0xf7653000
>>> log.success('The payload is too long')
[-] The payload is too long
context.arch = 'i386'
context.os = 'linux'
context.endian = 'little'
context.bits = 64
context.binary = './vulnerable_binary'
p = process()