roy0x01/jspect
GitHub: roy0x01/jspect
jspect 是一款终端 JavaScript 格式化美化与安全侦察工具,能够展开压缩混淆代码并扫描其中的端点、密钥等敏感信息。
Stars: 2 | Forks: 0

# jspect
**在终端中美化和侦察 JS**



`jspect` 使用语法高亮格式化 JavaScript —— 包括将压缩/混淆的 bundle 展开为可读的代码 —— 并使用可配置的规则集检查 JS 中的 endpoint、secret 和其他侦察发现。纯 Go 编写,零依赖。
## 安装
```
go install github.com/roy0x01/jspect@latest
```
## 使用方法
```
jspect
[-o output.js] [--analyze] [--config ]
```
| 命令 | 作用 |
|---|---|
| `jspect app.js` | 格式化并彩色打印 |
| `jspect app.js -o pretty.js` | 格式化并保存到文件 |
| `jspect https://site.com/app.js` | 获取、格式化并打印 |
| `jspect app.js --analyze` | 扫描 endpoint、secret、IP 等 |
| `jspect --init-config` | 将默认规则集写入 `~/.jspect/analyze.conf` |
除非指定了 `-o`,否则永远不会修改输入。
## 格式化
适用于干净和压缩/混淆的 JS —— 将单行 bundle 展开为缩进正确、可读的代码。
| Token | 颜色 |
|---|---|
| 关键字 | 紫罗兰色 |
| 字符串 / 模板字面量 | 鼠尾草绿 |
| 数字 | 珊瑚色 |
| 函数名 | 天蓝色 |
| 运算符 | 粉红色 |
| `{ } ( ) [ ]` | 金色 |
| 注释 | 灰色 |
`JSON.parse("...")` 调用会被自动检测,并且其中的 JSON 会被美化输出。
## 侦察分析
```
jspect app.js --analyze
```
首次运行时,会在 `~/.jspect/analyze.conf` 处创建一个默认规则集,涵盖:
- **Endpoints** — API 路径、HTTP 客户端调用(`fetch`、`axios`、`$.ajax`、`.get/.post/...`)、模板字面量路径
- **URLs** — 绝对 URL、WebSocket endpoint、S3/Azure/GCS bucket
- **GraphQL** — 操作和 endpoint
- **凭证** — JWT、API key、密码、URL 中的基本认证
- **Cloud Keys** — AWS、Google、Stripe、Slack、GitHub、SendGrid、Twilio
- **网络** — IPv4 地址、私有范围
- **调试** — console 语句、TODO/FIXME/硬编码凭证注释
发现结果按类别分组,并按严重程度(`critical → high → medium → info`)排序。
### 自定义规则
直接编辑 `~/.jspect/analyze.conf` —— 无需重新编译:
```
name = Internal Auth Header
category = Custom
severity = high
pattern = X-Internal-Token:\s*[\w\-]+
```
使用 `--config` 指定团队共享配置:
```
jspect app.js --analyze --config ./team-rules.conf
```
## 示例文件
[`sample.js`](sample.js) — 一个真实的压缩 bundle,包含 endpoint、JWT、S3 bucket、GraphQL 操作和硬编码的 secret,用于测试格式化和分析。
```
jspect sample.js
jspect sample.js --analyze
```
## 许可证
MIT标签:CMS安全, EVTX分析, Go语言, JavaScript, 代码美化, 安全助手, 实时处理, 日志审计, 机密扫描, 程序破解