abbisQQ/jspect
GitHub: abbisQQ/jspect
jspect 是一个自动化 JavaScript 安全分析流水线,整合多种工具对目标站点的 JS 资源进行爬取、静态分析和漏洞检测,最终输出 HTML 报告。
Stars: 0 | Forks: 0
# jspect
自动化 JavaScript 安全分析流水线。爬取目标站点,提取所有 JS 资源,运行标准工具链(Katana → JSluice → Semgrep → Retire.js → TruffleHog)以及若干附加模块(source-map 盲探测、Wayback、well-known 文件、AJAX 爬虫),最终生成一份自包含的 HTML 报告。
## 三种运行方式
```
# 1. CLI — 一条命令
jspect -u https://target.com
# 2. 终端向导 — 引导式提示
jspect -i
# 3. Web 向导 — 本地主机上的浏览器 UI
jspect --serve
```
Web 向导还接受 **原始 Burp 请求**(从 Burp 的"复制请求"剪贴板粘贴),自动提取 URL + Cookie + 认证头。
## 安装
### Docker(推荐 — 打包所有依赖)
```
git clone https://github.com/abbisQQ/jspect
cd jspect
docker build -t jspect .
# 然后是以下任意一种:
docker run --rm -v $(pwd)/out:/output jspect -u https://target.com
docker run --rm -it -v $(pwd)/out:/output jspect -i
docker run --rm -p 8765:8765 -v $(pwd)/out:/output jspect --serve --bind 0.0.0.0
```
### 原生安装(macOS / Linux)
```
pip install -r requirements.txt
# 外部二进制文件(一次性):
go install github.com/projectdiscovery/katana/cmd/katana@latest
go install github.com/BishopFox/jsluice/cmd/jsluice@latest
go install github.com/denandz/sourcemapper@latest
npm install -g retire
brew install trufflehog # or: see install.sh on trufflehog repo
playwright install chromium # only for --ajax-spider
```
使用 `python3 jspect.py -u https://target.com` 运行。
## 配置文件
选择扫描强度。以下大部分标志已捆绑到这些配置文件中:
| 配置文件 | 线程数 | 上限 | AJAX 爬虫 | 主动侦察 | Wayback | 适用场景 |
|---------|--------:|----:|:-----------:|:------------:|:-------:|------|
| `fast` | 10 | 200 | 关闭 | 关闭 | 关闭 | 快速分类 — 约 30 秒 |
| `default` ★ | 10 | 500 | **开启** | 关闭 | 开启 | 大多数测试场景 |
| `full` | 10 | ∞ | 开启 | 开启 | 开启 | 最大覆盖(约 10-30 分钟) |
| `gentle` | 1 | 200 | 关闭 | 关闭 | 关闭 | 对小型/脆弱目标的温和扫描 |
```
jspect -u https://target.com --profile gentle
```
## 常用标志
```
-u URL Target URL
--dir PATH Local source directory (skips crawl)
-H "Cookie: ..." Auth header (repeatable)
--from-burp FILE Read raw HTTP request from file (or '-' for stdin)
-o DIR Output directory (default: auto-timestamped)
--profile MODE fast / default / full / gentle
--proxy URL Route everything through Burp / mitmproxy / Tor
-i Terminal wizard
--serve [--port N] Web wizard (default port 8765)
--help-advanced Show ~15 more advanced flags
```
### 认证扫描(以下任一方式均可)
```
jspect -u https://app.example.com -H "Cookie: session=..." -H "Authorization: Bearer eyJ..."
jspect --from-burp /path/to/burp-request.txt
pbpaste | jspect --from-burp - # macOS — pipe a Burp clipboard
```
### 通过 Burp 代理所有流量
```
jspect -u https://target.com --proxy http://127.0.0.1:8080 --proxy-insecure
```
所有请求 — Katana 爬取、JS 下载、实时验证探测、well-known、Wayback、AJAX 爬虫、盲 source-map 探测 — 均会出现在 Burp 的站点地图中。
## 报告内容
HTML 报告以 **关键发现** 摘要开头(CVE、暴露的 map、ERROR 级别 SAST、泄露、悬空 JS 等),并直接链接到每一行。下方包含:
| 章节 | 内容 |
|---------|---------|
| 端点 | JS 代码调用的所有 URL(jsluice AST 提取) |
| AJAX 爬虫 | 仅在 JS 水合/点击后发现的 URL(使用 `--ajax-spider` 时) |
| 实时端点 | HTTP 探测结果 — 状态码、类型、大小、标题 |
| HTTP 调用 | 源码中的 `fetch` / `axios` / `XHR` / Express 路由 |
| Source Maps | 暴露的 `.map` 文件(提取原始源码树) |
| 库 | Retire.js 发现 — 存在漏洞的库版本 + CVE |
| Semgrep | DOM-XSS / `eval` / 开放重定向 / Cookie 配置错误 |
| 密钥 | JWT / AWS / API key 模式 + TruffleHog 候选 |
| Well-known | `robots.txt` / `sitemap.xml` / `.well-known/*` / `.git/*` / `.env*` 等 |
| 注释 | JS 源码中的 TODO / FIXME / 凭据提及 |
空章节会折叠为一行"无发现"——即使目标站点干净,报告依然保持可读性。
## Web 向导
`jspect --serve` 启动一个仅限本地访问的 HTTP 服务器(默认 `127.0.0.1:8765`)。包含三个页面:
| URL | 页面 |
|-----|------|
| `/` | 表单 — 启动新扫描(URL 标签页 + Burp 请求标签页 + 高级选项) |
| `/jobs/` | 实时进度 — 逐阶段 SSE 流 + 停止 / 浏览 / 报告按钮 |
| `/scans` | 历史扫描记录 — 磁盘上所有扫描目录,不受服务器生命周期限制 |
以子进程方式提交扫描;**停止扫描** 发送 SIGTERM(3 秒宽限期)→ SIGKILL。部分输出会被保留。
如需对外暴露(请使用 VPN — 无认证机制):
```
jspect --serve --bind 0.0.0.0 --port 8765
```
## 流水线阶段(供参考)
```
1. Katana crawl (URL mode)
1b. AJAX spider (Playwright, opt-in via profile)
2. JS download + HTML