Analizing MIPS binaries: is there a Python library for parsing binary data?

前端 未结 6 1520
小鲜肉
小鲜肉 2020-12-28 21:00

I\'m working on a utility which needs to resolve hex addresses to a symbolic function name and source code line number within a binary. The utility will run on Linux on x86,

相关标签:
6条回答
  • 2020-12-28 21:24

    You should give Construct a try. It is very useful to parse binary data into python objects.

    There is even an example for the ELF32 file format.

    0 讨论(0)
  • 2020-12-28 21:33

    You might be interested in the DWARF library from pydevtools:

    >>> from bintools.dwarf import DWARF
    >>> dwarf = DWARF('test/test')
    >>> dwarf.get_loc_by_addr(0x8048475)
    ('/home/emilmont/Workspace/dbg/test/main.c', 36, 0)
    
    0 讨论(0)
  • 2020-12-28 21:35

    I've been developing a DWARF parser using Construct. Currently fairly rough, and parsing is slow. But I thought I should at least let you know. It may suit your needs, with a bit of work.

    I've got the code in Mercurial, hosted at bitbucket:

    • http://bitbucket.org/cmcqueen1975/pythondwarf/
    • http://bitbucket.org/cmcqueen1975/construct/ (necessary modifications to Construct library)

    Construct is a very interesting library. DWARF is a complex format (as I'm discovering) and pushes Construct to its limits I think.

    0 讨论(0)
  • 2020-12-28 21:46

    I don't know of any, but if all else fails you could use ctypes to directly use libdwarf, libelf or libbfd.

    0 讨论(0)
  • 2020-12-28 21:47

    hachior is another library for parsing binary data

    0 讨论(0)
  • 2020-12-28 21:48

    Please check pyelftools - a new pure Python library meant to do this.

    0 讨论(0)
提交回复
热议问题