Skip to content

Using current ELF in Ghidra instead of file on disk? #13

Open
@Manouchehri

Description

@Manouchehri

Right now, ghidra2dwarf.py relies on having the original ELF on disk. It ends up breaking one of my automated workflows, since my tooling cleans up samples off disk after they've been imported to Ghidra.

while not os.path.isfile(exe_path):
print "I couldn't find the original file at path %s. Please specify its path:" % exe_path
exe_path = askFile("Original binary path", "Open").path
curr.executablePath = exe_path
print "Changed binary path to %s." % exe_path

add_sections_to_elf(exe_path, out_path, sections)

We should use the ElfExporter class instead to get the original ELF file. https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/ElfExporter.java

Here's some examples of how to do that:

https://github.com/sengi12/GhidraScripting-Basics/blob/fa6181bf0634a12015296fed54068bff0585acc5/examples/exportLocalCopy.py#L22-L27

https://github.com/riverratz/ghidraheadless_binexport/blob/b69966cc6ece8820588355c5f5b893b6d0d1c613/sample_functions_cpy.py#L17-L32

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions