域名系统(DNS) 充当互联网的目录,允许用户通过易记的域名(如 google.com 或 facebook.com)访问网站,而不是数字的互联网协议(IP)地址。通过将域名翻译为 IP 地址,DNS 确保 Web 浏览器可以快速加载互联网资源,简化我们在线世界中的导航。
默认端口: 53
PORT STATE SERVICE REASON
53/tcp open domain Microsoft DNS 6.1.7601 (1DB15D39) (Windows Server 2008 R2 SP1)
5353/udp open zeroconf udp-response
53/udp open domain Microsoft DNS 6.1.7601 (1DB15D39) (Windows Server 2008 R2 SP1)
digaxfr@<DNS_IP>#Try zone transfer without domaindigaxfr@<DNS_IP><DOMAIN>#Try zone transfer guessing the domainfierce--domain<DOMAIN>--dns-servers<DNS_IP>#Will try toperform a zone transfer against every authoritative name server and if this doesn'twork, will launch a dictionary attack
更多信息
digANY@<DNS_IP><DOMAIN>#Any informationdigA@<DNS_IP><DOMAIN>#Regular DNS requestdigAAAA@<DNS_IP><DOMAIN>#IPv6 DNS requestdigTXT@<DNS_IP><DOMAIN>#InformationdigMX@<DNS_IP><DOMAIN>#Emails relateddigNS@<DNS_IP><DOMAIN>#DNS that resolves that namedig-x192.168.0.2@<DNS_IP>#Reverse lookupdig-x2a00:1450:400c:c06::93@<DNS_IP>#reverse IPv6 lookup#Use [-p PORT] or -6 (to use ivp6 address of dns)
自动化
for sub in $(cat<WORDLIST>);do dig $sub.<DOMAIN> @<DNS_IP>|grep-v';\|SOA'|sed-r'/^\s*$/d'|grep $sub |tee-asubdomains.txt;donednsenum--dnsserver<DNS_IP>--enum-p0-s0-osubdomains.txt-f<WORDLIST><DOMAIN>
使用 nslookup
nslookup> SERVER <IP_DNS>#Select dns server> 127.0.0.1 #Reverse lookup of 127.0.0.1, maybe...><IP_MACHINE>#Reverse lookup of a machine, maybe...
#Perform enumeration actionsnmap-n--script"(default and *dns*) or fcrdns or dns-srv-enum or dns-random-txid or dns-random-srcport"<IP>
DNS - 反向 BF
dnsrecon-r127.0.0.0/24-n<IP_DNS>#DNS reverse of all of the addressesdnsrecon-r127.0.1.0/24-n<IP_DNS>#DNS reverse of all of the addressesdnsrecon-r<IP_DNS>/24-n<IP_DNS>#DNS reverse of all of the addressesdnsrecon-dactive.htb-a-n<IP_DNS>#Zone transfer
返回了针对 user@example.com 的错误代码 #550 5.1.1 RESOLVER.ADR.RecipNotFound; not found 的失败通知。
原始消息头中披露了内部IP地址和主机名。
The original message headers were modified for anonymity and now present randomized data:Generating server: server.example.comuser@example.com#550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##Original message headers:Received: from MAILSERVER01.domain.example.com (192.168.1.1) bymailserver02.domain.example.com (192.168.2.2) with Microsoft SMTP Server (TLS)id 14.3.174.1; Mon, 25 May 2015 14:52:22 -0700Received: from filter.example.com (203.0.113.1) byMAILSERVER01.domain.example.com (192.168.1.1) with Microsoft SMTP Server (TLS)id 14.3.174.1; Mon, 25 May 2015 14:51:22 -0700X-ASG-Debug-ID: 1432576343-0614671716190e0d0001-zOQ9WJReceived: from gateway.domainhost.com (gateway.domainhost.com [198.51.100.37]) byfilter.example.com with ESMTP id xVNPkwaqGgdyH5Ag for user@example.com; Mon,25 May 2015 14:52:13 -0700 (PDT)X-Envelope-From: sender@anotherdomain.orgX-Apparent-Source-IP: 198.51.100.37
Protocol_Name: DNS #Protocol Abbreviation if there is one.
Port_Number: 53 #Comma separated if there is more than one.
Protocol_Description: Domain Name Service #Protocol Abbreviation Spelled out
Entry_1:
Name: Notes
Description: Notes for DNS
Note: |
#These are the commands I run every time I see an open DNS port
dnsrecon -r 127.0.0.0/24 -n {IP} -d {Domain_Name}
dnsrecon -r 127.0.1.0/24 -n {IP} -d {Domain_Name}
dnsrecon -r {Network}{CIDR} -n {IP} -d {Domain_Name}
dig axfr @{IP}
dig axfr {Domain_Name} @{IP}
nslookup
SERVER {IP}
127.0.0.1
{IP}
Domain_Name
exit
https://book.hacktricks.xyz/pentesting/pentesting-dns
Entry_2:
Name: Banner Grab
Description: Grab DNS Banner
Command: dig version.bind CHAOS TXT @DNS
Entry_3:
Name: Nmap Vuln Scan
Description: Scan for Vulnerabilities with Nmap
Command: nmap -n --script "(default and *dns*) or fcrdns or dns-srv-enum or dns-random-txid or dns-random-srcport" {IP}
Entry_4:
Name: Zone Transfer
Description: Three attempts at forcing a zone transfer
Command: dig axfr @{IP} && dix axfr @{IP} {Domain_Name} && fierce --dns-servers {IP} --domain {Domain_Name}
Entry_5:
Name: Active Directory
Description: Eunuerate a DC via DNS
Command: dig -t _gc._{Domain_Name} && dig -t _ldap._{Domain_Name} && dig -t _kerberos._{Domain_Name} && dig -t _kpasswd._{Domain_Name} && nmap --script dns-srv-enum --script-args "dns-srv-enum.domain={Domain_Name}"
Entry_6:
Name: consolesless mfs enumeration
Description: DNS enumeration without the need to run msfconsole
Note: sourced from https://github.com/carlospolop/legion
Command: msfconsole -q -x 'use auxiliary/scanner/dns/dns_amp; set RHOSTS {IP}; set RPORT 53; run; exit' && msfconsole -q -x 'use auxiliary/gather/enum_dns; set RHOSTS {IP}; set RPORT 53; run; exit'