Created
April 7, 2021 20:23
-
-
Save trufae/748b2f36a3075a9707befb8a4a6ca93f to your computer and use it in GitHub Desktop.
script to load symbols from .gnu_debugdata section into r2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # | |
| # Script to parse the .gnu_debugdata section of ELF binaries | |
| # Usage: | |
| # $ r2 -i debugdata.py bd64 | |
| # The script can be also executed from the r2 shell | |
| # $ . debugdata.py | |
| # | |
| import r2pipe | |
| r2 = r2pipe.open(); | |
| def parse_debugdata(pa, sz): | |
| r2.cmd("wtf .dd.dump.xz %s @e:io.va=0@ %s"%(sz, pa)) | |
| r2.syscmd("xz -d .dd.dump.xz") | |
| r2.cmd(".!rabin2 -rs .dd.dump") | |
| pa = 0 | |
| sz = 0 | |
| sections = r2.cmdj("iSj") | |
| for s in sections: | |
| if s["name"] == ".gnu_debugdata": | |
| pa = s["paddr"] | |
| sz = s["size"] | |
| if pa > 0 and sz > 0: | |
| parse_debugdata(pa, sz) | |
| else: | |
| print("No debugdata section found in this binary") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment