
대량 조회 및 정찰(서브도메인 열거)을 위한 고성능 DNS 스텁 리졸버
MassDNS는 수백만 또는 수십억 개에 이르는 대량의 도메인 이름을 해석하려는 사용자를 대상으로 하는 간단한 고성능 DNS 스텁 리졸버입니다. 특별한 구성 없이도 MassDNS는 공개적으로 사용 가능한 리졸버를 사용하여 초당 350,000개 이상의 이름을 해석할 수 있습니다.
git 저장소를 클론하고 프로젝트 루트 폴더로 cd한 후, make를 실행하여 소스에서 빌드합니다.
Linux가 아닌 경우 make nolinux를 실행하세요. Windows에서는 Cygwin 패키지 gcc-core, git 및 make가 필요합니다.
Usage: ./bin/massdns [options] [domainlist]
-b --bindto Bind to IP address and port. (Default: 0.0.0.0:0)
--busy-poll Use busy-wait polling instead of epoll.
-c --resolve-count Number of resolves for a name before giving up. (Default: 50)
--drop-group Group to drop privileges to when running as root. (Default: nogroup)
--drop-user User to drop privileges to when running as root. (Default: nobody)
--extended-input Input names are followed by a space-separated list of resolvers.
These are used before falling back to the resolvers file.
--filter Only output packets with the specified response code.
--flush Flush the output file whenever a response was received.
-h --help Show this help.
--ignore Do not output packets with the specified response code.
-i --interval Interval in milliseconds to wait between multiple resolves of the same
domain. (Default: 500)
-l --error-log Error log file path. (Default: /dev/stderr)
--norecurse Use non-recursive queries. Useful for DNS cache snooping.
-o --output Flags for output formatting.
--predictable Use resolvers incrementally. Useful for resolver tests.
--processes Number of processes to be used for resolving. (Default: 1)
-q --quiet Quiet mode.
--rand-src-ipv6 Use a random IPv6 address from the specified subnet for each query.
--rand-src-ipv6-file Use a random IPv6 address from the specified file.
--rcvbuf Size of the receive buffer in bytes.
--retry Unacceptable DNS response codes.
(Default: All codes but NOERROR or NXDOMAIN)
-r --resolvers Text file containing DNS resolvers.
--root Do not drop privileges when running as root. Not recommended.
-s --hashmap-size Number of concurrent lookups. (Default: 10000)
--sndbuf Size of the send buffer in bytes.
--status-format Format for real-time status updates, json or ansi (Default: ansi)
--sticky Do not switch the resolver when retrying.
--socket-count Socket count per process. (Default: 1)
-t --type Record type to be resolved. (Default: A)
--verify-ip Verify IP addresses of incoming replies.
-w --outfile Write to the specified output file instead of standard output.
Output flags:
L - domain list output
S - simple text output
F - full text output
B - binary output
J - ndjson output
Advanced flags for the domain list output mode:
0 - Include NOERROR replies without answers.
Advanced flags for the simple output mode:
d - Include records from the additional section.
i - Indent any reply record.
l - Separate replies using a line feed.
m - Only output reply records that match the question name.
n - Include records from the answer section.
q - Print the question.
r - Print the question with resolver IP address, Unix timestamp and return code prepended.
s - Separate packet sections using a line feed.
t - Include TTL and record class within the output.
u - Include records from the authority section.
Advanced flags for the ndjson output mode:
e - Write a record for each terminal query failure.
명령줄 인터페이스에 대한 자세한 설명은 man ./doc/massdns.1을 사용하여 man 페이지를 참조하십시오.
lists의 resolvers.txt에 있는 리졸버를 사용하여 domains.txt 내의 도메인에서 모든 AAAA 레코드를 해석하고 결과를 results.txt에 저장합니다:
$ ./bin/massdns -r lists/resolvers.txt -t AAAA domains.txt > results.txt
이는 다음과 동일합니다:
$ ./bin/massdns -r lists/resolvers.txt -t AAAA -w results.txt domains.txt
기본적으로 MassDNS는 다음과 유사한 텍스트 형식으로 응답 패킷을 출력합니다:
;; Server: 77.41.229.2:53
;; Size: 93
;; Unix time: 1513458347
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51298
;; flags: qr rd ra ; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
example.com. IN A
;; ANSWER SECTION:
example.com. 45929 IN A 93.184.216.34
;; AUTHORITY SECTION:
example.com. 24852 IN NS b.iana-servers.net.
example.com. 24852 IN NS a.iana-servers.net.
리졸버 IP 주소는 일부 리졸버가 잘못된 결과를 생성하는 경우 출력을 더 쉽게 필터링할 수 있도록 포함됩니다.
저장소에는 subbrute 프로젝트에서 제공하는 리졸버의 필터링된 하위 집합으로 구성된 resolvers.txt 파일이 포함되어 있습니다.
MassDNS 사용 시 사용되는 리졸버에 상당한 부하를 발생시켜 ISP에 학대 신고가 접수될 수 있음에 유의하십시오.
또한 제공된 리졸버가 신뢰할 수 있다고 보장할 수 없습니다. 리졸버 목록은 현재 구식이며 상당 부분의 리졸버가 기능을 하지 않습니다.
MassDNS의 커스텀, malloc-free DNS 구현은 현재 가장 일반적인 레코드만 지원합니다. 협력을 통해 이를 개선하는 데 도움을 주시기 바랍니다.
MassDNS에는 모든 IPv4 PTR 레코드를 해석할 수 있는 Python 스크립트가 포함되어 있으며, 각 쿼리를 표준 출력으로 출력합니다.
$ ./scripts/ptr.py | ./bin/massdns -r lists/resolvers.txt -t PTR -w ptr.txt
in-addr.arpa 내의 레이블은 반대 순서임에 유의하십시오. 1.2.3.4의 도메인 이름을 해석하려면 MassDNS는 입력 쿼리 이름으로 4.3.2.1.in-addr.arpa를 기대합니다.
결과적으로 Python 스크립트는 레코드를 오름차순으로 해석하지 않으며, 이는 IPv4 서브넷의 네임 서버에 갑작스러운 과부하가 발생하는 것을 방지하므로 장점입니다.
정찰 스캔은 책임감 있게 수행하고 권한 있는 네임 서버에 과부하가 걸리지 않도록 -s 매개변수를 조정하십시오.
subbrute와 유사하게, MassDNS는 포함된 subbrute.py 스크립트를 사용하여 서브도메인을 무차별 대입할 수 있습니다:
$ ./scripts/subbrute.py example.com lists/names.txt | ./bin/massdns -r lists/resolvers.txt -t A -o S -w results.txt
추가 정찰 방법으로, ct.py 스크립트는 crt.sh에서 데이터를 스크래핑하여 인증서 투명성 로그에서 서브도메인을 추출합니다:
$ ./scripts/ct.py example.com | ./bin/massdns -r lists/resolvers.txt -t A -o S -w results.txt
subbrute 프로젝트에서 복사된 names.txt 및 names_small.txt 파일에는 일반적으로 사용되는 서브도메인 이름이 포함되어 있습니다. 또한 1,000,000개 이상의 이름이 포함된 Jason Haddix의 서브도메인 모음 또는 9,000,000개 이상의 이름이 포함된 Assetnote 워드리스트를 사용하는 것도 고려하십시오.
MassDNS는 또한 scripts 폴더에 recon.py 래퍼 스크립트(베타 상태)를 포함하고 있으며, 이 스크립트는 권한 있는 네임 서버에 대해 직접 서브도메인 열거를 수행하므로 타사 리졸버가 필요하지 않습니다. 동시성은 MassDNS에 의해 자동으로 결정되며 신뢰할 수 있는 결과를 전달하면서 초당 수십만 개의 쿼리를 지원합니다. 저렴한 전용 서버에서 Assetnode 워드리스트를 1분 이내에 열거할 수 있습니다. 현재 제한 사항은 영역 위임이 위임 지점까지만 처리된다는 점입니다. 예를 들어, example.org가 열거되고 sub.example.org가 다른 네임 서버에 위임된 경우, abc.sub가 워드리스트에 포함되어 있어도 이 스크립트는 abc.sub.example.org를 찾지 못합니다. 그러나 이 경우 스크립트는 ?.sub.example.org로 이 사실을 보고합니다.
$ ./scripts/recon.py -d google.com -l lists/best-dns-wordlist.txt > google.txt

MassDNS는 root 권한이 필요하지 않으므로 root로 실행될 때 기본적으로 "nobody"라는 사용자로 권한을 낮춥니다.
"nobody" 사용자가 존재하지 않는 경우 MassDNS는 실행을 거부합니다. 이 경우 다른 권한 없는 사용자로 MassDNS를 실행하는 것이 좋습니다.
권한 드롭은 --root 인수를 사용하여 우회할 수 있지만 권장되지 않습니다.
또한 master 이외의 브랜치는 프로덕션에서 전혀 사용해서는 안 됩니다.
MassDNS는 네트워크가 병목인 시나리오를 위해 설계된 간단한 단일 스레드 애플리케이션입니다. 높은 업로드 및 다운로드 대역폭을 가진 서버에서 실행되도록 설계되었습니다. 내부적으로 MassDNS는 조회의 동시성을 제어하는 해시 맵을 사용합니다. 따라서 크기 매개변수 -s를 설정하여 조회 속도를 제어할 수 있습니다. 성능 문제가 발생하는 경우 더 나은 성공률을 얻기 위해 -s 매개변수를 조정해 보십시오.
IPv6 리졸버에 의한 속도 제한이 문제가 되는 경우 --rand-src-ipv6 <your_ipv6_prefix>를 사용할 수 있습니다. 그러면 MassDNS는 DNS 패킷을 보내고 받기 위해 raw 소켓을 사용하고 각 쿼리에 대해 지정된 접두사에서 무작위로 소스 IPv6 주소를 선택합니다. 이를 위해서는 MassDNS가 CAP_NET_RAW 권한으로 실행되어야 합니다. 이 방법을 사용할 때는 운영 체제에서 ICMP Port unreachable 응답이 생성되지 않도록 iptables 또는 nftables가 MassDNS가 수신하는 DNS 트래픽을 드롭하도록 해야 합니다. 예를 들어 ip6tables -p udp --sport 53 -I INPUT -j DROP을 사용할 수 있습니다. 이 규칙은 예시이며 다른 애플리케이션의 트래픽을 포함한 모든 DNS 트래픽을 드롭합니다. 사용 사례에 맞게 더 세분화된 규칙으로 조정해야 할 수 있습니다.
결과의 신뢰성이 매우 중요한 경우 포함된 리졸버 목록에 의존해서는 안 됩니다. 대신 로컬 unbound 리졸버를 설정하고 MassDNS에 해당 IP 주소를 제공하십시오. MassDNS를 정찰 도구로 사용하는 경우 먼저 기본 리졸버 목록으로 실행한 후 발견된 이름에 대해 신뢰할 수 있는 리졸버 목록으로 다시 실행하여 오탐을 제거할 수 있습니다.
단일 이름(예: example.com)에 대한 서브도메인을 열거하는 경우 타사 리졸버를 생략하는 것이 좋습니다. 이 경우 다음과 같이 권한 있는 네임 서버를 직접 조회할 수 있습니다:
$ ./bin/massdns -r <(./scripts/auth-addrs.sh example.com) --norecurse -o Je example-com-subdomains.txt > results.txt