Reverse engineer a Go binary with Ghidra via MCP

Recently, I encountered a situation where I got a Golang HTTP server binary and needed to disassemble it for further research to find clues for the next steps. Task: Recently, I encountered a situation where I got a Golang HTTP server binary and needed to disassemble it for further research to find clues for the next steps. However, I am quite unfamiliar with reverse engineering. I only know how to throw the binary into Ghidra, and then I’m lost; I can’t even search for strings. But now AI agents have evolved rapidly. As long as the tools are used properly, even a reverse engineering layman like me can easily rely on AI to perform basic reverse engineering. This article will document the steps. To start with, the program I received and the one demonstrated here are relatively small. I don’t know if larger or more complex ones would work. I also don’t believe AI can completely replace the tasks that humans originally needed to perform, but it can definitely make some tasks easier. For someone like me, who originally could extract almost nothing, even getting some clues from AI is good. Even if it’s nonsense, it has some reference value; having something is better than nothing. I can still find ways to verify the nonsense. As for those who already know how to reverse engineer, I’m not sure if AI would help them or how they would use it; that’s beyond the scope of this discussion. Environment Preparation To demonstrate the overall process, I randomly had AI write a Golang server with registration, login, and file upload features. The file structure is: For the content, I’ll just paste a few of the main files. One is the route: Next are the two intentionally embedded vulnerabilities: SQL injection during registration: And path traversal during file upload: After writing it, I used this command to build it, removing everything that shouldn’t be there to simulate a more realistic scenario: Preliminary Work Since our binary is stripped, all related symbols have been removed. Therefore, finding a useful plugin can help us restore Golang-related information more conveniently. I chose this one: https://github.com/mooncat-greenpy/Ghidra_GolangAnalyzerExtension When analyzing, remember to check the relevant options: After the analysis, you can actually see more detailed information in Ghidra: But this still requires manual inspection. For someone like me who doesn’t know how to operate Ghidra, I just throw the binary in and don’t know how to look at it. So, we need to install something that truly connects AI with Ghidra: GhidraMCP. There seem to be about two or three versions that many people use, so I randomly picked one that looked like it had better documentation and was easier to run. After installation and enabling it in Ghidra, configure MCP on the AI side. For example, I’m using Cursor, so I set it up like this: Up to this point, the preliminary work is ready. By the way, I used Cursor for demonstration, but actually, any AI agent will do. Whether you use Codex, Claude Code, Open Code, or whatever, as long as it can connect to MCP, it’s fine. Start Commanding the AI Agent to Work Next, it’s time to reverse engineer using my words. I just told it this: I am currently reverse engineering a Golang binary. Please help me use Ghidra MCP to assist and let me know what kind of program it is and what functions it has. It will start calling MCP by itself and searching for what it wants: Here is the translated content: Finally, here are the libraries used by this binary: And the API routes: And the inferred file structure: Next, I let it help me convert the decompiled C back to Golang based on the inferred structure. It listed a few todos and then started its work: As a result, the routes.go it reverse-engineered looks like this: The structure of the code is slightly different from the original, indicating that there was no cheating (?). By the way, I had it run under different contexts, so it indeed could not see the original Golang source code. In any case, the reverse-engineered code is clear and readable, but there are a few small errors. For example, /my-messages does not exist; it should be /me/messages. /avatar should also be /me/avatar. It seems some parts were skipped lazily. The registration part looks like this: The part that was intentionally left for SQL injection has now been fixed, indicating that what it reverse-engineered is incorrect. However, the path traversal vulnerability during file upload still exists, and it was easily identified: The above results were generated using the Cursor’s own composer 1.5 model because I was running out of quota, which is not as smart.; tools: Cursor. Human role: The original post does not say how a person stayed involved.; limitations: The workflow was tested on a small, stripped binary; scalability to larger or more complex binaries is unknown. AI outputs contained factual errors and hallucinations, requiring human verification. The author suggests combining static analysis results with dynamic testing for validation. Reliance on specific MCP versions and Ghidra plugins may introduce compatibility issues..

Tools

Cursor

Published on Agent Work Atlas:

Overview

Recently, I encountered a situation where I got a Golang HTTP server binary and needed to disassemble it for further research to find clues for the next steps.

Workflow

Recently, I encountered a situation where I got a Golang HTTP server binary and needed to disassemble it for further research to find clues for the next steps. However, I am quite unfamiliar with reverse engineering. I only know how to throw the binary into Ghidra, and then I’m lost; I can’t even search for strings. But now AI agents have evolved rapidly. As long as the tools are used properly, even a reverse engineering layman like me can easily rely on AI to perform basic reverse engineering. This article will document the steps. To start with, the program I received and the one demonstrated here are relatively small. I don’t know if larger or more complex ones would work. I also don’t believe AI can completely replace the tasks that humans originally needed to perform, but it can definitely make some tasks easier. For someone like me, who originally could extract almost nothing, even getting some clues from AI is good. Even if it’s nonsense, it has some reference value; having something is better than nothing. I can still find ways to verify the nonsense. As for those who already know how to reverse engineer, I’m not sure if AI would help them or how they would use it; that’s beyond the scope of this discussion. Environment Preparation To demonstrate the overall process, I randomly had AI write a Golang server with registration, login, and file upload features. The file structure is: For the content, I’ll just paste a few of the main files. One is the route: Next are the two intentionally embedded vulnerabilities: SQL injection during registration: And path traversal during file upload: After writing it, I used this command to build it, removing everything that shouldn’t be there to simulate a more realistic scenario: Preliminary Work Since our binary is stripped, all related symbols have been removed. Therefore, finding a useful plugin can help us restore Golang-related information more conveniently. I chose this one: https://github.com/mooncat-greenpy/Ghidra_GolangAnalyzerExtension When analyzing, remember to check the relevant options: After the analysis, you can actually see more detailed information in Ghidra: But this still requires manual inspection. For someone like me who doesn’t know how to operate Ghidra, I just throw the binary in and don’t know how to look at it. So, we need to install something that truly connects AI with Ghidra: GhidraMCP. There seem to be about two or three versions that many people use, so I randomly picked one that looked like it had better documentation and was easier to run. After installation and enabling it in Ghidra, configure MCP on the AI side. For example, I’m using Cursor, so I set it up like this: Up to this point, the preliminary work is ready. By the way, I used Cursor for demonstration, but actually, any AI agent will do. Whether you use Codex, Claude Code, Open Code, or whatever, as long as it can connect to MCP, it’s fine. Start Commanding the AI Agent to Work Next, it’s time to reverse engineer using my words. I just told it this: I am currently reverse engineering a Golang binary. Please help me use Ghidra MCP to assist and let me know what kind of program it is and what functions it has. It will start calling MCP by itself and searching for what it wants: Here is the translated content: Finally, here are the libraries used by this binary: And the API routes: And the inferred file structure: Next, I let it help me convert the decompiled C back to Golang based on the inferred structure. It listed a few todos and then started its work: As a result, the routes.go it reverse-engineered looks like this: The structure of the code is slightly different from the original, indicating that there was no cheating (?). By the way, I had it run under different contexts, so it indeed could not see the original Golang source code. In any case, the reverse-engineered code is clear and readable, but there are a few small errors. For example, /my-messages does not exist; it should be /me/messages. /avatar should also be /me/avatar. It seems some parts were skipped lazily. The registration part looks like this: The part that was intentionally left for SQL injection has now been fixed, indicating that what it reverse-engineered is incorrect. However, the path traversal vulnerability during file upload still exists, and it was easily identified: The above results were generated using the Cursor’s own composer 1.5 model because I was running out of quota, which is not as smart.

Reported result

The AI successfully identified libraries, API routes, and file structure, and detected a path traversal vulnerability. However, it incorrectly 'fixed' an intentional SQL injection vulnerability and hallucinated some route paths (e.g., /my-messages instead of /me/messages). The author noted that results varied by model, with Composer 1.5 being less accurate than Opus 4.6.

Human role

The original post does not say how a person stayed involved.

Limitations

The workflow was tested on a small, stripped binary; scalability to larger or more complex binaries is unknown. AI outputs contained factual errors and hallucinations, requiring human verification. The author suggests combining static analysis results with dynamic testing for validation. Reliance on specific MCP versions and Ghidra plugins may introduce compatibility issues.

Try it

I have a stripped Golang binary at [replaceable input: path/to/binary]. I need to reverse engineer it to find API routes and potential vulnerabilities. Please use GhidraMCP to analyze the binary. First, identify the libraries used and list all API endpoints. Then, decompile the main handler functions into readable Golang code. Specifically, look for SQL injection patterns in database queries and path traversal issues in file upload handlers. Output the findings in a structured JSON format with keys: 'libraries', 'routes', 'vulnerabilities', and 'decompiled_code'. Do not assume the code is secure; report any suspicious patterns even if they look like standard practice. If you cannot access the binary via MCP, ask me to provide the decompiled C code instead.

Original source

Source reports are not independently verified. Publication date is the catalog publication date, not the original article date.

More cases · Security & operations