ahmxdniazi/malware-static-analysis

GitHub: ahmxdniazi/malware-static-analysis

一份基于静态分析的课程级恶意软件研究仓库,提供从文件识别到 YARA 检测的全流程方法论与报告。

Stars: 0 | Forks: 0

![Malware Analysis Banner](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/9a356cf6f7095610.svg) # 🛡️ 静态恶意软件分析 — 综合报告 [![FAST-NUCES](https://img.shields.io/badge/Institution-FAST--NUCES-blue?style=flat-square&logo=university)](https://nu.edu.pk) [![Course](https://img.shields.io/badge/Course-Malware%20Analysis%20%26%20Detection-red?style=flat-square)](.) [![Samples](https://img.shields.io/badge/Samples%20Analyzed-7-green?style=flat-square)](.) [![License](https://img.shields.io/badge/License-Academic-yellow?style=flat-square)](.) [![Tools](https://img.shields.io/badge/Tools-CFF%20Explorer%20%7C%20DIE%20%7C%20PEStudio%20%7C%20YARA-purple?style=flat-square)](.) [![Year](https://img.shields.io/badge/Year-2026-orange?style=flat-square)](.)
## 📋 目录 - [概述](#-overview) - [分析环境](#-analysis-environment) - [样本摘要](#-samples-summary) - [方法论](#-methodology) - [关键发现](#-key-findings) - [样本分解](#-sample-breakdown) - [样本 1 — PE32 可执行文件(打包 89%)](#sample-1--pe32-executable-packed-89) - [样本 2 — PE32 可执行文件(打包 99%)](#sample-2--pe32-executable-packed-99) - [样本 3 — AgentTesla 信息窃取器](#sample-3--agenttesla-infostealer) - [样本 4 — VMProtect 保护的 EXE](#sample-4--vmprotect-protected-exe) - [样本 5 — 恶意 DLL(45% 熵)](#sample-5--malicious-dll-45-entropy) - [样本 6 — 恶意 DLL(79% 熵)](#sample-6--malicious-dll-79-entropy) - [样本 7 — Java 归档(JAR)恶意软件](#sample-7--java-archive-jar-malware) - [YARA 规则](#-yara-rules) - [使用的工具](#-tools-used) - [IOC 摘要](#-ioc-summary) - [仓库结构](#-repository-structure) - [使用方法](#-how-to-use) - [作者](#-author) ## 🔍 概述 本仓库包含一项综合的 **静态恶意软件分析** 作业,作为 **FAST-NUCES** 的 *恶意软件分析与检测* 课程的一部分。七个恶意软件样本来源于 [MalwareBazaar](https://bazaar.abuse.ch/),全部通过静态分析手段进行研究 — **未执行任何样本**。 采用的静态分析技术包括: - 通过魔数与十六进制签名进行**文件识别** - **PE 头解析**(架构、节、导入表) - **熵测量**以检测打包/加密 - **密码学哈希**(MD5、SHA1、SHA256)用于指纹识别 - 使用 **FLOSS** 提取混淆字符串 - **YARA 规则开发**用于自动化检测 ## 🖥️ 分析环境 | 组件 | 详情 | |---|---| | **操作系统** | Windows 10 64 位(隔离虚拟机) | | **Hypervisor** | Oracle VirtualBox 7.x | | **VM 模板** | FLARE-VM(FireEye/Mandiant) | | **网络** | 仅主机/NAT(物理隔离) | | **归档密码** | `infected`(标准恶意软件处理流程) | ## 📦 样本摘要 | # | 截断的 SHA256 | 类型 | 熵 | 打包 | 恶意家族 | |---|---|---|---|---|---| | 1 | `00af217...cd776` | `.exe` | 7.14 | 89% | 未知(混淆) | | 2 | `720e1a3...2159` | `.exe` | 7.99 | 99% | NsPack (C++) | | 3 | `9919b64...916` | `.exe` | 5.00 | 62% | **AgentTesla / Jalapeno** | | 4 | `113c133...980ce` | `.exe` | 7.55 | 94% | VMProtect 保护 | | 5 | `b3a91d2...ad51` | `.dll` | 3.62 | 45% | .NET DLL(可读) | | 6 | `8677376...383` | `.dll` | 6.37 | 79% | C/C++ DLL | | 7 | `26277ff...adf1` | `.jar` | 7.94 | 99% | 跨平台 JAR | ## 🔬 方法论 对每个样本执行的静态分析流程: ``` ┌─────────────────────────────────────────────────────────────┐ │ STATIC ANALYSIS PIPELINE │ ├─────────────────────────────────────────────────────────────┤ │ 1. File Identification │ │ └─ Magic bytes (hex editor) → TrIDNet → Python magic │ │ │ │ 2. PE Structure Analysis │ │ └─ CFF Explorer → File Header → Optional Header │ │ → Section Headers → Import/Export Directory │ │ │ │ 3. Entropy & Packing Detection │ │ └─ DIE (Detect-It-Easy) → Entropy per section │ │ → Packer identification │ │ │ │ 4. Cryptographic Fingerprinting │ │ └─ Python hashlib → MD5 / SHA1 / SHA256 │ │ → HashMyFiles cross-verification │ │ │ │ 5. String Extraction │ │ └─ PEStudio → DIE Strings → FLOSS (obfuscated) │ │ → Notepad++ (raw ASCII view) │ │ │ │ 6. VirusTotal / Threat Intel Correlation │ │ └─ Hash lookup → Vendor detections → Family labels │ │ │ │ 7. YARA Rule Development │ │ └─ Pattern extraction → Rule writing → Testing │ └─────────────────────────────────────────────────────────────┘ ``` ## 🎯 关键发现 ### 🔴 高严重性观察 - **7 个样本中有 6 个**显示高熵(>5.0),表明经过刻意打包或加密以规避 AV 特征码 - **样本 2** 达到接近最大熵 **7.997**(99% 打包)— 静态字符串提取几乎不可能 - **样本 4** 受 **VMProtect** 保护 — 一种被高级威胁行为者使用的商业保护器 - **样本 3** 确认为 **AgentTesla**(VirusTotal 71/71 检出)— 臭名昭著的凭证窃取信息窃取器 ### 🟡 DLL 特定发现 - 两个 DLL 样本(5 与 6)均导入 **KERNEL32.dll** 与 **mscoree.dll** — 表明 .NET CLR 托管与进程注入能力 - 样本 5 熵值较低(~45%)— IOC 可直接提取而无需解包 - 样本 6 导出函数包含 **TLS 回调** 条目 — 一种高级反调试技术 ### 🟢 跨平台威胁(样本 7) - 样本 7 是 **Java 归档(JAR)** — 独特的跨平台(Windows、Linux、macOS) - 仅通过 **魔数**(`PK` + `0xCAFEBABE`)识别 — 原始扩展名未知 - 包含引用 `com/github/kevinsawicki` 的字符串 — 可能滥用开源库 ### 常见 API 导入(恶意能力) | API / DLL | 能力 | |---|---| | `KERNEL32.dll` | 进程创建、内存管理、文件 I/O | | `ADVAPI32.dll` | 注册表操控、权限提升 | | `USER32.dll` | GUI 交互、键盘记录、屏幕捕获 | | `WS2_32.dll` | 网络 / 套接字通信(C2) | | `WINMM.dll` | 音频录制(潜在间谍) | | `mscoree.dll` | .NET CLR 托管 | | `CreateRemoteThread` | 进程注入 | | `VirtualProtect` | 内存权限绕过(Shellcode 阶段) | | `RegSetValue` | 注册表持久化 | ## 📂 样本分解 ### 样本 1 — PE32 可执行文件(打包 89%)
点击展开完整分析 | 属性 | 值 | |---|---| | **文件名** | `00af21794a2dd1fb27e5f8200583ddf35dfa192d0ae0fd9095637a21953cd776.exe` | | **MD5** | `2f1ae97570469357351646187675a3f8` | | **SHA1** | `5789b85012a285d83ff31c6230e0dacb21ebebf3` | | **SHA256** | `00af21794a2dd1fb27e5f8200583ddf35dfa192d0ae0fd9095637a21953cd776` | | **架构 | x86(Intel 386 / PE32) | | **熵** | 7.14594(89% 打包) | | **节区** | 5(`.text`、`.rdata`、`.data`、`.rsrc`、`.reloc`) | | **编译器** | 未知(混淆) | **重要导入项:** KERNEL32.dll(172 个函数)、USER32.dll(227 个函数)、GDI32.dll(99 个)、ADVAPI32.dll(11 个) **打包:** `.text` 与 `.rsrc` 节区熵值高(分别为 6.51 与 7.42),FLOSS 揭示大量无意义 ASCII 模式,确认刻意混淆。 **YARA 规则:** `yara-rules/sample1_detection.yar`
### 样本 2 — PE32 可执行文件(打包 99%)
点击展开完整分析 | 属性 | 值 | |---|---| | **文件名** | `720e1a32fcc9308e33781ea1f1e0dd5e980f11492e93ed14624a68c383752159.exe` | | **MD5** | `b4ee2f9dcae350b317bfcca07263f73e` | | **SHA1** | `17db27e10118704a1ef6fed13915d182e2513399` | | **SHA256** | `720e1a32fcc9308e33781ea1f1e0dd5e980f11492e93ed14624a68c383752159` | | **架构** | x86(Intel 386 / PE32) | | **熵** | 7.99967(99% 打包) | | **节区** | 3(`.nsp0`、`.nsp1`、`.nsp2`)— NsPack 签名 | | **打包器** | **NsPack 3.x** | | **编译器** | Microsoft Visual C++ 12.00.9782 | **注意:** 版本信息嵌入 `com/www.52guji.cc` — 潜在 C2 或分发域名。清单名称 `TianYi` 暗示为中国来源威胁。 **YARA 规则:** `yara-rules/sample2_detection.yar`
### 样本 3 — AgentTesla 信息窃取器
点击展开完整分析 | 属性 | 值 | |---|---| | **文件名** | `9919b646562123265d27bb8b64db1048cc8833a76c377bcd15e8a221c2990916.exe` | | **MD5** | `c038ccdc98121bfc2629f11cba1c8357` | | **SHA1** | `4e45bfa800992bd2ec927f0f297ea61f81d92283` | | **SHA256** | `9919b646562123265d27bb8b64db1048cc8833a76c377bcd15e8a221c2990916` | | **架构** | x86(Intel 386 / .NET PE32) | | **熵** | 5.00023(62% 打包 — 部分可读) | | **节区** | 3(`.text`、`.rsrc`、`.reloc`) | | **VirusTotal** | **56/71 检出** | | **家族** | `trojan.msil/agenttesla`、`Jalapeno.320` | **VirusTotal 标签:** `Infostealer/Win.AgentTesla.R631699`(AhnLab)、`Backdoor:MSIL/Agent.D#`(AliCloud)、`TrojanPSW:MSIL/AgentTesla.8d1a2508`(Alibaba) **导入项:** 仅 `mscoree.dll`(1 个函数)— .NET CLR 启动引导器 **YARA 规则:** `yara-rules/sample3_detection.yar`
### 样本 4 — VMProtect 保护的 EXE
点击展开完整分析 | 属性 | 值 | |---|---| | **文件名** | `113c133afaf9312ab4aea413456e9107de2b9fb1694dc31f8747bafdba2980ce.exe` | | **MD5** | `56fc994d21e5fe0d39576d7b550c17f7` | | **SHA1** | `8013b10c460e23c0235dcbfcd4d91514da110154` | | **SHA256** | `113c133afaf9312ab4aea413456e9107de2b9fb1694dc31f8747bafdba2980ce` | | **架构** | x86(Intel 386 / PE32) | | **熵** | 7.55194(94% 打包) | | **大小** | 10.14 MiB | | **保护器** | **VMProtect(新版)[DS]** | | **编译器** | Microsoft Visual C/C++ | **注意:** VMProtect 将代码虚拟化为自定义字节码,在 VM 引擎上执行以阻止反汇编。字符串包含 `VirtualProtect`、`GetProcAddress`、`LoadLibraryA` — 典型的反射加载器指示。 **YARA 规则:** `yara-rules/sample4_detection.yar`
### 样本 5 — 恶意 DLL(45% 熵)
点击展开完整分析 | 属性 | 值 | |---|---| | **文件名** | `b3a91d26480efc16a0f6fd30e2077b72da65bbb1c07f35abba526983c781ad51.dll` | | **MD5** | `2e7053d4ef9412c62b5d5a4f4e2580f8` | | **SHA1** | `84f5b211aa5f559c0ae8956c1a66a2df563feb77` | | **SHA256** | `b3a91d26480efc16a0f6fd30e2077b72da65bbb1c07f35abba526983c781ad51` | | **架构** | x86(Intel 386 / PE32 DLL) | | **熵** | 3.62726(5% — 未完全打包) | | **节区** | 3(`.text`、`.rsrc`、`.reloc`) | | **导入项** | `mscoree.dll` — .NET CLR 托管 DLL | **关键发现:** 低熵意味着字符串 / IOC 可直接提取而无需解包。DLL 特征 `0x2102` 确认设置了 ASLR 与 DLL 标志。 **YARA 规则:** `yara-rules/sample5_detection.yar`
### 样本 6 — 恶意 DLL(79% 熵)
点击展开完整分析 | 属性 | 值 | |---|---| | **文件名** | `8677376173ccdd877787cffffb6290c2c623d1c2ad82b15e31a9a2bab9c03b383.dll` | | **MD5** | `4a5777f54aa6081cac8247438c30fa5b` | | **SHA1** | `6b2a579cd3b5721e75a8d8996ca7c9f5dd3c6f7a` | | **SHA256** | `8677376173ccdd877787cffffb6290c2c623d1c2ad82b15e31a9a2bab9c03b383` | | **架构** | x86(Intel 386 / PE32 DLL) | | **熵** | 6.36974(79% 打包) | | **节区** | 8+(`.text`、`.data`、`.rdata`、`.bss`、`.edata`、`.idata`、`.tls`、`.reloc`) | | **导入项** | KERNEL32.dll(55 个函数)、msvcrt.dll(17 个函数) | **注意:** 包含 **TLS 目录**(反调试)、Go 构建 ID 字符串(`nmVbnXBciqh6HHaaaCNK/...`)以及导出目录 — 表明这是一个注入或旁路加载的 DLL。 **YARA 规则:** `yara-rules/sample6_detection.yar`
### 样本 7 — Java 归档(JAR)恶意软件
点击展开完整分析 | 属性 | 值 | |---|---| | **文件名** | `26277ffc2f95f3a64e86e2f5424bbe430fe257be905dc39aab5534533e4cadf1.jar` | | **MD5** | `97d0d52e3d2b8cf27aa22ebba7baf170` | | **SHA1** | `ce702fa87567a4100502ffa126aed0402d81e721` | | **SHA256** | `26277ffc2f95f3a64e86e2f5424bbe430fe257be905dc39aab5534533e4cadf1` | | **平台** | **JVM(跨平台 — Windows/Linux/macOS)** | | **魔数** | `PK`(50 4B)+ `0xCAFEBABE`(Java 类标记) | | **熵** | 7.944(99% 通过 ZIP 压缩打包) | | **大小** | 28.22 MiB | **关键发现:** 仅通过魔数识别 — 原始扩展名未知。包含引用 `com/github/kevinsawicki` 的字符串(HTTP 客户端库),可能用于 C2 通信。跨平台特性使其特别危险。 **YARA 规则:** `yara-rules/sample7_detection.yar`
## 📜 YARA 规则 所有 YARA 检测规则位于 [`yara-rules/`](yara-rules/) 目录。每条规则均基于静态分析提取的模式手工编写。 ``` yara-rules/ ├── sample1_detection.yar # String-based detection (obfuscated ASCII patterns) ├── sample2_detection.yar # NsPack + obfuscated string matching ├── sample3_detection.yar # .NET AgentTesla byte-pattern detection ├── sample4_detection.yar # VMProtect + embedded IOC strings ├── sample5_detection.yar # .NET DLL characteristics ├── sample6_detection.yar # DLL flag + import sequence + binary patterns ├── sample7_detection.yar # ZIP/Java magic bytes + malicious class patterns └── all_samples.yar # Combined ruleset for batch scanning ``` ### 运行 YARA 规则 ``` # 扫描单个文件 yara yara-rules/sample3_detection.yar /path/to/suspicious/file # 扫描包含所有规则的目录 yara yara-rules/all_samples.yar /path/to/scan/ # 扫描并输出详细信息 yara -s yara-rules/all_samples.yar /path/to/file ``` ## 🔧 使用的工具 | 工具 | 用途 | 类别 | |---|---|---| | **CFF Explorer VIII** | PE 结构解析、导入/导出分析 | PE 分析 | | **DIE (Detect-It-Easy)** | 熵、打包检测、字符串提取 | 打包检测 | | **PEStudio** | 恶意字符串高亮、PE 概览 | 静态分析 | | **HxD / Notepad++ (hex)** | 原始二进制/魔数检查 | 十六进制编辑 | | **TrIDNet** | 基于二进制签名的文件类型识别 | 文件识别 | | **FLOSS** | 从打包二进制文件中提取混淆字符串 | 字符串分析 | | **Python hashlib** | 密码学哈希计算(MD5/SHA1/SHA256) | 指纹识别 | | **HashMyFiles** | GUI 哈希验证工具 | 指纹识别 | | **VirusTotal** | 基于哈希的威胁情报关联 | 威胁情报 | | **YARA** | 模式匹配规则编写与测试 | 检测 | | **Hybrid Analysis / SNDBOX** | 补充沙箱交叉参考 | 威胁情报 | | **Sigcheck (Sysinternals)** | 文件签名与熵验证 | 验证 | ## 🚨 IOC 摘要 ### 文件哈希(SHA256) ``` 00af21794a2dd1fb27e5f8200583ddf35dfa192d0ae0fd9095637a21953cd776 720e1a32fcc9308e33781ea1f1e0dd5e980f11492e93ed14624a68c383752159 9919b646562123265d27bb8b64db1048cc8833a76c377bcd15e8a221c2990916 113c133afaf9312ab4aea413456e9107de2b9fb1694dc31f8747bafdba2980ce b3a91d26480efc16a0f6fd30e2077b72da65bbb1c07f35abba526983c781ad51 8677376173ccdd877787cffffb6290c2c623d1c2ad82b15e31a9a2bab9c03b383 26277ffc2f95f3a64e86e2f5424bbe430fe257be905dc39aab5534533e4cadf1 ``` ### 可疑字符串 / 域名 ``` com/www.52guji.cc # Sample 2 — suspected C2/distribution domain com/github/kevinsawicki # Sample 7 — HTTP library abuse pattern ``` ### 可疑 API 调用 ``` VirtualProtect, VirtualAlloc, CreateRemoteThread WriteProcessMemory, LoadLibraryA, GetProcAddress RegSetValue, CreateProcess, WaitForSingleObject ``` ## 📁 仓库结构 ``` malware-static-analysis/ │ ├── 📄 README.md ← You are here ├── 📄 LICENSE ├── 📄 .gitignore │ ├── 📂 reports/ │ └── Static_Analysis_Report_Muhammad_Ahmad.pdf ← Full analysis report │ ├── 📂 yara-rules/ │ ├── sample1_detection.yar │ ├── sample2_detection.yar │ ├── sample3_detection.yar │ ├── sample4_detection.yar │ ├── sample5_detection.yar │ ├── sample6_detection.yar │ ├── sample7_detection.yar │ └── all_samples.yar │ ├── 📂 scripts/ │ ├── hash_calculator.py ← MD5/SHA1/SHA256 batch hashing │ ├── entropy_checker.py ← Entropy measurement script │ ├── string_extractor.py ← ASCII/Unicode string extractor │ └── ioc_extractor.py ← IOC pattern extractor │ ├── 📂 docs/ │ ├── methodology.md ← Detailed methodology breakdown │ ├── tools_setup.md ← Tool installation guide (FLARE-VM) │ └── references.md ← References and further reading │ ├── 📂 screenshots/ │ ├── sample1/ ← CFF Explorer, DIE, PEStudio views │ ├── sample2/ │ ├── sample3/ │ ├── sample4/ │ ├── sample5/ │ ├── sample6/ │ └── sample7/ │ └── 📂 assets/ └── banner.svg ← Repository banner ``` ## 🚀 使用方法 ### 1. 克隆仓库 ``` git clone https://github.com/YOUR_USERNAME/malware-static-analysis.git cd malware-static-analysis ``` ### 2. 运行 Python 脚本 ``` # 安装依赖项 pip install python-magic pefile # 计算文件的哈希值 python scripts/hash_calculator.py /path/to/suspicious/file # 检查熵值 python scripts/entropy_checker.py /path/to/suspicious/file # 提取字符串 python scripts/string_extractor.py /path/to/suspicious/file --min-length 4 ``` ### 3. 使用 YARA 规则 ``` # 安装 YARA pip install yara-python # 运行检测 python -c " import yara rules = yara.compile('yara-rules/all_samples.yar') matches = rules.match('/path/to/file') print(matches) " ``` ### 4. 阅读完整报告 打开 [`reports/Static_Analysis_Report_Muhammad_Ahmad.pdf`](reports/Static_Analysis_Report_Muhammad_Ahmad.pdf) 获取包含截图的完整分析。 ## ⚠️ 免责声明 ## 👤 作者
**Muhammad Ahmad** 学号:`25I-7705` 📍 FAST-NUCES, 伊斯兰堡,巴基斯坦 📚 *恶意软件分析与检测* — Jawad Hassan 教授 [![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-0077B5?style=flat-square&logo=linkedin)](https://linkedin.com) [![GitHub](https://img.shields.io/badge/GitHub-Follow-181717?style=flat-square&logo=github)](https://github.com)
## 📚 参考资料 1. [MalwareBazaar](https://bazaar.abuse.ch/) — 恶意样本仓库 2. [FLARE-VM](https://github.com/mandiant/flare-vm) — 恶意软件分析虚拟机环境 3. [YARA 文档](https://yara.readthedocs.io/) — YARA 规则编写指南 4. [PE 格式参考](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format) — Microsoft PE 规范 5. [DIE (Detect-It-Easy)](https://github.com/horsicq/Detect-It-Easy) — 打包检测工具 6. [FLOSS](https://github.com/mandiant/flare-floss) — 混淆字符串求解器 7. [VirusTotal](https://www.virustotal.com/) — 多引擎威胁情报关联 8. Sikorski, M. & Honig, A. — *Practical Malware Analysis* (No Starch Press)
*使用 🔬 为学术网络安全研究制作* ![Visitors](https://visitor-badge.laobi.icuadge?page_id=malware-static-analysis)
标签:2026, AMSI绕过, CFF Explorer, DAST, DIE, FAST-NUCES, IOC, PEStudio, YARA, 云安全监控, 云资产可视化, 云资产清单, 元数据分析, 威胁分类, 威胁检测, 学术研究, 恶意软件分析, 数字取证, 文件结构分析, 样本分析, 自动化特征提取, 自动化脚本, 课程作业, 逆向工具, 逆向工程, 静态分析, 静态恶意软件分析