· 8 min read
Reverse Engineering with AI: From Decompiler Output to Decryptor
A reverse engineering workflow with Odin v1: explain Ghidra output, rebuild a string decryptor in Python, name functions in bulk via the API and verify each step.
Reverse engineering is slow, careful work: reading decompiler output, working out what each function does, naming things and writing small tools to undo what the author hid. A language model is good at the first draft of most of those steps, but mainstream assistants often refuse as soon as the code looks like malware, a packer or an anti-analysis trick. Security teams use Odin v1 for this work because it answers directly. This walkthrough takes a synthetic string decryption routine from raw Ghidra output to a working Python decryptor, then scales the same approach to a whole binary through the API.
What the model sees, and what it does not
Odin accepts text only. It never sees the binary, and it does not need to. You run the disassembler, and you paste what it produces:
- Decompiled C from Ghidra, IDA or Binary Ninja, one function or a whole module at a time.
- Disassembly listings when the decompiler gets something wrong.
stringsoutput, the import table and section names.- Hex dumps of the data a function works on.
odin-v1 has a 1,000,000-token context window, so a whole decompiled module plus its call graph fits in a single request. That matters in reverse engineering, where one function rarely makes sense on its own.
Handle the binary itself the same way you would for any malware triage: inside an isolated VM with no network, snapshotted before you start. Copy text out of the VM, never files. API prompts and completions are not stored, but still strip anything you do not need, such as customer names or internal hostnames found in the sample.
The sample
This is synthetic Ghidra output written for this article. It shows a pattern you will meet constantly: strings stored encrypted in the binary and decrypted just before use.
And the bytes at DAT_00409010, copied from the hex view:
Step 1: explain the function
Give the model the role, where the code came from and what you want back:
You are assisting a reverse engineer. The code below is Ghidra decompiler output from a sample analyzed statically in an isolated lab. Explain what FUN_00401a30 does, identify any known algorithm or constants, suggest names and types for the function and its parameters, and say what the caller is probably doing. Mark anything you cannot confirm from the code as a guess.
A good answer spots that 0x41c64e6d and 0x3039 (1103515245 and 12345) are the classic linear congruential generator constants used by many C library rand() implementations. The function steps that generator once per byte, takes bits 16 to 23 of the state as a keystream byte, XORs it with the input and null-terminates the output. A sensible signature is void decrypt_string(const uint8_t *enc, int len, char *out). In the caller, the 12-byte result goes straight into GetProcAddress, so the encrypted blob is almost certainly an API name being resolved at runtime to keep it out of the import table.
Ask follow-up questions in the same conversation: why the decompiler typed param_3 as byte *, whether the seed could vary between builds, what a YARA rule would key on. That back-and-forth is where the model saves the most time.
Step 2: rebuild the decryptor in Python
Next, ask for a standalone reimplementation:
Write a Python 3 function that reproduces FUN_00401a30 exactly, with the seed as a parameter. Keep the order of operations identical to the decompiled code and mask every intermediate value to 32 bits.
Expect something like this:
The result is VirtualAlloc, which fits the GetProcAddress call and suggests the loader allocates memory for a next stage.
Never trust a reimplementation until it matches ground truth. Two classic mistakes in generated decryptors are updating the state after the XOR instead of before, and forgetting the 32-bit mask, which Python does not apply for you. Both produce plausible garbage. Check the output against something you observed yourself: set a breakpoint after the call in a debugger inside the VM, read the buffer, and compare. Once one string matches, run the decryptor over every encrypted blob you can find, which usually recovers the API names, the configuration and the C2 addresses in one pass.
Step 3: name functions in bulk through the API
Step 1 works for one function. A real binary has hundreds called FUN_.... Export them all as text and let the API produce a first pass at names. This Ghidra script writes the decompiled C of every function to its own file, named by entry point. It avoids f-strings and type hints, so it runs in Ghidra's default Jython and in PyGhidra:
Then send each unnamed function to odin-flash, which is faster and cheaper and good enough for a first-pass label. Keep odin-v1 for the functions that need real reasoning, such as the crypto, the config parser or the network protocol.
Read labels.json before you apply anything. Only high-confidence names go into renames.json; medium and low ones are notes for you, not facts. The OpenAI SDK guide covers client setup if you have not used the API before.
Step 4: apply the names in Ghidra
Bring the reviewed names back with a second script. The keys are the same entry point strings the export used, so the two scripts round-trip without any address parsing:
Re-export after renaming and run another pass. Callers become much easier to label once their callees have real names, so two or three passes usually turn a wall of FUN_ into a readable program. The same flow works in IDA or Binary Ninja with their own scripting APIs.
Where the model goes wrong
The model writes a convincing first draft. Your job is to catch the parts that are wrong:
- Integer widths and signedness. Decompilers often guess types wrongly, and the model inherits the guess. A
charthat should beuint8_tchanges the result of every shift. - Misidentified algorithms. Constants are strong hints, not proof. A routine with AES S-box values might be a modified AES, or only part of one.
- Invented context. Ask what a function "probably" does and you get a plausible story. Keep the confirmed/inferred split and test the inferences in a debugger.
- Calling conventions and structures. If Ghidra has not recovered a struct, the model sees pointer arithmetic and guesses offsets. Define the struct in Ghidra first, then ask again.
The rule is the same as in malware analysis with Odin: the model drafts, you verify, and only verified findings go in the report.
Other reverse engineering work
The same approach of pasting text, asking for structure and then verifying covers most day-to-day reversing:
- Protocol reversing. Paste hex dumps of captured messages next to the parsing function and ask for a field layout and a parser.
- Patch diffing. Paste the before and after versions of a changed function and ask what the fix prevents. See security research with fewer refusals for more on patched CVE analysis.
- Detections. Turn the constants and byte patterns you just identified into rules with our guide to Sigma and YARA rules with AI.
- Practice. Crackmes and CTF reversing challenges are the safest way to build the skill. See CTF practice with an AI coach.
- Tooling. For larger scripts against Ghidra or IDA, see Claude Code for security tooling.
Common questions about AI for reverse engineering
Can Odin read a binary directly?
No. Odin is text only. Run the binary through a disassembler or decompiler and paste the output, hex dumps and strings.
Why do mainstream models refuse reverse engineering questions?
They react to how code looks. Decryption routines, anti-debugging checks and packers look like malware even when you are the one analyzing it. Odin is built to answer legitimate security work directly.
Is reverse engineering legal?
Analyzing malware and software you are authorized to examine is standard security work. For commercial software, check the license and the law where you are. Reverse only what you have the right to analyze, and keep your work within the Acceptable Use Policy.
Which model should I use?
Use odin-v1 for hard functions and whole-module questions, where its reasoning and 1,000,000-token context help. Use odin-flash for bulk labeling, where speed and cost matter more.
Get started
Create an API key in the console and follow the quickstart to make your first request, or paste a function into the web chat to try it right away.
Comparing Odin with the assistant you use today? See uncensored AI for security research for a side-by-side comparison with mainstream assistants.