Package: dailalib
DAILAThe Decompiler Artificial Intelligence Language Assistant (DAILA) is a unified interface for AI systems to be used in decompilers.
Using DAILA, you can utilize various AI systems, like local and remote LLMs, all in the same scripting and GUI interfaces.
DAILA was featured in the keynote talk atHITCON CMT 2023.DAILA provides a lifted interface, relying on the BinSync libraryLibBSto abstract away the decompiler.All decompilers supported in LibBS are supported in DAILA, which currently includes IDA, Ghidra, Binja, and angr-management.Currently, there are two AI systems supported in DAILA:OpenAIandVarBERT,
the latter of which is a local model for renaming variables in decompilation published in S&P 2024.
If you are looking for a demo of DAILA, please see theDemosection.InstallationInstall our library backend through pip and our decompiler plugin through our installer:pip3installdailalib&&daila--installThis will also download the VarBERT models for you through theVarBERT API.
If you happen to be installing DAILA on a machine that won't have internet access, like a secure network, you can use our Docker image in theDocker Containersection.Ghidra Extra StepsYou need to do a few extra steps to get Ghidra working.
Next, enable the DAILA plugin:Start Ghidra and open a binaryGoto theWindows > Script ManagermenuSearch fordailaand enable the scriptYou must havepython3in your path for the Ghidra version to work. We quite literally call it from inside Python 2.
You may also need to enable the$USER_HOME/ghidra_scriptsas a valid scripts path in Ghidra.Manual Install (if above fails)If the above fails, you will need to manually install.
To manually install, firstpip3 install dailalibon the repo, then copy thedaila_plugin.pyfile to your decompiler's plugin directory.UsageDAILA is designed to be used in two ways:As a decompiler plugin with a GUIAs a scripting library in your decompilerDecompiler GUIWith the exception of Ghidra (see below), when you start your decompiler you will have a new context menu
which you can access when you right-click anywhere in a function:If you are using Ghidra, go toTools->DAILA->Start DAILA Backendto start the backend server.
After you've done this, you can use the context menu as shown above.ScriptingYou can use DAILA in your own scripts by importing thedailalibpackage.
Here is an example using the OpenAI API:fromdailalibimportOpenAIAPIfromlibbs.apiimportDecompilerInterfacedeci=DecompilerInterface.discover()ai_api=OpenAIAPI(decompiler_interface=deci)forfunctionindeci.functions:summary=ai_api.summarize_function(function)Docker ContainerIf you are attempting to install DAILA for a one-shot install that will not use the internet after install, like on a secure network, you can use our Docker container.
You should either build the container yourself, save the image to a tarball, and then load it on the target machine, or you can use our pre-built image.
You can build the container yourself by runningdocker build -t daila .in the root of this repo.
You can also download our pre-built image by runningdocker pull binsync/daila:latest(the image is for x86_64 Linux).
The container contains DAILA and a copy of Ghidra.Now you need to foward X11 to the container so that you can see the GUI.
To do this, you need to run the container with the following flags:dockerrun-it--rm-eDISPLAY=$DISPLAY-v/tmp/.X11-unix:/tmp/.X11-unixbinsync/daila:latestIn the container, you can launch ghidra from/tools/ghidra_10.4_PUBLIC/ghidraRun.
Now follow theGhidra Extra Stepsto enable the DAILA plugin and you're good to go!Supported AI BackendsOpenAI (ChatGPT)DAILA supports the OpenAI API. To use the OpenAI API, you must have an OpenAI API key.
If your decompiler does not have access to theOPENAI_API_KEYenvironment variable, then you must use the decompiler option from
DAILA to set the API key.Currently, DAILA supports the following prompts:Summarize a functionRename variablesRename functionIdentify the source of a functionVarBERTVarBERT is a local BERT model from the S&P 2024 paper""Len or index or count, anything but v1": Predicting Variable Names in Decompilation Output with Transfer Learning".
VarBERT is for renaming variables (both stack, register, and arguments) in decompilation.
To understand how to use VarBERT as a library, please see theVarBERT APIdocumentation.
Using it in DAILA is a simple as using the GUI context-menu when clicking on a function.DemoYou can find a demo of VarBERT running inside DAILA below:Supported DecompilersIDABinjaGhidraangr management