joxeankoret / diaphora

Diaphora, the most advanced Free and Open Source program diffing tool.
http://diaphora.re
GNU Affero General Public License v3.0
3.62k stars 372 forks source link

Feature Request: More library friendly #252

Open jpsnyder opened 1 year ago

jpsnyder commented 1 year ago

When trying to use diaphora as a library for my own tool, I discovered a few things that could be improved: (Note: I haven't pulled some of your latest changes yet, so some of this might be fixed already.)

Obviously, I'm not really using diaphora as it was initially designed, and I may not be the target audience, but it would be nice if diaphora was more Python API friendly.

joxeankoret commented 1 year ago

Everything you are mentioning makes sense to me. The 2nd point you mention is problematic, but I believe I can do something to make it easier too.

I'm doing some heavy changes for Diaphora 3.0 (see #193), I will add these tasks.

jpsnyder commented 1 year ago

Sounds good. Glad you can incorporate some of these suggestions. I think with some strategic tweaks, diaphora can be a powerful library for users.

If you are curious, I'm using diaphora for batch diffing files. So being able to programmatically call diaphora is key. I use the following ida script to export the database and then diff the databases created locally using CBinDiff and the reimplemented similarity calcuation.

"""
IDA script used to process a file and generate its SQLite database.
"""

import os

def main():
    import idc
    from autodiff.vendor.diaphora import diaphora_ida

    os.environ["DIAPHORA_AUTO"] = "1"
    os.environ["DIAPHORA_USE_DECOMPILER"] = "1"
    os.environ["DIAPHORA_EXPORT_FILE"] = idc.ARGV[1]

    diaphora_ida.main()

if __name__ == "__main__":
    main()

(It would also be nice to have an export() function that took parameters to do this programatically, instead of my hacky method here.)