verygoodsecbadsec/surphaceinyourhand

GitHub: verygoodsecbadsec/surphaceinyourhand

一个轻量级的自动化攻击面持续监控脚本,通过定时任务对目标域名执行多维侦察并与历史基线进行差分对比,在资产发生变化时推送 Webhook 告警。

Stars: 0 | Forks: 0

# 掌中的攻击面监控 专为漏洞赏金侦察、红队资产跟踪以及轻量级企业 ASM 流水线而设计,你只需一个 cron 任务,即可在目标资产在夜间发生变化时收到通知。 ## 监控内容 | # | 任务 | 方式 | |---|---|---| | 1 | 子域名发现(被动 + 暴力破解) | subfinder, amass, dnsx | | 2 | 开放端口 + 服务版本 | naabu → nmap -sV | | 3 | Web 服务器头信息 | curl -I | | 4 | 目录暴力破解(按子域名) | ffuf | | 5 | 全站抓取 | gospider | | 6 | 技术指纹识别 | whatweb | | 7 | DNS 记录监控 (A/AAAA/MX/NS/TXT/CNAME/SOA) | dig | | 8 | WAF 检测(按子域名) | wafw00f | 每个部分会将今天的输出与昨天的快照进行对比,仅报告新增 (`[+]`) 和移除 (`[-]`) 的内容。首次运行时会静默建立基线。 ## 快速开始 ``` # 1. Clone repo git clone https://github.com/verygoodsecbadsec/surphaceinyourhand.git cd surphaceinyourhand # 2. Install 所有 dependencies(Debian/Ubuntu、Arch 或 macOS) chmod +x install.sh && ./install.sh # 3. Copy 并 edit config(可选) cp monitor.conf.example monitor.conf # 4. Run against 你有权限测试的 target ./monitor.sh example.com ``` 结果将写入 `~/monitor//` 并记录到带有日期的日志文件中。 ## Cron 设置(推荐) 每天凌晨 03:00 运行一次: ``` crontab -e ``` ``` 0 3 * * * /path/to/monitor.sh example.com >> /var/log/surphaceinyourhand.log 2>&1 ``` 对于多个目标,每个域名占一行: ``` 0 2 * * * /path/to/monitor.sh target-one.com 0 3 * * * /path/to/monitor.sh target-two.com 0 4 * * * /path/to/monitor.sh target-three.com ``` ## 配置 所有设置均有合理的默认值,并可以在配置文件中或通过环境变量进行覆盖。 ``` ./monitor.sh -c monitor.conf example.com ``` | 变量 | 默认值 | 描述 | |---|---|---| | `TOP_PORTS` | `1000` | naabu 扫描的顶部端口数量 | | `FFUF_THREADS` | `30` | 每个 ffuf 任务的并发线程数 | | `FFUF_RATE` | `100` | 每个 ffuf 任务的最大请求数/秒 | | `CRAWL_DEPTH` | `3` | gospider 抓取深度 | | `SUBDOMAIN_WORDLIST` | `~/wordlists/subdomains-top1million-5000.txt` | 用于子域名暴力破解的字典 | | `DIR_WORDLIST` | `~/wordlists/directories-common.txt` | 用于目录暴力破解的字典 | | `WEBHOOK_URL` | *(空)* | 用于变更警报的 Slack 或 Discord webhook URL | 复制 `monitor.conf.example` 到 `monitor.conf` 并进行调整: ``` TOP_PORTS=3000 FFUF_THREADS=50 FFUF_RATE=150 WEBHOOK_URL="https://hooks.slack.com/services/..." ``` ## Webhook 警报 将 `WEBHOOK_URL` 设置为任何兼容 Slack 的传入 webhook。该脚本仅在检测到至少一个 `[+]` 或 `[-]` 变更时才会发送通知——在安静的夜晚保持静默。 兼容:Slack、Discord(使用 `/slack` webhook 格式)以及任何接受 `{"text": "..."}` POST 请求体的服务。 ## 输出结构 ``` ~/monitor/ └── example.com/ ├── log_20240915_030001.log # Full timestamped log ├── previous/ # Yesterday's snapshot (diffed against) │ ├── subs_alive.txt │ ├── ports_open.txt │ ├── versions.txt │ ├── server_headers.txt │ ├── dirs_all.txt │ ├── crawl_paths.txt │ ├── tech_all.txt │ ├── dns_records.txt │ └── waf_status.txt └── previous.bak/ # Two-day-old snapshot (safety net) ``` `current/` 目录在每次运行开始时创建,并在成功后原子性地轮换为 `previous/`。如果脚本在运行过程中被中断,未完成的 `current/` 将被移除,从而保持 `previous/` 完好无损。 ## 依赖项 | 工具 | 用途 | 安装 | |---|---|---| | subfinder | 被动子域名枚举 | `go install github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest` | | amass | 被动子域名枚举 | `go install github.com/owasp-amass/amass/v4/...@latest` | | dnsx | DNS 解析 + 子域名暴力破解 | `go install github.com/projectdiscovery/dnsx/cmd/dnsx@latest` | | naabu | 快速端口扫描器 | `go install github.com/projectdiscovery/naabu/cmd/naabu@latest` | | nmap | 服务版本检测 | `apt install nmap` | | ffuf | 目录暴力破解 | `go install github.com/ffuf/ffuf/v2@latest` | | whatweb | 技术指纹识别 | `apt install whatweb` | | gospider | Web 爬虫 | `go install github.com/jaeles-project/gospider@latest` | | dig | DNS 记录查询 | `apt install dnsutils` | | wafw00f | WAF 检测 | `pip3 install wafw00f` | | curl | HTTP 头信息获取 | 系统包 | | jq | JSON 解析(ffuf 输出) | `apt install jq` | 运行 `./install.sh` 可自动处理上述所有内容。 ## 字典 该脚本需要两个字典: ``` ~/wordlists/subdomains-top1million-5000.txt ~/wordlists/directories-common.txt ``` `install.sh` 会自动从 [SecLists](https://github.com/danielmiessler/SecLists) 下载这些文件。要使用你自己的字典,请在 `monitor.conf` 中设置路径。 ## 标志 ``` ./monitor.sh [OPTIONS] Options: -c Load config from file (overrides defaults) --dry-run Print config and exit without running any scans ``` ## 限制与注意事项 - **范围**:每次调用仅针对一个域名运行。请为多个目标使用多个 cron 条目。 - **速率限制**:ffuf 默认为 100 req/s。如果目标对流量敏感,请降低 `FFUF_RATE`。 ## 法律声明 本工具仅供在 CTF 比赛、安全研究和受控测试环境中获得授权后使用。在你不拥有或未获得明确授权监控的网络上抓取流量在大多数司法管辖区都是违法的。作者对未经授权的使用不承担任何责任。 ## 许可证 - 本项目基于 MIT 许可证授权 - 有关详细信息,请参见 [LICENSE](LICENSE) 文件。
标签:ASM, BeEF, Bug Bounty, Cron, DNS监控, GitHub项目, WAF测试, 云存储安全, 变更监控, 可自定义解析器, 子域名枚举, 安全脚本, 密码管理, 应用安全, 技术识别, 持续监控, 插件系统, 数据展示, 数据统计, 无线安全, 日志审计, 爬虫, 目录爆破, 端口扫描, 系统安全, 红队, 红队基础设施, 网站指纹, 网络安全审计, 网络扫描, 自动化侦察, 资产梳理, 逆向工具