During a security assessment of software for virtual work environments, we encountered an interesting reverse engineering challenge. The component we needed to analyze was written in Pascal Script and compiled into bytecode embedded in an Inno Setup installer. The disassemblers we used could extract low-level instructions, but they could only partially reconstruct the program’s logic as high-level Pascal code.
We used AI to help reconstruct the parts of the code that were difficult to interpret. The resulting analysis helped our team identify a Local Privilege Escalation (LPE) vulnerability, which was subsequently verified and fixed.
AI can reconstruct Pascal code that’s easy to read, but does it preserve the original program’s behavior? And do the anomalies AI flags point to real security vulnerabilities? We regularly have to answer these questions in AI-assisted pentesting.
Assigning tasks to GLM and DeepSeek
FPT Smart Cloud’s Offensive Security Team uses GLM-5.2 and DeepSeek-V4.1-Flash through the FPT AI Factory API, with both models integrated into tools such as Kilo Code and ZCode. We choose a model for each task based on its complexity, response time, and token cost.
We favor GLM-5.2 for tasks that require multi-step reasoning and the ability to retain context across long inputs. In reverse engineering, we use it to analyze algorithms that have undergone obfuscation, trace complex program logic, and examine multi-stage attack scenarios.
In our experience, DeepSeek-V4.1-Flash offers faster responses and lower token costs when processing batches of assembly snippets, analyzing stack-based bytecode, and supporting iterative code verification. These tasks can require several calls to the model for the same artifact, so response time and token cost both matter when choosing which model to use.
We also integrate AI with Ghidra through the Model Context Protocol (MCP). During static triage, AI can retrieve pseudocode and cross-references (Xrefs) for the functions under analysis, infer what unnamed functions do, and suggest descriptive names. Through Ghidra MCP, AI can also make certain changes directly in the project under expert supervision, such as renaming functions, variables, and parameters or updating structures in the Data Type Manager. This reduces the manual effort involved in analyzing binaries with hundreds of unnamed functions and helps analysts narrow the scope of their investigation before moving on to dynamic analysis.
Assigning tasks across models lets the team make use of each model’s strengths. Overall efficiency also depends on how much work it takes to verify the results. If analysts spend substantial time reviewing AI-generated output, cross-checking it against the evidence, and validating the findings, that verification overhead can erase the time savings AI provides.
Discovering a Local Privilege Escalation Vulnerability in a Software Installer
In the Inno Setup installer described in the beginning, the stack-based RemObjects Pascal Script virtual machine executes the Pascal Script bytecode. To reconstruct the program’s logic from the disassembled instructions, analysts had to track push/pop operations on the stack, function calls, and how data changed across conditional branches.
During the assessment, we found that the installer ran as NT AUTHORITY\SYSTEM and handled an executable location in a writable by standard users. This was the root cause of the Local Privilege Escalation (LPE) vulnerability confirmed during testing. The reverse engineering challenge was to reconstruct the file I/O flow from the stack-based instructions and determine the exact privilege context at each relevant step.
We used AI to reconstruct assembly snippets as high-level Pascal code, making the data flow and file-handling logic easier to follow. To confirm the vulnerability, our analysts compared the reconstructed Pascal code with the original bytecode, reviewed the relevant branch conditions, and verified the program’s behavior. The vulnerability was subsequently fixed.
Automating Verification in CPython Bytecode Decompilation
In another penetration test, we used AI to decompile CPython bytecode and analyze the program’s logic. This gave us a way to automate verification by recompiling the Python code reconstructed by the model. The AI-generated Python code can follow Python’s syntax rules and be easy to read yet still behaves differently from the original program. To catch discrepancies, we built a verification loop that recompiles the reconstructed Python code to bytecode and compares it with the original. When the comparison reveals a mismatch, we feed the results back to the model so it can revise the code. We use the compiler’s output as the basis for verification, without asking the model to judge the accuracy of the code it just generated.
The uncompyle6 project used recompilation to verify decompiler output for older versions of Python. PyLingual, presented at the 2025 IEEE Symposium on Security and Privacy, also introduced a perfect decompilation criterion to set a stricter standard for evaluating decompiler output. Because bytecode is a CPython implementation detail and can change across versions, recompilation needs to use the corresponding CPython version and account for relevant compiler options. Establishing behavioral equivalence requires looking beyond opcode names to operands, constants, referenced objects, and other relevant parts of the code object.
Automated verification reduces manual review and gives the model concrete feedback. The reliability of the results still depends on what the comparison covers and which criteria it uses.

Missing Context Leads to AI Reasoning Errors
One limitation we often encounter when using LLMs in reverse engineering is that a model can produce a convincing analysis of an individual function but draw incorrect conclusions when it lacks enough information about related components.
For example, while analyzing a network packet processing function, the AI noticed that a memory copy operation used the length field from the packet header and flagged a stack buffer overflow. When we broadened the scope of the analysis, we found that the caller had already checked the length against the relevant bounds before invoking the function. The model produced a false positive because it analyzed the callee in isolation, overlooking the program’s data constraints and memory allocation context.
In reverse engineering, similar errors arise when AI analyzes binaries that use Control Flow Flattening or VM-based Obfuscation. The model tends to interpret unusual code structures using familiar control flow patterns, leading to incorrect conclusions about the program’s behavior.
In binary exploitation, race condition bugs also pose challenges when using AI to assess exploitability. Static analysis can help identify suspicious locations, but verification still depends on execution order, timing, and the state of concurrent threads. An analyst can spend hours setting up a test environment only to determine that the AI’s initial hypothesis was unfounded.
Calculating Verification Overhead in Pentest Automation
When we used PentAGI and Cyberstrike to automate reconnaissance and attack surface assessment, we found that the AI agents produced quite a few false positives. For example, an agent might flag a potential SQL injection or remote code execution (RCE) vulnerability after receiving an HTTP 500 response or observing unusual server response times. These anomalies warrant further investigation, but they provide insufficient evidence to confirm a vulnerability.
In web application testing, we use Burp Suite Repeater or test scripts to verify the behavior reported by the agent. For binaries, analysts may need to review the assembly, trace data flow, or verify program behavior with debuggers such as x64dbg, WinDbg, or GDB.
AI agents can complete the initial testing steps very quickly, but some of the pentester’s workload shifts to triaging and verifying findings. If verification takes longer than the time saved through automation, the overall assessment takes longer. To evaluate how effective AI agents are in penetration testing, we need to consider total testing time, the number and proportion of findings that are confirmed, and the effort analysts spend investigating false positives.
We can reduce verification overhead by defining comparison criteria that the system can evaluate automatically. In reverse engineering, we apply this approach when decompiling CPython bytecode.
Defining the Limits of AI in Security Testing
An AI model can analyze source code, formulate hypotheses about vulnerabilities, and suggest test scenarios. Security professionals retain the authority to decide which actions are permitted on the target system. When integrating AI with pentesting tools, they must still define the objectives, design the test scenarios, set the scope of execution, and supervise the agent’s actions.
Based on my experience using GLM and DeepSeek in offensive security, I believe four principles should guide the use of AI in security testing.
- Data Governance — Classify source code, binaries, system logs, and data collected during dynamic analysis before sharing them with the model. The testing team must establish where the data is processed and stored, and who is authorized to access it.
- Execution Boundaries — Distinguish read-only tasks from actions that can change the state or affect the operation of the target system. Risky actions must stay within the authorized testing scope and require human-in-the-loop approval from a security professional.
- Evidence Standards — The evidence must match the type of vulnerability. For memory corruption, analysts need to verify the conditions that trigger the issue and the resulting memory behavior. For access control flaws, they need to establish the privilege context and identify the behavior that violates access controls. In reverse engineering, analysts should check AI-generated findings against the original code or verify them by observing the program’s behavior.
- End-to-End Efficiency — In addition to response time and token costs, account for the time spent analyzing results, verifying findings, investigating false positives, and finalizing the assessment’s conclusions.
For offensive security practitioners, AI’s effectiveness should be measured by the quality of verified findings and the total time it takes to produce them. I believe we should look for opportunities to automate verification wherever feasible from the outset, when designing AI-assisted pentesting workflows. This lets pentesters devote more time to in-depth analysis and benefit from AI while maintaining the reliability of their findings.
Reference
- PyLingual – Toward Perfect Decompilation of Evolving High-Level Languages, IEEE Symposium on Security and Privacy 2025.
- uncompyle6 – Python bytecode decompiler.
- Python Documentation – dis: Disassembler for Python bytecode.
Author:
Dang Dinh Phuong is the Offensive Security Specialist in Offensive Security Team at FPT Smart Cloud. He is experienced in information security and adversary simulation, with expertise in malware analysis, reverse engineering, and vulnerability research. His work focuses on offensive security and red teaming, with an emphasis on improving proactive security assessments and securing large-scale systems.
***
Enjoy FPT Smart Cloud’s technical blogs from these authors? Get to know the products they are building!
- FPT GPU Cloud
- FPT Token Factory
- FPT AI Agents
- FPT.AI
All details are at: https://factory.fpt.ai/
