我得到的错误是:
Traceback (most recent call last):
File "test.py", line 391, in <module>
main()
File "test.py", line 385, in main
find_rop_gadgets('libc.so')
File "test.py", line 78, in find_rop_gadgets
e = elf.ELF(path)
File "/usr/local/lib/python2.7/dist-packages/pwnlib/elf/__init__.py", line 54, in __init__
super(ELF,self).__init__(self.mmap)
File "/usr/local/lib/python2.7/dist-packages/elftools/elf/elffile.py", line 50, in __init__
self._identify_file()
File "/usr/local/lib/python2.7/dist-packages/elftools/elf/elffile.py", line 201, in _identify_file
elf_assert(magic == b'\x7fELF', 'Magic number does not match')
File "/usr/local/lib/python2.7/dist-packages/elftools/common/utils.py", line 69, in elf_assert
_assert_with_exception(cond, msg, ELFError)
File "/usr/local/lib/python2.7/dist-packages/elftools/common/utils.py", line 101, in _assert_with_exception
raise exception_type(msg)
elftools.common.exceptions.ELFError: Magic number does not match
python中的幻数是多少?以上代码中的错误意味着什么?在
ELF格式(可执行和可链接格式)是二进制代码文件(如动态库)的常用文件格式。https://en.wikipedia.org/wiki/Executable_and_Linkable_Format
此消息表示正在检查的文件不是有效的ELF文件格式。(Take a look at line 201 in the source code for elffile.py)。代码从文件中读取4个字节,并检查它们是否与值
0x7fELF
匹配:这个“神奇数字”是ELF格式头的开始。如果这些字节不匹配,则表明文件已损坏和/或不是有效的ELF格式文件。可以使用
^{pr2}$readelf
命令检查ELF二进制文件的头:从您发布的堆栈跟踪中,函数
find_rop_gadgets('libc.so')
正在查看libc.so
,它被传递给elffile.py
进行验证(因为它不是ELF文件,所以验证失败)。我认为检查libc.so
并确保该文件存在并且是有效的(未损坏的)ELF文件是合理的。在如果没有更具体的信息(例如代码示例),这个答案就尽可能具体。在
请参阅ELF文件格式中的this page for more details。在
相关问题 更多 >
编程相关推荐