target – Target definition

The Target class describes the architecture of a targeted machine, executable or environment. It encodes the generic architecture, the word size, the byte order and an architecture dependant mode.

It is used throughout pwnypack to determine how data should be interpreted or emitted.

class pwnypack.target.Target(arch=None, bits=None, endian=None, mode=0)[source]

Bases: object

class Arch[source]

Bases: enum.Enum

Describes the general architecture of a target.

arm = None

ARM architecture.

unknown = None

Any other architecture.

x86 = None

X86 architecture.

class Target.Bits[source]

Bases: enum.IntEnum

The target architecture’s word size.

bits_32 = None

32 bit word size.

bits_64 = None

64 bit word size.

class Target.Endian[source]

Bases: enum.IntEnum

The target architecture’s byte order.

big = None

Big endian.

little = None

Little endian.

class Target.Mode[source]

Bases: enum.IntEnum

Architecture dependant mode flags.

arm_m_class = None

Use ARMv7-M instruction set

arm_thumb = None

Use ARM Thumb instruction set

arm_v8 = None

Use ARM V8 instruction set

Target.arch

The target’s architecture. One of Target.Arch.

Target.assume(other)[source]

Assume the identity of another target. This can be useful to make the global target assume the identity of an ELF executable.

Parameters:other (Target) – The target whose identity to assume.

Example

>>> from pwny import *
>>> target.assume(ELF('my-executable'))
Target.bits

The target architecture word size. One of Target.Bits.

Target.endian

The target architecture byte order. One of Target.Endian.

Target.mode

The target architecture dependant flags. OR’ed values of Target.Mode.

pwnypack.target.target = Target(arch=x86,bits=64,endian=little,mode=0)

The global, default target. If no targeting information is provided to a function, this is the target that will be used.