google / binexport

Export disassemblies into Protocol Buffers
Apache License 2.0
1.03k stars 197 forks source link

Support for exporting multiple databases to 1 .BinExport (or for merging .BinExport files) #56

Closed VelocityRa closed 4 years ago

VelocityRa commented 4 years ago

Is this supported? I basically have many small .idb (or Ghidra) files, with a few functions each, and I want to generate a single .BinExport file from that. (sidenote: the originals were actually .o files, but I've used IDA's batch mode to make .idbs for all of them) I haven't found any method/tool to do this.

I see that there is the option --export (batch export .idb files from input directory to BinExport format) which does this apparently? Assuming it means a single BinExport file, which isn't clear. But it does not work.

bindiff.exe --export --primary=test (where test is a dir that has a bunch of .idbs) -> no output or errors whatsoever.

Any help appreciated, thanks :)

cblichmann commented 4 years ago

That is not currently supported by any of the tools. A .BinExport files is supposed to represent a full binary. That said, if you have multiple disassembly databases that share the same address space (like in your case with a bunch of separate object files), this is a reasonable thing to want.

As a workaround, you could simply link the .o files together and use the resulting executable as some kind of container. Then you can create a single .idb and export that one.

IIRC, IDA also supports loading additional binary files into an IDB. So if you have a database open, File|Load input file (or similar, not near my IDA installation right now) should allow you to load another object file.

Failing that, it's is relatively straighforward to write a small tool that takes a set of .BinExport files and produces a "merged" one by iterating over all instructions/basic blocks/functions and adding them.

As for the batch diff/export case, take a look at issue 150583990 in the BinDiff bug tracker. That bug also has updated binaries that should allow you to export successfully.

VelocityRa commented 4 years ago

Thank you @cblichmann! Good ideas.

I'm currently trying rizzo with Ghidra. If i can't make that work I'll try the methods you suggested.

glitchnsec commented 3 years ago

@cblichmann thanks so much for the referenced issue issue 150583990. However, I have encountered an issue in that was supposedly addressed in that issue. I added a follow-up comment on the issue. Hoping you can get around to checking it out! Let me know if I need to open a new issue here, on there