Skip to content

Commit 6d21991

Browse files
committed
Add resources and updated README.
README now describes how to rename variables.
1 parent f0c395f commit 6d21991

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

README.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
# BinaryNinja-OpenAI
44

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

1013
## Installation
1114

@@ -60,20 +63,42 @@ You can find your API key at https://beta.openai.com.
6063

6164
## Usage
6265

66+
### What Does this Function Do?
67+
6368
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).
7279

7380
The output will appear in Binary Ninja's Log like so:
7481

7582
![The output of running the plugin.](https://github.com/WhatTheFuzz/binaryninja-openai/blob/main/resources/output.png?raw=true)
7683

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+
![Before renaming](resources/rename-before.png)
93+
94+
![After renaming](resources/rename-after.png)
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+
77102
## OpenAI Model
78103

79104
By default, the plugin uses the `text-davinci-003` model, you can tweak this

resources/rename-after.png

7.79 KB
Loading

resources/rename-before.png

7.66 KB
Loading

0 commit comments

Comments
 (0)