0xvuln0/C2-Tracker

GitHub: 0xvuln0/C2-Tracker

一款基于网络的 C2 服务器追踪与恶意软件检测工具,集成实时网络监控、文件扫描、YARA 规则与威胁情报查询。

Stars: 1 | Forks: 0

# C2 Tracker [![Python 3.9+](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://www.python.org/downloads/) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/39/39faa54be350a1dab8afd3b2fb8c1c83e4d9cff84abfef2374d19a18053687c4.svg)](https://github.com/0xvuln0/C2-Tracker/actions) [![PyPI](https://img.shields.io/pypi/v/c2tracker.svg)](https://pypi.org/project/c2tracker/) [![Docker](https://img.shields.io/badge/Docker-Ready-blue?logo=docker)](Dockerfile) [![YARA](https://img.shields.io/badge/YARA-Supported-orange)](yara_scanner.py) 基于网络的命令与控制 (C2) 服务器追踪器。监控实时网络连接,通过 Shodan 和 Censys 丰富 IP 信息,扫描文件以查找恶意软件,并检测已知的 C2 框架。 ## 功能 | 功能 | 描述 | |---------|-------------| | **实时网络监控** | 通过 `psutil` 追踪所有入站/出站连接 | | **Shodan 信息丰富** | Banners、开放端口、漏洞、OS、组织信息 | | **Censys 信息丰富** | 服务、协议、自治系统数据 | | **恶意软件 IP 数据库** | 涵盖 114 个家族和 22 个威胁行为者的 1200+ 个 IP | | **文件扫描** | 检测恶意软件签名、shellcode、reverse shells | | **YARA 规则** | 内置规则 + 支持自定义规则 | | **MITRE ATT&CK** | 将检测结果映射到 30+ 种 ATT&CK 技术 | | **二进制分析** | 检测原始 shellcode、anti-debug、anti-VM、加壳 | | **自我学习** | 扫描器随着每次扫描不断改进 | | **C2 搜索** | 通过被动 Shodan 查询发现 C2 基础设施 | | **导出** | 支持 JSON、CSV 和 IOC 导出格式 | | **Docker** | 开箱即用的 Docker 支持 | | **威胁评分** | 采用加权评分,并带有 MALICIOUS/SUSPICIOUS/LOW RISK/CLEAN 标签 | ## 快速开始 ### 1. 安装 **通过 PyPI:** ``` pip install c2tracker ``` **从源码安装(用于开发):** ``` git clone https://github.com/0xvuln0/C2-Tracker.git cd C2-Tracker pip install -e ".[all]" ``` ### 2. 设置 API 密钥(可选) ``` cp .env.example .env ``` 编辑 `.env` 并添加你的 API 密钥: ``` SHODAN_API_KEY=your_key_here CENSYS_API_ID=your_id_here CENSYS_API_SECRET=your_secret_here ``` 获取免费的 API 密钥: - Shodan: https://account.shodan.io - Censys: https://search.censys.io/register ### Docker ``` # Build docker build -t c2tracker . # Scan files docker run -v ./samples:/samples c2tracker scan-file /samples/* # Scan network (needs host access) docker run --network host --pid host --privileged c2tracker scan --no-api ``` ## 使用方法 ### 扫描网络连接 ``` # Basic scan (requires sudo for live connection data) sudo python3 cli.py scan # Show all connections with verbose output sudo python3 cli.py scan -s -v # Continuous monitoring (check every 10 seconds) sudo python3 cli.py scan -m -i 10 # Filter out private/internal IPs sudo python3 cli.py scan -f # Local-only scan (no API lookups) sudo python3 cli.py scan --no-api ``` ### 扫描文件以查找恶意软件 ``` # Scan a single file python3 cli.py scan-file suspicious.exe # Scan multiple files with verbose output python3 cli.py scan-file -v sample1.exe sample2.dll # Export results to JSON python3 cli.py scan-file -o results.json suspicious.exe ``` 文件扫描器可检测: - **恶意软件家族** — Cobalt Strike、Metasploit、Sliver、AsyncRAT、njRAT、Remcos 等 40 多种 - **Reverse shells** — bash、python、perl、php、ruby、netcat、socat - **Shellcode** — NOP sleds、XOR 模式、syscalls、编码的 IP - **Web shells** — PHP、ASP、ASPX、JSP - **反分析** — anti-debug、anti-VM、anti-sandbox、加壳 - **可疑行为** — 编码的 PowerShell、凭证转储、持久化 - **MITRE ATT&CK** — 将每次检测映射到具体的技术 ID - **YARA 规则** — 根据内置和自定义规则进行扫描 ### YARA 扫描 ``` # Scan with built-in YARA rules python3 cli.py scan-file --yara suspicious.exe # Scan with custom rules directory python3 cli.py scan-file --yara-rules /path/to/rules suspicious.exe ``` ### 导出结果 ``` # Export to JSON python3 cli.py scan-file -o results.json sample.exe # Export to CSV python3 cli.py scan-file --csv results.csv sample.exe # Export IOCs (hashes, IPs, domains) python3 cli.py scan-file --iocs iocs.txt sample.exe ``` ### 通过 Shodan 搜索 C2 基础设施 ``` # Hunt all tracked C2 families (requires Shodan API key) python3 cli.py hunt # Hunt specific products only python3 cli.py hunt "Cobalt Strike" "Sliver" "AsyncRAT" # Verbose output python3 cli.py hunt -v # Custom output directory python3 cli.py hunt -o /tmp/c2data ``` ### 学习数据库 ``` # View learning stats python3 cli.py learning # Reset learning database python3 cli.py learning --reset ``` ### 根据威胁数据库检查 IP ``` # Check one or more IPs python3 cli.py check 45.77.65.114 python3 cli.py check 45.77.65.114 185.56.83.83 ``` ### 搜索威胁数据库 ``` # Search by malware family python3 cli.py family "cobalt strike" python3 cli.py family trickbot # Search by threat actor python3 cli.py actor "Evil Corp" python3 cli.py actor "Conti Group" # Show database summary python3 cli.py db --families --actors ``` ## MITRE ATT&CK 映射 每次检测都会映射到 MITRE ATT&CK 技术: | 技术 | 描述 | |-----------|-------------| | T1059 | 命令和脚本解释器 | | T1055 | 进程注入 | | T1053 | 计划任务/作业 | | T1003 | 操作系统凭证转储 | | T1486 | 用于影响的数据加密 (Ransomware) | | T1027 | 混淆的文件或信息 | | T1572 | 协议隧道 | | T1497 | 虚拟化/沙箱规避 | | T1562 | 削弱防御 | | T1071 | 应用层协议 (C2) | | ... | 其他 20+ 种技术 | 请参阅 [`mitre_attack.py`](mitre_attack.py) 查看完整映射。 ## YARA 规则 `rules/` 中的内置规则: | 文件 | 描述 | |------|-------------| | `malware.yar` | Ransomware、加壳可执行文件、挖矿木马 | | `webshells.yar` | PHP、ASPX、JSP web shells | | `shells.yar` | Bash、Python、Perl、Ruby reverse shells | 将你自己的 `.yar` 文件添加到 `rules/` 目录中,它们将被自动加载。 ## 架构 ``` c2tracker/ cli.py # CLI entry point network.py # Network connection monitoring analyzer.py # Threat scoring engine malware_db.py # 1226 malicious IPs shodan_lookup.py # Shodan API integration censys_lookup.py # Censys API integration hunter.py # Passive C2 hunting via Shodan file_scanner.py # File-based malware analysis yara_scanner.py # YARA rule scanning mitre_attack.py # MITRE ATT&CK mapping export.py # JSON/CSV/IOC export config.py # Configuration management models.py # Data models rules/ # YARA rules directory test_samples/ # Sample malware for testing ``` ## 检测到的 C2 框架 | 框架 | 指标 | |-----------|-----------| | Cobalt Strike | Beacon 特征、Malleable C2 配置文件、端口 50050 | | Metasploit | Meterpreter payloads、reverse_tcp/shells | | Sliver | Sliver 特定端口和服务名称 | | Havoc | Demon implants | | Brute Ratel | Badger payloads | | Mythic | Athena/apfell agents | | Covenant | Grunt implants | | Empire | PowerShell Empire 特征 | | PoshC2 | PoshC2 特定标记 | | AsyncRAT | AsyncRAT 特定的 C2 通道 | | njRAT | njRAT C2 端口 | | Remcos | Remcos C2 基础设施 | | Agent Tesla | Agent Tesla 数据外发服务器 | | TrickBot | TrickBot C2 面板 | | Emotet | Emotet Epoch 4 C2 | | Conti | Conti ransomware C2 | | LockBit | LockBit ransomware C2 | | REvil | REvil/Sodinokibi C2 | | QakBot | QakBot C2 服务器 | | RedLine | RedLine 窃密木马 C2 | | Lumma | Lumma 窃密木马 C2 | | Pikabot | Pikabot C2 | ## 环境要求 - Python 3.9+ - Root/sudo 权限(用于通过 `scan` 进行实时网络监控) - (可选) Shodan API 密钥 — 提供免费 tiers(`hunt` 命令必需) - (可选) Censys API 密钥 — 提供免费 tiers - (可选) `yara-python`,用于 YARA 规则扫描 ## 贡献 欢迎贡献!在提交 PR 之前,请阅读 [CONTRIBUTING.md](CONTRIBUTING.md)。 ## 许可证 MIT — 详情请参阅 [LICENSE](LICENSE)。
标签:C2追踪, DNS 反向解析, IP 地址批量处理, YARA, 云资产可视化, 威胁情报, 开发者工具, 网络信息收集, 网络安全, 请求拦截, 逆向工具, 隐私保护