fazelllyyy/url-deep-trace
GitHub: fazelllyyy/url-deep-trace
企业级 URL 追踪与安全分析引擎,提供 SSL 取证、威胁情报、ML 分类和启发式风险评分,专为 SOC 运营和渗透测试设计。
Stars: 1 | Forks: 0
# @fazelstudio/url-deep-trace
[](https://www.npmjs.com/package/@fazelstudio/url-deep-trace) [](https://github.com/fazelllyyy/url-deep-trace/actions/workflows/ci.yml) [](https://opensource.org/licenses/MIT)
企业级 URL 追踪引擎,提供 SSL 取证、威胁情报、ML 分类和启发式风险评分。专为 SOC 运营、API 安全服务和渗透测试工作流而设计。
## 功能
### 核心追踪
- **重定向链追踪** — 手动 HTTP 3xx 处理与 cookie jar 管理
- **Meta Refresh 检测** — 解析 HTML 以查找 ``
- **JavaScript 重定向检测** — 识别 `location.href`、`location.replace`、`window.location`
- **深度 SSL/TLS 取证** — 并行 socket 级证书检查与过期追踪
### 分析模块
| 模块 | 描述 |
|--------|-------------|
| **词法分析器** | URL 熵、子域名分析、同形异义词/punycode 检测、端口分析 |
| **HTML 分析器** | 表单分析、脚本混淆、iframe 检查、外部资源追踪 |
| **域名情报** | DNS 记录(A、AAAA、MX、TXT、SPF、DMARC)、TLD 信誉、域龄估计 |
| **Header 指纹** | 安全 Header 审计(HSTS、CSP、XFO 等)、cookie 安全性、CORS 分析 |
| **行为分析器** | 重定向模式、域名跳转、协议切换、伪装检测 |
| **威胁情报** | 钓鱼、恶意软件、SQLi/XSS 检测、品牌冒充、IOC 提取 |
| **ML 分类器** | 特征提取、加权评分(良性 → 恶意)、可解释 AI |
| **信誉缓存** | SHA-256 URL 索引、LRU 淘汰、基于 TTL 的过期、黑名单/白名单 |
| **性能管理器** | 批量处理、速率限制、指数退避重试 |
| **Webhook 通知器** | 条件警报(高风险、恶意)、重试机制、批量通知 |
| **速率限制器** | 滑动窗口算法、基于域名的限制、队列管理 |
| **报告引擎** | JSON/CSV 导出、执行/技术/合规/事件报告 |
### 风险评分
多因素启发式评分(0–100):
| 因素 | 分值 |
|--------|--------|
| 过多重定向(> 5 次跳转) | +5–30 |
| 协议降级(HTTPS → HTTP) | +35 |
| 证书问题 | +15–30 |
| 可疑 TLD(.xyz、.top 等) | +12/域名 |
| Meta refresh / JS 重定向 | +10–12 |
| 循环重定向 | +20 |
| HTML 混淆 | +10–25 |
| 钓鱼指标 | +10–25 |
| 恶意软件指标 | +15–30 |
**风险等级:** `minimal`(0–29)、`low`(30–59)、`medium`(60–79)、`high`(80–100)
## 安装说明
```
npm install @fazelstudio/url-deep-trace
```
用于截图捕获的可选依赖项:
```
npm install playwright
# 或
npm install puppeteer
```
## 快速开始
```
import URLDeepTrace from '@fazelstudio/url-deep-trace';
const tracer = new URLDeepTrace({
maxHops: 20,
timeout: 15000,
enableDeepAnalysis: true,
enableThreatIntel: true,
enableMLClassification: true,
});
const result = await tracer.analyze('https://example.com');
console.log('Risk Score:', result.security.risk.score); // 15
console.log('Risk Level:', result.security.risk.level); // "minimal"
console.log('ML Class:', result.mlClassification.classification);
```
## API 参考
### `URLDeepTrace(options?)`
| 选项 | 类型 | 默认值 | 描述 |
|--------|------|--------|-------------|
| `maxHops` | `number` | `20` | 最大重定向跳转次数 |
| `timeout` | `number` | `15000` | 请求超时 (ms) |
| `userAgent` | `string` | 预设 | 自定义 user agent |
| `enableDeepAnalysis` | `boolean` | `true` | 启用词法、域名、Header、HTML、TLS 分析 |
| `enableThreatIntel` | `boolean` | `true` | 启用威胁情报 |
| `enableMLClassification` | `boolean` | `true` | 启用 ML 分类器 |
| `maxConcurrent` | `number` | `5` | 并发分析限制 |
| `retryAttempts` | `number` | `2` | 失败时的重试次数 |
| `retryDelay` | `number` | `1000` | 重试之间的延迟 (ms) |
### 方法
| 方法 | 描述 |
|--------|-------------|
| `analyze(url)` | 利用完整取证分析单个 URL |
| `analyzeMultiple(urls)` | 并发分析多个 URL |
| `analyzeMultipleParallel(urls, options)` | 在受控批次中分析 URL |
| `exportResults(results, format, options)` | 将结果导出为 JSON 或 CSV |
### 响应结构
```
{
success: true,
url: "https://example.com",
finalDestination: "https://example.com",
trace: {
totalHops: 1,
chain: [{
url: "https://example.com",
statusCode: 200,
protocol: "https",
tlsInfo: { ... },
lexical: { ... },
domainInfo: { ... },
headerFingerprint: { ... },
htmlAnalysis: { ... },
timing: { ... }
}]
},
security: {
risk: { score: 15, level: "minimal", factors: [...], details: { ... } }
},
metadata: {
analyzedAt: "2026-01-21T10:30:00.000Z",
executionTime: 2345
}
}
```
## 架构
```
src/
├── index.js # Main entry point
├── tracer.js # Recursive URL tracer
├── tls-inspector.js # SSL/TLS forensics
├── lexical-analyzer.js # URL pattern analysis
├── html-analyzer.js # HTML structure inspection
├── domain-intelligence.js # DNS and domain analysis
├── header-fingerprint.js # HTTP header security audit
├── risk-engine.js # Security risk scoring
├── performance-manager.js # Batch processing & export
├── behavioral-analyzer.js # Redirect behavior analysis
├── threat-intelligence.js # Phishing, malware detection
├── ml-classifier.js # ML classification engine
├── reputation-cache.js # LRU cache with blacklist
├── rate-limiter.js # Sliding window rate limiter
├── webhook-notifier.js # Conditional alerting
├── reporting-engine.js # Multi-format report generator
├── screenshot-capture.js # Browser screenshot (optional)
```
## 开发
```
# 安装
npm install
# 运行测试
npm test
npm run test:all
npm run test:optimization
# 启动 API 服务器
npm run server
# Lint & format
npm run lint
npm run format
```
## 许可证
MIT — © 2026 [Fazel](https://github.com/fazelllyyy)
标签:MITM代理, 暗色界面, 特征检测, 自定义脚本