https://github.com/JusticeRage/Gepetto
All credit goes to original repo owner.
Gepetto is a Python script which uses Local LLM to provide meaning to functions decompiled by IDA Pro. At the moment, it can ask any local model to explain what a function does, and to automatically rename its variables. Here is a simple example of what results it can provide in mere seconds:
![IDA](https://private-user-images.githubusercontent.com/27184655/329802035-565daaaf-7c39-401d-b411-17b2dd90aad3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3NTA3ODksIm5iZiI6MTcxOTc1MDQ4OSwicGF0aCI6Ii8yNzE4NDY1NS8zMjk4MDIwMzUtNTY1ZGFhYWYtN2MzOS00MDFkLWI0MTEtMTdiMmRkOTBhYWQzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjMwVDEyMjgwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTllMGEyOTY3ZGQ5ZGZkMmI1NzY5Y2M4NWZiYTY2Y2JkNjBiOGRmNDE2MjViNmU4ZmIxN2E3OWU5OWY0ZjY5YWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7jqvD6PUdPGn3pse-3NHS-on_1XIdmw3X3hmNLb5_BE)
![LMStudio](https://private-user-images.githubusercontent.com/27184655/329802765-cf99ba0f-7d2a-4ea4-8bb2-845e4a240844.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3NTA3ODksIm5iZiI6MTcxOTc1MDQ4OSwicGF0aCI6Ii8yNzE4NDY1NS8zMjk4MDI3NjUtY2Y5OWJhMGYtN2QyYS00ZWE0LThiYjItODQ1ZTRhMjQwODQ0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjMwVDEyMjgwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJjZDc5MGQxYjk5OWY3ODk0YjJkMTUxY2ExMGJjODMwMTA0Y2I2ODhjNWI1M2VjZGQ3OGE1MmJlNjlkMDc4ZjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RpaG7FUAzszGkBuYgVz5565xqzPLPzUWfS9An18_0ZA)
Simply drop this script (as well as the gepetto/
folder) into your IDA plugins folder ($IDAUSR/plugins
).
By default, on Windows, this should be %AppData%\Hex-Rays\IDA Pro\plugins
(you may need to create the folder).
You will need to add the required packages to IDA's Python installation for the script to work.
Find which interpreter IDA is using by checking the following registry key:
Computer\HKEY_CURRENT_USER\Software\Hex-Rays\IDA
(default on Windows: %LOCALAPPDATA%\Programs\Python\Python39
).
Once the plugin is installed properly, you should be able to invoke it from the context menu of IDA's pseudocode window,
as shown in the screenshot below:
You can also use the following hotkeys:
- Ask the model to explain the function:
Ctrl
+Alt
+H
- Request better names for the function's variables:
Ctrl
+Alt
+R
Initial testing shows that asking for better names works better if you ask for an explanation of the function first – I assume because the model then uses its own comment to make more accurate suggestions. There is an element of randomness to the AI's replies. If for some reason the initial response you get doesn't suit you, you can always run the command again.