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

Feature Request: More library friendly #252

Open
jpsnyder opened this issue Feb 17, 2023 · 2 comments
Open

Feature Request: More library friendly #252

jpsnyder opened this issue Feb 17, 2023 · 2 comments
Assignees

Comments

@jpsnyder
Copy link

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.)

  • Logs are printed directly to stdout https://github.com/joxeankoret/diaphora/blob/master/diaphora.py#L109 which spams my own tool's output. This leads me to having to use stdout redirection to put them in a proper logger. It would be nice for diaphora to use Python's standard logging library.
  • Getting results are tightly coupled with sqlite databases, which requires me to let diaphora write out the diff results to the database, only to then immediately open up the database and read the results for my own usage. It would be nice if pulling diff results can be exposed as functions before writing out results.
    • For example, I had to reimplement the similarity calculation in my own code since the result is only printed out and not returned.
  • While I understand that this is a IDA only tool, it would be nice if diaphora was setup as a package to make it pip installable and discoverable on PyPi. I've found it easy enough to quickly install a IDA plugin with pip install ida_plugin --target=%IDA_INSTALL_DIR%\python\3 if it is pip installable. Plus this would help me not have to vendor diaphora in my own code.

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
Copy link
Owner

joxeankoret commented Feb 18, 2023

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
Copy link
Author

jpsnyder commented Mar 6, 2023

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.)

@joxeankoret joxeankoret added this to the Diaphora 3.0 milestone Apr 10, 2023
@joxeankoret joxeankoret modified the milestones: Diaphora 3.0, Diaphora 3.1 Sep 30, 2023
@joxeankoret joxeankoret removed this from the Diaphora 3.2 milestone Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants