tomnomnom/meg

GitHub: tomnomnom/meg

meg 是一款用 Go 编写的多主机批量路径探测工具,能够在保持对单个主机友好的前提下快速获取大量 URL 的响应。

Stars: 1695 | Forks: 267

# meg meg 是一个用于获取大量 URL 但仍对服务器保持“友好”的工具。 它可以用于为许多主机获取许多路径;在继续下一个路径并重复之前,先为所有主机获取一个路径。 你可以快速获得大量结果,但没有任何单个主机会被流量淹没。 ## 安装 meg 是用 Go 编写的,没有运行时依赖。如果你安装并配置了 Go 1.9 或更高版本,你可以使用 `go install` 安装 meg: ``` ▶ go install github.com/tomnomnom/meg@latest ``` 或者 [download a binary](https://github.com/tomnomnom/meg/releases) 并将其放在 `$PATH` 中的某个位置(例如 `/usr/bin/`)。 ### 安装错误 如果你看到类似这样的错误,说明你的 Go 版本太旧了: ``` # github.com/tomnomnom/rawhttp /root/go/src/github.com/tomnomnom/rawhttp/request.go:102: u.Hostname undefined ( type *url.URL has no field or method Hostname) /root/go/src/github.com/tomnomnom/rawhttp/request.go:103: u.Port undefined (type *url.URL has no field or method Port) /root/go/src/github.com/tomnomnom/rawhttp/request.go:259: undefined: x509.System CertPool ``` 你应该更新你的 Go 版本,或者为你的平台使用二进制发行版。 ## 基本用法 给定一个包含路径的文件: ``` /robots.txt /.well-known/security.txt /package.json ``` 以及一个包含主机(带有协议)的文件: ``` http://example.com https://example.com http://example.net ``` `meg` 将为每个 *主机* 请求每个 *路径*: ``` ▶ meg --verbose paths hosts out/example.com/45ed6f717d44385c5e9c539b0ad8dc71771780e0 http://example.com/robots.txt (404 Not Found) out/example.com/61ac5fbb9d3dd054006ae82630b045ba730d8618 https://example.com/robots.txt (404 Not Found) out/example.net/1432c16b671043271eab84111242b1fe2a28eb98 http://example.net/robots.txt (404 Not Found) out/example.net/61deaa4fa10a6f601adb74519a900f1f0eca38b7 http://example.net/.well-known/security.txt (404 Not Found) out/example.com/20bc94a296f17ce7a4e2daa2946d0dc12128b3f1 http://example.com/.well-known/security.txt (404 Not Found) ... ``` 并将输出保存到名为 `./out` 的目录中: ``` ▶ head -n 20 ./out/example.com/45ed6f717d44385c5e9c539b0ad8dc71771780e0 http://example.com/robots.txt > GET /robots.txt HTTP/1.1 > Host: example.com < HTTP/1.1 404 Not Found < Expires: Sat, 06 Jan 2018 01:05:38 GMT < Server: ECS (lga/13A2) < Accept-Ranges: bytes < Cache-Control: max-age=604800 < Content-Type: text/* < Content-Length: 1270 < Date: Sat, 30 Dec 2017 01:05:38 GMT < Last-Modified: Sun, 24 Dec 2017 06:53:36 GMT < X-Cache: 404-HIT ``` 在没有任何参数的情况下,meg 将从名为 `./paths` 的文件读取路径,从名为 `./hosts` 的文件读取主机。也不会有输出: ``` ▶ meg ▶ ``` 但它会将一个 *索引* 文件保存到 `./out/index`: ``` ▶ head -n 2 ./out/index out/example.com/538565d7ab544bc3bec5b2f0296783aaec25e756 http://example.com/package.json (404 Not Found) out/example.com/20bc94a296f17ce7a4e2daa2946d0dc12128b3f1 http://example.com/.well-known/security.txt (404 Not Found) ``` 你可以使用索引文件来查找响应的存储位置,但通常使用 `grep` 查找你想要的内容更容易: ``` ▶ grep -Hnri '< Server:' out/ out/example.com/61ac5fbb9d3dd054006ae82630b045ba730d8618:14:< Server: ECS (lga/13A2) out/example.com/bd8d9f4c470ffa0e6ec8cfa8ba1c51d62289b6dd:16:< Server: ECS (lga/13A3) ``` 如果你只想请求一个路径,可以直接将其作为参数指定: ``` ▶ meg /admin.php ``` ## 详细用法 meg 的帮助输出试图提供真正的帮助: ``` ▶ meg --help Request many paths for many hosts Usage: meg [options] [path|pathsFile] [hostsFile] [outputDir] Options: -c, --concurrency Set the concurrency level (defaut: 20) -d, --delay Milliseconds between requests to the same host (default: 5000) -H, --header
Send a custom HTTP header -r, --rawhttp Use the rawhttp library for requests (experimental) -s, --savestatus Save only responses with specific status code -v, --verbose Verbose mode -X, --method HTTP method (default: GET) Defaults: pathsFile: ./paths hostsFile: ./hosts outputDir: ./out Paths file format: /robots.txt /package.json /security.txt Hosts file format: http://example.com https://example.edu https://example.net Examples: meg /robots.txt meg -s 200 -X HEAD meg -c 30 / meg hosts.txt paths.txt output ``` ### 并发 默认情况下,meg 将尝试进行 20 个并发请求。你可以使用 `-c` 或 `--concurrency` 选项来更改它: ``` ▶ meg --concurrency 5 ``` 将并发级别保持在高于主机数量的水平并不是很友好——你最终可能会同时向一个主机发送大量请求。 ### 延迟 默认情况下,meg 在对同一主机的请求之间会等待 5000 毫秒。你可以使用 `-d` 或 `--delay` 选项来覆盖它: ``` ▶ meg --delay 10000 ``` **警告:** 在减少延迟之前,请确保你有权向你目标主机发送大量请求。 ### 添加标头 你可以使用 `-H` 或 `--header` 选项在请求上设置额外的标头: ``` ▶ meg --header "Origin: https://evil.com" ▶ grep -h '^>' out/example.com/* > GET /.well-known/security.txt HTTP/1.1 > Origin: https://evil.com > Host: example.com ... ``` ### 原始 HTTP(实验性) 如果你想发送无效的请求——例如带有无效 URL 编码的请求——Go HTTP 客户端将会失败: ``` ▶ meg /%%0a0afoo:bar request failed: parse https://example.org/%%0a0afoo:bar: invalid URL escape "%%0" ``` 你可以使用 `-r` 或 `--rawhttp` 标志来启用 [rawhttp](https://github.com/tomnomnom/rawhttp) 库,该库对请求几乎不进行验证: ``` ▶ meg --verbose --rawhttp /%%0a0afoo:bar out/example.com/eac3a4978bfb95992e270c311582e6da4568d83d https://example.com/%%0a0afoo:bar (HTTP/1.1 404 Not Found) ``` `rawhttp` 库及其使用是实验性的。除此之外,它还不支持分块传输编码,因此如果你使用它,你可能会注意到输出中穿插着分块长度。 ### 仅保存特定的状态码 如果你只想保存返回特定状态码的结果,可以使用 `-s` 或 `--savestatus` 选项: ``` ▶ meg --savestatus 200 /robots.txt ``` ### 指定方法 你可以使用 `-X` 或 `--method` 选项指定要使用的 HTTP 方法: ``` ▶ meg --method TRACE ▶ grep -nri 'TRACE' out/ out/example.com/61ac5fbb9d3dd054006ae82630b045ba730d8618:3:> TRACE /robots.txt HTTP/1.1 out/example.com/bd8d9f4c470ffa0e6ec8cfa8ba1c51d62289b6dd:3:> TRACE /.well-known/security.txt HTTP/1.1 ... ```
标签:DNS解析, EVTX分析, EVTX分析, Go语言, HTTPS请求, HTTP请求, Linux取证, MacOS取证, RAM分析, Web安全, Windows取证, 主机友好, 二进制发布, 内存提取, 合规审计, 安全扫描, 安全研究, 开源工具, 开源项目, 批量URL抓取, 数字调查, 日志审计, 时序注入, 流量控制, 漏洞分析, 程序破解, 蓝队分析, 路径探测, 路径枚举