如何使用meg尽可能多地发现目标主机中的多个URL地址

关于meg

meg是一款功能强大的URL信息收集工具,在该工具的帮助下,广大研究人员能够在不影响目标主机和服务器的情况下,尽可能多地收集与目标主机相关的大量URL地址。

该工具能够同时从多台主机中获取多条URL路径,而且在转移到下一个路径并重复之前,该工具还能够在所有主机中寻找同一条路径。

该工具的运行速度非常快,并且不会导致目标主机被恶意流量所淹没,也就是不会影响目标主机的正常运行。

工具安装

meg采用Go语言开发,并且不需要其他运行时依赖,因此我们首先需要在本地设备上安装并配置好Go v1.9+环境。接下来,我们就可以使用下列命令来安装meg了:

▶ go install github.com/tomnomnom/meg@latest

除此之外,我们还可以直接访问该项目的【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

工具基础使用

我们可以给工具提供一个包含路径的列表文件:

/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

<!doctype html>

<html>

<head>

如果没有提供任何运行参数的话,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 <val> 设置并发等级,默认为20

-d, --delay <val> 对同一主机的请求之间的毫秒数,默认为5000

-H, --header <header> 发送一个自定义HTTP Header

-r, --rawhttp 使用rawhttp库发送请求

-s, --savestatus <status> 仅存储指定状态码的响应信息

-v, --verbose Verbose模式

-X, --method <method> 使用的HTTP方法,默认使用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 --concurrency 5

延迟设置:

▶ meg --delay 10000

添加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

...

仅存储指定状态码:

▶ meg --savestatus 200 /robots.txt

指定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

...

猜你喜欢

转载自blog.csdn.net/m0_60571990/article/details/129565829