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 = 'arm'

ARM architecture.

unknown = 'unknown'

Any other architecture.

x86 = 'x86'

X86 architecture.

class Bits[source]

Bases: enum.IntEnum

The target architecture’s word size.

bits_32 = 32

32 bit word size.

bits_64 = 64

64 bit word size.

class Endian[source]

Bases: enum.IntEnum

The target architecture’s byte order.

big = 1

Big endian.

little = 0

Little endian.

class Mode[source]

Bases: enum.IntEnum

Architecture dependant mode flags.

arm_m_class = 4

Use ARMv7-M instruction set

arm_thumb = 2

Use ARM Thumb instruction set

arm_v8 = 1

Use ARM V8 instruction set

arch

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

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'))
bits

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

endian

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

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.