XingLo SkillSearch

恶意程序逆向工程分析

用于对恶意二进制进行深层逆向分析,指导使用Ghidra、IDA等工具完成反汇编、反编译、函数与交叉引用跟踪、控制流分析以及关键加密算法和网络逻辑定位。适合静态和动态分析已经发现可疑功能后继续追踪实现细节,例如C2地址生成、配置解密、命令分发、注入与持久化代码,从而还原样本核心执行链。

在 AI 中使用此 Skill将本页链接复制给 AI,即可让 AI 获取完整 Skill 内容并按此执行
安全提示: 本站 Skill 均经 ChatGPT 最新模型扫描,未发现恶意脚本及危险指令、未检出已知恶意行为特征,但不保证绝对安全,使用即表示接受此风险

Skill 文件

版本 20260301 · c14a30727f854232c9ed64dea80c8568

references/
scripts/
SKILL.md
---
name: reverse-engineering
description: Deep binary analysis using Ghidra and IDA Pro - disassembly, decompilation, control flow analysis, and cryptographic algorithm identification
---

# Reverse Engineering

## Overview

This skill provides guidance and tooling for deep binary analysis of malware samples using reverse engineering tools such as Ghidra and IDA Pro. It covers disassembly, decompilation, control flow analysis, and identification of cryptographic algorithms embedded in binaries.

## When to Use

- After initial triage and static analysis indicate deeper inspection is needed
- When understanding the exact logic of malware behavior is required
- To identify custom encryption, packing, or obfuscation routines
- To map out program control flow and call graphs
- To find hidden functionality not revealed by dynamic analysis

## Prerequisites

- **Ghidra** (free, open-source) or **IDA Pro** (commercial): disassembly and decompilation
- **Python 3.10+** for running automation scripts
- **Ghidra headless analyzer** (`analyzeHeadless`): required by `ghidra_analyze.py`
- Familiarity with **x86/x64 assembly** and common calling conventions
- A triaged malware sample (unpacked if possible) ready for deep analysis

## Step-by-Step Instructions

1. **Load the binary** into Ghidra or IDA Pro for initial auto-analysis
2. **Review the entry point** and identify the main function or DllMain
3. **Examine imports/exports** to understand API usage patterns
4. **Trace control flow** from entry point through key decision branches
5. **Identify cryptographic routines** using known constants and patterns
6. **Decompile critical functions** to obtain pseudo-C representation
7. **Annotate and rename** functions and variables for clarity
8. **Document findings** including algorithms, keys, and C2 logic

## Available Scripts

### ghidra_analyze.py
Runs Ghidra in headless mode to perform automated analysis on a binary, extracting functions, strings, imports, exports, and cross-references.

```bash
python scripts/ghidra_analyze.py --binary sample.exe --ghidra-path /opt/ghidra --output report.json
```

### function_identifier.py
Scans binary files for known cryptographic constants (AES S-box, RC4 KSA patterns, MD5/SHA initialization vectors) to identify embedded crypto routines.

```bash
python scripts/function_identifier.py --binary sample.exe --output crypto_report.json
```

## Key Techniques

### Disassembly Analysis
- Identify function prologues and epilogues
- Recognize compiler-generated patterns vs hand-written assembly
- Trace data flow through registers and stack variables

### Decompilation
- Use Ghidra's decompiler for pseudo-C output
- Cross-reference decompiled output with disassembly for accuracy
- Identify inlined functions and optimized code patterns

### Control Flow Analysis
- Map out conditional branches and loop structures
- Identify anti-analysis checks (debugger detection, VM detection)
- Trace error handling and fallback paths

### Crypto Identification
- Search for known algorithm constants in binary data
- Identify custom XOR, RC4, AES, and RSA implementations
- Extract hardcoded keys and initialization vectors

## References

- `references/ghidra-workflow.md` - Step-by-step Ghidra analysis workflow
- `references/x86-quick-ref.md` - x86/x64 instruction quick reference
- `references/crypto-identification.md` - Cryptographic algorithm identification guide