|
2 | 2 |
|
3 | 3 | # BinaryNinja-OpenAI |
4 | 4 |
|
5 | | -Integrates OpenAI's GPT3 with Binary Ninja via a plugin. Creates a query asking |
6 | | -"What does this function do?" followed by the instructions in the High Level IL |
7 | | -function or the decompiled pseudo-C. Returns the response to the user in Binary |
8 | | -Ninja's console. |
| 5 | +Integrates OpenAI's GPT3 with Binary Ninja via a plugin and currently supports |
| 6 | +two actions: |
| 7 | + |
| 8 | +- Queries OpenAI to determine what a given function does (in Pseudo-C and HLIL). |
| 9 | + - The results are logged to Binary Ninja's log to assist with RE. |
| 10 | +- Allows users to rename variables in HLIL using OpenAI. |
| 11 | + - Variable are renamed immediately and the decompiler is reloaded. |
9 | 12 |
|
10 | 13 | ## Installation |
11 | 14 |
|
@@ -60,20 +63,42 @@ You can find your API key at https://beta.openai.com. |
60 | 63 |
|
61 | 64 | ## Usage |
62 | 65 |
|
| 66 | +### What Does this Function Do? |
| 67 | + |
63 | 68 | After installation, you can right-click on any function in Binary Ninja and |
64 | | -select `Plugins > OpenAI > What Does this Function Do (HLIL)?`. Alternatively, |
65 | | -select a function in Binary Ninja (by clicking on any instruction in the |
66 | | -function) and use the menu bar options |
67 | | -`Plugins > OpenAI > What Does this Function Do (HLIL)?`. If your cursor has |
68 | | -anything else selected other than an instruction inside a function, `OpenAI` |
69 | | -will not appear as a selection inside the `Plugins` menu. This can happen if |
70 | | -you've selected data or instructions that Binary Ninja determined did not belong |
71 | | -inside of the function. |
| 69 | +select `Plugins > OpenAI > What Does this Function Do (HLIL/Pseudo-C)?`. |
| 70 | +Alternatively, select a function in Binary Ninja (by clicking on any instruction |
| 71 | +in the function) and use the menu bar options `Plugins > OpenAI > ...`. If your |
| 72 | +cursor has anything else selected other than an instruction inside a function, |
| 73 | +`OpenAI` will not appear as a selection inside the `Plugins` menu. This can |
| 74 | +happen if you've selected data or instructions that Binary Ninja determined did |
| 75 | +not belong inside of the function. Additionally, the HLIL options are context |
| 76 | +sensitive; if you're looking at the decompiled results in LLIL, you will not see |
| 77 | +the HLIL options; this is easily fixed by changing the user view to HLIL |
| 78 | +(Pseudo-C should always be visible). |
72 | 79 |
|
73 | 80 | The output will appear in Binary Ninja's Log like so: |
74 | 81 |
|
75 | 82 |  |
76 | 83 |
|
| 84 | +### Renaming Variables |
| 85 | + |
| 86 | +I feel like half of reverse engineering is figuring out variable names (which |
| 87 | +in-turn assist with program understanding). This plugin is an experimental look |
| 88 | +to see if OpenAI can assist with that. Right click on an instruction where a |
| 89 | +variable is initialized and select `OpenAI > Rename Variable (HLIL)`. Watch the |
| 90 | +magic happen. Here's a quick before-and-after. |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +Renaming variables only works on HLIL instructions that are initializations (ie. |
| 97 | +`HighLevelILVarInit`). You might also want this to support assignments |
| 98 | +(`HighLevelILAssign`), but I did not get great results with this. Most of the |
| 99 | +responses were just `result`. If your experience is different, please submit a |
| 100 | +pull request. |
| 101 | + |
77 | 102 | ## OpenAI Model |
78 | 103 |
|
79 | 104 | By default, the plugin uses the `text-davinci-003` model, you can tweak this |
|
0 commit comments