File: context.rst

package info (click to toggle)
pwntools 4.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,508 kB
  • sloc: python: 59,870; ansic: 48,351; asm: 45,047; sh: 396; makefile: 256
file content (33 lines) | stat: -rw-r--r-- 910 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
.. testsetup:: *

   from pwn import *
   import logging
   log = pwnlib.log.getLogger('pwnlib.context')
   context.clear()

:mod:`pwnlib.context` --- Setting runtime variables
=====================================================

Many settings in ``pwntools`` are controlled via the global variable :data:`.context`, such as the selected target operating system, architecture, and bit-width.

In general, exploits will start with something like:

.. code-block:: python

    from pwn import *
    context.arch = 'amd64'

Which sets up everything in the exploit for exploiting a 64-bit Intel binary.

The recommended method is to use ``context.binary``  to automagically set all of the appropriate values.

.. code-block:: python

    from pwn import *
    context.binary = './challenge-binary'

Module Members
----------------------------------------------------

.. automodule:: pwnlib.context
   :members: