0
$ apt-get update
$ apt-get install python2.7 python-pip python-dev git libssl-dev libffi-dev build-essential
$ pip install --upgrade pip
$ pip install --upgrade pwntools

After I ran the above command to install pwntools when I go to python and import pwntools it shows the following error.

> christos@ubuntu:~$ python Python 2.7.12 (default, Dec  4 2017,
> 14:50:18) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright",
> "credits" or "license" for more information.
> >>> import pwn Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File
> "/home/christos/.local/lib/python2.7/site-packages/pwn/__init__.py",
> line 4, in <module>
>     from pwn.toplevel import *   File "/home/christos/.local/lib/python2.7/site-packages/pwn/toplevel.py",
> line 20, in <module>
>     import pwnlib   File "/home/christos/.local/lib/python2.7/site-packages/pwnlib/__init__.py",
> line 43, in <module>
>     importlib.import_module('.%s' % module, 'pwnlib')   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
>     __import__(name)   File "/home/christos/.local/lib/python2.7/site-packages/pwnlib/dynelf.py",
> line 57, in <module>
>     from pwnlib import elf   File "/home/christos/.local/lib/python2.7/site-packages/pwnlib/elf/__init__.py",
> line 9, in <module>
>     from pwnlib.elf.corefile import Core   File "/home/christos/.local/lib/python2.7/site-packages/pwnlib/elf/corefile.py",
> line 85, in <module>
>     from pwnlib.elf.elf import ELF   File "/home/christos/.local/lib/python2.7/site-packages/pwnlib/elf/elf.py",
> line 55, in <module>
>     from elftools.elf.enums import ENUM_P_TYPE ImportError: cannot import name ENUM_P_TYPE
4

2 回答 2

1

As pointed out by @wujiechao, perhaps the best option while waiting for the pwntools fix to be released, is to revert to a previous version of the pyelftools module:

python2.7 -m pip install --upgrade pyelftools==0.24
于 2018-09-14T23:49:13.457 回答
0

this is due to ENUM_P_TYPE not in /usr/lib/pythonXX/site-packages/elftools/elf/enums.py, but ENUM_P_TYPE_BASE in it, so there is a solution that change the ENUM_P_TYPE to ENUM_P_TYPE_BASE in /usr/lib/pythonXX/site-packages/pwnlib/elf/elf.py. (Just 2 places: line 54 and line 1749)

The solution has been found thanks to this post (Credits)

于 2018-09-03T14:09:49.860 回答