Cyber Training Guide
CTF WriteupsOther NotesHow-To: Radare2How-To: GDB
  • Cyber Training Guide
  • 0x0: Introduction
    • git-good
    • root-1
    • root-2
    • intro
  • Binary Exploitation (pwn)
    • What is Binary Exploitation?
    • 0x1: ret2win
      • win32
      • win64
      • args
    • 0x2: shellcodes
      • location
      • shell
      • constrained
    • 0x3: format strings
      • format
      • chase
      • bbpwn
    • 0x4: stack canaries
      • canary
      • findme
    • 0x5: ROP
      • rop2win
      • split
      • callme
      • write4
      • badchars
    • 0x6: PIE
      • gimme
      • leak32
      • leak64
    • 0x7: ASLR
      • groundzero
      • stepup
      • ret2plt
    • 0x8: GOT overwrites
      • gotem
      • gotem64
  • Programming
    • What is the Programming Section?
    • 0x9: Data Serialization
      • LinkedOps
      • Tree
      • TeLeVision
    • 0xA: Programming
      • Calorie Counting
      • Hash
      • Rock Paper Scissors
      • Watch the Register
      • Supply Stacks
      • Rope Bridge
      • Mountain Climbers
  • Reverse Engineering (RE)
    • What is Reverse Engineering?
    • 0xB: Ghidra
      • hardcode
      • undo
      • snake
  • Toolkit
    • Using Pwntools
      • Establishing Connection
      • Context
      • Sending/Receiving Data
      • The ELF Class
    • My Workflow
      • Tmux
      • Vim
Powered by GitBook
On this page
  • Primary Attributes
  • context.arch
  • context.os
  • context.endian
  • context.word_size
  • Grouping this together
  • Other Attributes
  • context.log_level
  • context.terminal

Was this helpful?

  1. Toolkit
  2. Using Pwntools

Context

Context is a global object used to store information about the target binary and the environment it's being run. There are a number of attributes that can be set.

Primary Attributes

context.arch

We can use this to set the architecture of the target binary. This is useful for packing and unpacking data, as well as for shellcode generation.

context.arch = 'i386'

context.os

We can use this to set the operating system of the target binary. This is useful for shellcode generation.

context.os = 'linux'

context.endian

We can use this to set the endianness of the target binary. This is useful for packing and unpacking data.

context.endian = 'little'

context.word_size

We can use this to set the word size of the target binary. This is useful for shellcode generation (and packing data with flat).

context.word_size = 32

Grouping this together

We can simply set context.binary to the binary we're using, and pwntools will automatically set the architecture, operating system, endianness, and word size.

context.binary = ELF('./win32')

Other Attributes

context.log_level

We can set the verbosity of the output logger.

context.log_level = 'debug'

context.terminal

For those that use the tmux, we can use context.terminal to set how the window is split.

context.terminal = ['tmux', 'splitw', '-h']
PreviousEstablishing ConnectionNextSending/Receiving Data

Last updated 1 year ago

Was this helpful?

This takes an ELF object. More information on the ELF class .

here