
많은 호스트에 대해 많은 경로를 가져오기 - 호스트에 부담을 주지 않음
meg는 많은 URL을 가져오되 서버에 '예의 바르게' 대하는 도구입니다.
여러 호스트에 대해 많은 경로를 가져오는 데 사용할 수 있습니다. 한 경로를 모든 호스트에 대해 가져온 후 다음 경로로 넘어가 반복합니다.
많은 결과를 빠르게 얻을 수 있지만, 개별 호스트가 트래픽에 넘쳐나지는 않습니다.
meg는 Go로 작성되었으며 런타임 종속성이 없습니다. Go 1.9 이상이 설치되고 구성되어 있다면 go install로 meg를 설치할 수 있습니다:
▶ go install github.com/tomnomnom/meg@latest
또는 바이너리를 다운로드하여 $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
<!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> Set the concurrency level (defaut: 20)
-d, --delay <val> Milliseconds between requests to the same host (default: 5000)
-H, --header <header> Send a custom HTTP header
-r, --rawhttp Use the rawhttp library for requests (experimental)
-s, --savestatus <status> Save only responses with specific status code
-v, --verbose Verbose mode
-X, --method <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
...
유효하지 않은 요청(예: 잘못된 URL 인코딩)을 보내려면 Go HTTP 클라이언트는 실패합니다:
▶ meg /%%0a0afoo:bar
request failed: parse https://example.org/%%0a0afoo:bar: invalid URL escape "%%0"
-r 또는 --rawhttp 플래그를 사용하여 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
사용할 HTTP 메서드는 -X 또는 --method 옵션으로 지정할 수 있습니다:
▶ 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
...