e = ELF("./executable")
struct
module and the struct.pack()
function, these functions have a host of options that we simply do not need or are hard to remember in which case we need which arguments. This is where pwntools comes in.p32()
takes in an integer and returns the representation of that integer as a series of bytes, much like struct.pack()
. p32(0xdeadc0de) == b"\xde\xc0\xad\xde"
u32()
does quite the opposite - takes in a series of bytes and returns the integer representation of them, much like struct.unpack()
. u32(b"\xde\xc0\xad\xde") == 0xdeadc0de
p32()
and u32()
but are for 64-bit binaries.context.endian = 'little'
makes all future p32()
and u32()
functions (as well as other similar ones) use little endian, meaning you don't have to specify every time you use the function.