CYB3RMX/NuSecurity
GitHub: CYB3RMX/NuSecurity
基于 Nushell 的安全研究命令行工具集,整合威胁情报查询、IOC 信誉判定与主机侧取证分析能力。
Stars: 7 | Forks: 2
# NuSecurity
用于安全研究工作流的 Nushell 配置和辅助命令。
## 可用命令

运行 `hlp` 获取当前命令列表,或运行 `hlp ` 查看详细用法和带注释的示例(上图可能未包含最新命令)。
## 环境要求
- `nu` (Nushell) — 目标版本 0.114+(`str lowercase`/`str uppercase`)
- 常用 CLI 工具(`python3`、`git`、`curl`/网络访问)
- 可选:用于自动安装某些工具(`httpx`、`hednsextractor`)的 `go`
- 可选:用于通过 `yrs` 进行本地规则扫描的 `yara`
- 可选:用于通过 Team Cymru MHR 进行 `vt` 哈希查询的 `dig`(或 `nslookup`)
- 可选:用于 `otx` 完整 ThreatFox 导出的 `unzip`(或 `python3`)
- Linux 上可选:用于包辅助命令的 `apt` + `sudo`
- Linux 上可选:用于提供更丰富 `log-hunt` 输出的 `journalctl`
- Windows 上可选:用于包辅助命令的 `winget`
- Windows 上可选:用于 `windows-evt-hunt` / `log-hunt` / `persist-hunt` 的 `powershell`
- Windows 上可选:用于 `proc-dump` 的 `procdump` (Sysinternals)
内置的威胁情报命令(`vt`、`abuse`、
`otx`)不需要 API key。只有 `rip` / `dchr` 需要 WHOISXMLAPI key,该 key 仅需输入一次,并会保存到
`~/.whoisxmlkey.txt`。
## 设置
在 Nushell (Linux/macOS/Windows) 中运行以下命令:
```
cp $nu.config-path $"($nu.config-path).backup"
cp configs/config.nu $nu.config-path
```
复制完成后重启你的 Nu shell。
## 可选的启动系统信息
系统信息输出(`neofetch`)默认处于禁用状态。
使用以下命令启用:
```
$env.NUSECURITY_SHOW_SYSINFO = true
```
## 威胁情报(无需 API key)
```
vt aadfc11ee472ecd3e8dae7acde9233dac75acfa7 # hash reputation (ThreatFox + Cymru MHR + CIRCL)
vt 160.20.109.75 # IP reputation (ThreatFox + DShield + ip-api geo/hosting)
vt evil.example.com # domain reputation (ThreatFox + urlscan.io)
abuse 45.83.12.9 # IP reputation via ISC SANS DShield
ipinfo 8.8.8.8 # geo + ISP/ASN + reverse DNS enrichment
otx agenttesla # search ThreatFox full export by malware family
otx 45.83.12.9 # search by IP/domain/URL substring
otx --refresh # refresh the cached ThreatFox export (auto every 6h)
defang https://evil.example.com/x # -> hxxps://evil[.]example[.]com/x
refang hxxps://evil[.]example[.]com # reverse of defang
hashf suspicious.bin # md5 + sha1 + sha256 + size
```
`vt` 根据 IOC 类型聚合来自免 key 数据源的单一判定结果(`MALICIOUS` / `suspicious` / `no known reports` /
`unknown`)。`otx` 会将完整的 ThreatFox 导出数据下载并缓存到
`~/.nusecurity/cache` 目录下(TTL 为 6 小时,使用 `--refresh` 可强制刷新)。
### 国家/地区聚焦 (`--cc`)
将 feed 命令的结果筛选至单个国家/地区 —— IP 通过 ip-api 进行地理定位,
域名则通过 ccTLD 进行匹配:
```
otx cobaltstrike --cc TR # only Turkey-based C2s
vrb --cc TR # only Turkey-based C2 panels (Viriback)
tfox --dtype all --cc TR # only Turkey-based ThreatFox IOCs
haus online --cc TR --host-only # only Turkey-based URLHaus hosts
pls --cc TR # only Turkish proxies (uses native geo field)
```
## 快速示例
```
hlp # compact command list with summary + sample
hlp -v # verbose command list
hlp triage # show detailed usage/examples for one command
chkbgp 8.8.8.8 # BGP information for IP
bdc SGVsbG8= # base64 decode (bdc -e "text" to encode)
haus # URLHaus online feed (default)
haus normal --limit 20 # full feed, first 20 URLs
haus --host-only --contains "in.net" --limit 10 # unique hosts filtered by keyword
haus --host-ends-with ".tr" --host-only --limit 20 # hosts ending with .tr
rware TR --limit 20 # country-specific ransomware victims
rware --limit 20 # global recent ransomware victims
rware TR --monitor --interval 30 # live monitor mode for newly added entries
tfox --dtype url # ThreatFox URL-only output
triage --family agenttesla --limit 5 # fetch reports + C2 candidates
triage --family remcos --limit 3 # includes C2 + MalwareConfig
triage --query "sha1:..." --limit 3 --no-c2 --no-config # fastest report listing
triage --query "sha256:..." --limit 1 | get 0.MalwareConfig # expand parsed config fields
hx subdomains.txt # httpx scan over a file
shx example.com # subfinder + httpx
yrs suspicious.bin # YARA scan using ~/rules
persist-hunt --contains cron --limit 50 # Linux/Windows persistence artifacts
proc-hunt --min-score 2 --limit 50 # heuristic suspicious process scoring
proc-dump lsass --out-dir C:\dumps # dump process memory with ProcDump
proc-dump ollama.exe --out-dir C:\dumps --mini # mini dump
proc-dump notepad.exe --out-dir C:\dumps --full # full dump
log-hunt "failed password" --since-hours 24 --limit 100 # suspicious log lines
timeline-lite /var/tmp --with-hash --limit 100 # quick file timeline + optional SHA256
windows-evt-hunt --log Security --event-id 4625 --since-hours 24 # Windows event triage
```
`vt` / `abuse` / `otx` 均无需 key:`vt` 会根据 IOC 类型结合 ThreatFox、Team Cymru MHR(通过 DNS 查询 md5/sha1)、CIRCL hashlookup、ISC SANS DShield、ip-api 以及 urlscan.io 的数据;`abuse` 使用 DShield;`otx` 则搜索缓存的完整 ThreatFox 导出数据。
`otx` 在匹配恶意软件家族名称时会进行标准化处理(例如 `agenttesla` 可以匹配 `win.agent_tesla` / `Agent Tesla`);使用 `--recent` 可获取小型的实时 feed,或使用 `--refresh` 重建缓存。
`--cc ` 可将 `otx`、`vrb`、`tfox`、`haus` 和 `pls` 的结果筛选至特定国家/地区(IP 通过 ip-api 进行地理定位,域名通过 ccTLD 进行匹配;`pls` 使用其原生的地理字段)。
`triage` 的 C2 输出基于启发式算法,主要关注来自行为请求中可能的 payload/C2 主机。
如果获取到了域名信息,它将与 IP 一起显示为 `domain [ip]` 格式。
`MalwareConfig` 现在是一个结构化记录(包含 `family/version/botnet/c2/URLs/Deobfuscated/credentials/mutex`),以实现更清晰的表格输出。
`haus` 支持 `--limit`、`--host-only`、`--contains`、`--host-contains`、`--host-ends-with`、`--https-only`、`--cc` 和 `--raw`。
`rware` 支持 `--monitor`、`--interval`、`--limit` 和 `--max-cycles`(用于测试/调试的循环次数)。
`windows-evt-hunt` 仅限 Windows 使用,并调用 PowerShell 的 `Get-WinEvent`。
`persist-hunt` 会检查常见的持久化驻留点(Linux 的 cron/systemd/autostart/shell 初始化文件,Windows 的 Run 键/startup/计划任务)。
`proc-hunt` 采用启发式评分机制,可能会包含误报结果;请通过 `--min-score` 和 `--contains` 进行调整。
`proc-dump` 仅限 Windows 使用,它封装了 Sysinternals ProcDump(默认使用 `-ma` 进行完整转储,使用 `--mini` 则对应 `-mp`);它会在首次使用时自动下载 ProcDump 并自动添加 `-accepteula` 参数。
`log-hunt` 会读取 Linux 日志文件及 `journalctl`(如果可用)或 Windows 事件日志。
`timeline-lite` 支持 `--with-hash` 以在增加额外运行时间开销的情况下输出 SHA256。
## 安全提示
- `fixu` 会格式化磁盘。运行前请反复确认目标设备。
- `clean`、`aget`、`arem` 会执行特权操作。
- `upc` 会从 GitHub 拉取配置并覆盖你当前的 Nu 配置路径。
- 威胁情报/富化命令(`vt`、`abuse`、`otx`、`ipinfo`、`--cc` 筛选器、`haus`、`tfox`、`vrb`)会将你查询的 IOC/IP 发送给第三方服务(ThreatFox、urlscan.io、ip-api、ISC SANS DShield、Team Cymru、CIRCL)。请勿提交你不想泄露的敏感指标。
## 更新配置
完成设置后,你可以在 Nu 中拉取最新的上游配置:
```
upc
```
标签:AI合规, IP 地址批量处理, Nushell, 威胁情报, 开发者工具, 日志审计, 网络安全研究, 运维辅助, 配置脚本