Gallopsled / pwntools-tutorial

Tutorials for getting started with Pwntools

Home Page:http://pwntools.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unpack() needs word size

iviirai opened this issue · comments

Hi, when I tried e.unpack(e.symbols['bash_license']) , an error raised. But e.unpack(e.symbols['bash_license'], 'all') works fine. It's different from examples given in ELF.md.

>>> from pwn import *   
>>> e = ELF('/bin/bash')
[*] '/bin/bash'
    Arch:     amd64-64-little
    RELRO:    Partial RELRO
    Stack:    Canary found
    NX:       NX enabled
    PIE:      No PIE (0x400000)
    FORTIFY:  Enabled
>>> license = e.unpack(e.symbols['bash_license']) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/elf/elf.py", line 1686, in unpack
    return packing.unpack(self.read(address, context.bytes), *a, **kw)
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/context/__init__.py", line 1349, in setter
    return function(*a, **kw)
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/util/packing.py", line 211, in unpack
    raise ValueError("unpack(): data must have length %d, since word_size was %d" % (byte_size, word_size))
ValueError: unpack(): data must have length 8, since word_size was 64
>>> e.unpack(e.symbols['bash_license'], 'all')
4957888