【问题标题】:pwntools python not importingpwntools python没有导入
【发布时间】:2023-03-03 15:12:02
【问题描述】:
$ 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

在我运行上述命令安装 pwntools 后,当我转到 python 并导入 pwntools 时,它显示以下错误。

> 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

【问题讨论】:

    标签: python import pwntools


    【解决方案1】:

    作为@wujiechaopointed out,在等待pwntools 修复程序发布时,也许最好的选择是恢复到pyelftools 模块的先前版本:

    python2.7 -m pip install --upgrade pyelftools==0.24
    

    【讨论】:

      【解决方案2】:

      这是由于ENUM_P_TYPE 不在/usr/lib/pythonXX/site-packages/elftools/elf/enums.py 中,而是ENUM_P_TYPE_BASE 在其中,因此有一个解决方案将/usr/lib/pythonXX/site-packages/pwnlib/elf/elf.py 中的ENUM_P_TYPE 更改为ENUM_P_TYPE_BASE。 (只有 2 个地方:第 54 行和第 1749 行)

      感谢this post (Credits) 找到了解决方案

      【讨论】:

        猜你喜欢
        • 2012-02-03
        • 2016-10-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-01
        相关资源
        最近更新 更多