JadavMadhavkumar/StaticMalware

GitHub: JadavMadhavkumar/StaticMalware

一个基于 Python 和 Next.js 的生产级静态恶意软件分析平台,通过 YARA 规则、PE 解析与 IOC 提取等手段在不执行文件的前提下完成全面安全检测。

Stars: 0 | Forks: 0

# StaticMalware 🛡️

Python Version Next.js Status License

一个生产就绪的**静态恶意软件分析平台**,可在不执行的情况下安全检查可疑文件。具备 Python 后端、React/Next.js 前端、Supabase 持久化以及 YARA 签名检测功能。 ![仪表盘](https://via.placeholder.com/800x400?text=StaticMalware+Dashboard) ## 🌟 功能 ### 后端 (Python) - **多重哈希生成**:MD5, SHA1, SHA256 - **熵值分析**:用于加壳/混淆检测的香农熵 - **文件类型识别**:通过 Magic bytes 识别 EXE, DLL, PDF, DOC, ZIP 等 - **YARA 签名检测**:自定义规则加载 - **IOC 提取**:URL、域名、IP、电子邮件、文件路径 - **字符串提取**:ASCII 和 UTF-16LE - **PE 静态分析**:导入、导出、节、时间戳 ### 前端 (Next.js) - 包含分析和趋势的仪表盘 - 拖放文件上传 - 实时扫描进度 - 详尽的分析报告 - 基于 Supabase 的持久化 ### 数据层 (Supabase) - 文件存储 (Supabase Storage) - 分析结果 (PostgreSQL) - 用于安全文件访问的签名 URL ## 🏗️ 系统架构 ``` ┌─────────────────────────────────────────────────────────────────┐ │ StaticMalware │ ├─────────────────────┬─────────────────────┬─────────────────────┤ │ Frontend │ Backend │ Data │ │ (Next.js) │ (Python) │ (Supabase) │ ├─────────────────────┼─────────────────────┼─────────────────────┤ │ - Dashboard │ - Scanner Engine │ - Storage Bucket │ │ - Upload │ - YARA Engine │ - uploaded_files │ │ - Results │ - PE Analysis │ - analysis_reports │ │ - Reports │ - IOC Extraction │ - RLS Policies │ │ - Settings │ - REST API │ │ └─────────────────────┴─────────────────────┴─────────────────────┘ ``` ## 🚀 快速开始 ### 前置条件 - Python 3.11+(后端) - Node.js 18+(前端) - Supabase 账号 ### 1. 后端设置 ``` # Clone 并导航 git clone https://github.com/JadavMadhavkumar/StaticMalware.git cd StaticMalware # 创建 virtual environment python -m venv venv source venv/bin/activate # Linux/Mac # venv\Scripts\activate # Windows # 安装依赖 pip install -r requirements.txt # 在本地运行 python -m staticmalware.cli serve ``` ### 2. 前端设置 ``` # 导航到 frontend cd frontend # 安装依赖 npm install # 添加环境变量 # NEXT_PUBLIC_SUPABASE_URL=your-url # NEXT_PUBLIC_SUPABASE_ANON_KEY=your-key # 运行 development server npm run dev ``` ### 3. 部署 **后端**:[Render](https://render.com) - 连接 GitHub 仓库 - 设置 `PYTHON_VERSION = 3.12` - 构建命令:`pip install -r requirements.txt` - 启动命令:`python -m staticmalware.cli serve` **前端**:[Vercel](https://vercel.com) - 从 GitHub 导入 - 添加 Supabase 环境变量 ## 📁 项目结构 ``` StaticMalware/ ├── staticmalware/ # Python backend │ ├── cli.py # Command-line interface │ ├── scanner.py # Main scanner coordinator │ ├── server.py # HTTP API server │ ├── hashing.py # Hash computation │ ├── entropy.py # Entropy analysis │ ├── strings.py # String extraction │ ├── ioc.py # IOC extraction │ ├── fileinfo.py # File type identification │ ├── yara_engine.py # YARA rule engine │ ├── pe_analysis.py # PE file analysis │ ├── database.py # Supabase integration │ └── utils.py # Utilities ├── rules/ # YARA rules (.yar files) ├── frontend/ # Next.js frontend │ ├── src/ │ │ ├── app/ # App router pages │ │ │ ├── upload/ # File upload page │ │ │ ├── results/ # Analysis results │ │ │ └── report/ # Detailed report │ │ ├── components/ # React components │ │ ├── lib/ # API & Supabase clients │ │ └── store/ # Zustand state │ └── public/ ├── tests/ # Python tests └── reports/ # Output directory ``` ## 🔧 配置 ### 环境变量 **后端 (Render)** ``` PORT=8000 PYTHON_VERSION=3.12 ``` **前端 (Vercel)** ``` NEXT_PUBLIC_SUPABASE_URL=https://xxx.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ... SUPABASE_SERVICE_ROLE_KEY=eyJ... # Server-side only ``` ### YARA 规则 将 `.yar` 文件添加到 `/rules/` 目录: ``` rule suspicious_mz_header { meta: author = "StaticMalware" description = "Detects MZ header" strings: $mz = { 4D 5A } condition: $mz at 0 } ``` ## 📡 API 接口 | 方法 | 接口 | 描述 | |--------|----------|-------------| | GET | `/` | 服务状态 | | GET | `/health` | 健康检查 | | POST | `/analyze` | 上传并分析文件 | | GET | `/stats` | 仪表盘统计 | | GET | `/analyses` | 最近的记录 | **请求:** ``` curl -X POST https://staticmalware.onrender.com/analyze \ -F "file=@malware.exe" ``` **响应:** ``` { "file_name": "malware.exe", "size": 102400, "hashes": { "md5": "...", "sha256": "..." }, "entropy": 7.82, "is_packed": true, "yara_matches": [...], "iocs": {...} } ``` ## 🗄️ 数据库结构 ### uploaded_files | 列名 | 类型 | 描述 | |--------|------|-------------| | id | UUID | 主键 | | original_filename | TEXT | 原始文件名 | | storage_path | TEXT | Supabase Storage 路径 | | file_size | BIGINT | 文件大小(字节) | | mime_type | TEXT | MIME 类型 | | sha256 | TEXT | 文件哈希 | | created_at | TIMESTAMP | 上传时间 | ### analysis_reports | 列名 | 类型 | 描述 | |--------|------|-------------| | id | UUID | 主键 | | file_id | UUID | 外键,关联 uploaded_files | | analysis_status | TEXT | pending/analyzing/completed/failed | | risk_level | TEXT | safe/low/medium/high/critical | | entropy_score | REAL | 计算得出的熵值 | | is_packed | BOOLEAN | 加壳检测 | | yara_match_count | INTEGER | YARA 匹配数 | | detected_rules | JSONB | 规则名称数组 | | created_at | TIMESTAMP | 分析时间 | ## 🧪 测试 ``` # Backend 测试 pytest tests/ -v # Frontend build 测试 cd frontend && npm run build ``` ## ⚠️ 免责声明 ## 📄 许可证 MIT 许可证 - 详情请参阅 [LICENSE](LICENSE)。 ## 🙏 鸣谢 - [yara-python](https://github.com/VirusTotal/yara-python) - [pefile](https://github.com/erocarrera/pefile) - [Supabase](https://supabase.com) - [Next.js](https://nextjs.org)
**StaticMalware** - 为安全社区提供安全的静态分析 [![GitHub stars](https://img.shields.io/github/stars/JadavMadhavkumar/StaticMalware)](https://github.com/JadavMadhavkumar/StaticMalware/stargazers) [![GitHub forks](https://img.shields.io/github/forks/JadavMadhavkumar/StaticMalware)](https://github.com/JadavMadhavkumar/StaticMalware/network)
标签:DeepSeek, DNS信息、DNS暴力破解, DNS 反向解析, IOC提取, MD5, PE文件分析, PostgreSQL, Python安全工具, React, SHA256, Supabase, Syscalls, Web安全分析平台, YARA规则, 哈希计算, 失陷标示提取, 威胁情报, 字符串提取, 库, 应急响应, 开发者工具, 恶意代码分析, 数字取证, 文件上传扫描, 文件类型识别, 沙箱分析, 测试用例, 熵值分析, 网络信息收集, 网络安全, 自动化脚本, 逆向工具, 逆向工程基础, 配置文件, 隐私保护, 静态分析框架, 静态恶意软件分析