Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import from elftools is failing #1189

Closed
matedealer opened this issue Sep 1, 2018 · 3 comments
Closed

Import from elftools is failing #1189

matedealer opened this issue Sep 1, 2018 · 3 comments

Comments

@matedealer
Copy link

When installing the newest version of pwntools in a fresh venv, "from pwn import *" failing in a python console:

>>> from pwn import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/matedealer/Dokumente/Uni/TUD/Masterarbeit/test_blue/venv/lib/python2.7/site-packages/pwn/__init__.py", line 4, in <module>
    from pwn.toplevel import *
  File "/home/matedealer/Dokumente/Uni/TUD/Masterarbeit/test_blue/venv/lib/python2.7/site-packages/pwn/toplevel.py", line 20, in <module>
    import pwnlib
  File "/home/matedealer/Dokumente/Uni/TUD/Masterarbeit/test_blue/venv/lib/python2.7/site-packages/pwnlib/__init__.py", line 43, in <module>
    importlib.import_module('.%s' % module, 'pwnlib')
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/matedealer/Dokumente/Uni/TUD/Masterarbeit/test_blue/venv/lib/python2.7/site-packages/pwnlib/dynelf.py", line 56, in <module>
    from pwnlib import elf
  File "/home/matedealer/Dokumente/Uni/TUD/Masterarbeit/test_blue/venv/lib/python2.7/site-packages/pwnlib/elf/__init__.py", line 9, in <module>
    from pwnlib.elf.corefile import Core
  File "/home/matedealer/Dokumente/Uni/TUD/Masterarbeit/test_blue/venv/lib/python2.7/site-packages/pwnlib/elf/corefile.py", line 84, in <module>
    from pwnlib.elf.elf import ELF
  File "/home/matedealer/Dokumente/Uni/TUD/Masterarbeit/test_blue/venv/lib/python2.7/site-packages/pwnlib/elf/elf.py", line 54, in <module>
    from elftools.elf.enums import ENUM_P_TYPE
ImportError: cannot import name ENUM_P_TYPE

I guess the new version of elftools may be the problem ( https://pypi.org/project/pyelftools/0.25/ )

@wujiechao
Copy link

wujiechao commented Sep 2, 2018

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)

tips: This solution can solve some friends' problem, but in some cases, will bring other problem. Another solution for solve the whole problem is to reduce your pyelftools version to 0.24.

@estewart08
Copy link

estewart08 commented Sep 6, 2018

I am still having the same issue. I have changed ENUM_P_TYPE to ENUM_P_TYPE_BASE on line 54 and line 1749 in elf.py. I assume I have to recompile the elf.py after these changes? However, I am getting some permission errors when trying to recompile. Any thoughts?

FIX: I had to change permission on my elf.pyc file so that it would recompile. Now it is working properly.

@zachriggle
Copy link
Member

Fixed with 7467402e, will cut a new release today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants