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

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

Open
Manouchehri opened this issue Feb 14, 2022 · 1 comment
Open

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

Manouchehri opened this issue Feb 14, 2022 · 1 comment

Comments

@Manouchehri
Copy link

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

@Manouchehri
Copy link
Author

I'll do this myself, just wanted to make a ticket so I don't forget.

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

1 participant