mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-22 12:43:23 +00:00
305 lines
15 KiB
Markdown
305 lines
15 KiB
Markdown
# 53 - Pentesting DNS
|
|
|
|
{% hint style="success" %}
|
|
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Support HackTricks</summary>
|
|
|
|
* Kyk na die [**subskripsie planne**](https://github.com/sponsors/carlospolop)!
|
|
* **Sluit aan by die** 💬 [**Discord groep**](https://discord.gg/hRep4RUj7f) of die [**telegram groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
|
|
|
</details>
|
|
{% endhint %}
|
|
|
|
<figure><img src="/.gitbook/assets/pentest-tools.svg" alt=""><figcaption></figcaption></figure>
|
|
|
|
**Onmiddellik beskikbare opstelling vir kwesbaarheidsassessering & penetrasietoetsing**. Voer 'n volledige pentest vanaf enige plek uit met 20+ gereedskap & funksies wat van rekognisie tot verslagdoening strek. Ons vervang nie pentesters nie - ons ontwikkel pasgemaakte gereedskap, opsporing & eksploitasiemodules om hulle weer 'n bietjie tyd te gee om dieper te delf, shells te pop en pret te hê.
|
|
|
|
{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %}
|
|
|
|
## **Basiese Inligting**
|
|
|
|
Die **Domeinnaamstelsel (DNS)** dien as die internet se gids, wat gebruikers in staat stel om toegang tot webwerwe te verkry deur middel van **maklik onthoubare domeinnames** soos google.com of facebook.com, eerder as die numeriese Internetprotokol (IP) adresse. Deur domeinnames in IP adresse te vertaal, verseker die DNS dat webblaaiers vinnig internetbronne kan laai, wat die manier waarop ons die aanlyn wêreld navigeer vereenvoudig.
|
|
|
|
**Standaard poort:** 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)
|
|
```
|
|
### Verskillende DNS Bedieners
|
|
|
|
* **DNS Wortel Bedieners**: Hierdie is aan die bokant van die DNS hiërargie, wat die topvlak domeine bestuur en slegs ingryp as laer vlak bedieners nie reageer nie. Die Internet Korporasie vir Toegewyde Name en Nommers (**ICANN**) toesig oor hul werking, met 'n globale telling van 13.
|
|
* **Autoritatiewe Naamservers**: Hierdie bedieners het die finale sê vir navrae in hul aangewese sones, wat definitiewe antwoorde bied. As hulle nie 'n antwoord kan verskaf nie, word die navraag na die wortelbedieners opgestoot.
|
|
* **Nie-autoritatiewe Naamservers**: Gebrek aan eienaarskap oor DNS sones, hierdie bedieners versamel domein inligting deur navrae aan ander bedieners.
|
|
* **Kas DNS Bediener**: Hierdie tipe bediener onthou vorige navraag antwoorde vir 'n bepaalde tyd om reaksietye vir toekomstige versoeke te versnel, met die kasduur wat deur die autoritatiewe bediener bepaal word.
|
|
* **Voorwaartse Bediener**: Wat 'n eenvoudige rol dien, stuur voorwaartse bedieners eenvoudig navrae na 'n ander bediener.
|
|
* **Resolver**: Geïntegreer binne rekenaars of routers, voer resolvers naamresolusie plaaslik uit en word nie as autoritatief beskou nie.
|
|
|
|
## Enumerasie
|
|
|
|
### **Banner Grabbing**
|
|
|
|
Daar is nie bane in DNS nie, maar jy kan die magiese navraag vir `version.bind. CHAOS TXT` gryp wat op die meeste BIND naamservers sal werk.\
|
|
Jy kan hierdie navraag uitvoer met `dig`:
|
|
```bash
|
|
dig version.bind CHAOS TXT @DNS
|
|
```
|
|
Boonop kan die hulpmiddel [`fpdns`](https://github.com/kirei/fpdns) ook die bediener vingerafdruk.
|
|
|
|
Dit is ook moontlik om die banier te gryp met 'n **nmap** skrip:
|
|
```
|
|
--script dns-nsid
|
|
```
|
|
### **Enige rekord**
|
|
|
|
Die rekord **ANY** sal die DNS-bediener vra om **terug te gee** al die beskikbare **ingevoerde** wat **hy bereid is om bekend te maak**.
|
|
```bash
|
|
dig any victim.com @<DNS_IP>
|
|
```
|
|
### **Zone Oordrag**
|
|
|
|
Hierdie prosedure word afgekort as `Asynchronous Full Transfer Zone` (`AXFR`).
|
|
```bash
|
|
dig axfr @<DNS_IP> #Try zone transfer without domain
|
|
dig axfr @<DNS_IP> <DOMAIN> #Try zone transfer guessing the domain
|
|
fierce --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
|
|
```
|
|
### Meer inligting
|
|
```bash
|
|
dig ANY @<DNS_IP> <DOMAIN> #Any information
|
|
dig A @<DNS_IP> <DOMAIN> #Regular DNS request
|
|
dig AAAA @<DNS_IP> <DOMAIN> #IPv6 DNS request
|
|
dig TXT @<DNS_IP> <DOMAIN> #Information
|
|
dig MX @<DNS_IP> <DOMAIN> #Emails related
|
|
dig NS @<DNS_IP> <DOMAIN> #DNS that resolves that name
|
|
dig -x 192.168.0.2 @<DNS_IP> #Reverse lookup
|
|
dig -x 2a00:1450:400c:c06::93 @<DNS_IP> #reverse IPv6 lookup
|
|
|
|
#Use [-p PORT] or -6 (to use ivp6 address of dns)
|
|
```
|
|
#### Outomatisering
|
|
```bash
|
|
for sub in $(cat <WORDLIST>);do dig $sub.<DOMAIN> @<DNS_IP> | grep -v ';\|SOA' | sed -r '/^\s*$/d' | grep $sub | tee -a subdomains.txt;done
|
|
|
|
dnsenum --dnsserver <DNS_IP> --enum -p 0 -s 0 -o subdomains.txt -f <WORDLIST> <DOMAIN>
|
|
```
|
|
#### Gebruik van nslookup
|
|
```bash
|
|
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...
|
|
```
|
|
### Nuttige metasploit modules
|
|
```bash
|
|
auxiliary/gather/enum_dns #Perform enumeration actions
|
|
```
|
|
### Nuttige nmap skripte
|
|
```bash
|
|
#Perform enumeration actions
|
|
nmap -n --script "(default and *dns*) or fcrdns or dns-srv-enum or dns-random-txid or dns-random-srcport" <IP>
|
|
```
|
|
### DNS - Omgekeerde BF
|
|
```bash
|
|
dnsrecon -r 127.0.0.0/24 -n <IP_DNS> #DNS reverse of all of the addresses
|
|
dnsrecon -r 127.0.1.0/24 -n <IP_DNS> #DNS reverse of all of the addresses
|
|
dnsrecon -r <IP_DNS>/24 -n <IP_DNS> #DNS reverse of all of the addresses
|
|
dnsrecon -d active.htb -a -n <IP_DNS> #Zone transfer
|
|
```
|
|
{% hint style="info" %}
|
|
As jy in staat is om subdomeine te vind wat na interne IP-adresse oplos, moet jy probeer om 'n omgekeerde dns BF na die NS's van die domein te doen wat vir daardie IP-reeks vra.
|
|
{% endhint %}
|
|
|
|
Nog 'n hulpmiddel om dit te doen: [https://github.com/amine7536/reverse-scan](https://github.com/amine7536/reverse-scan)
|
|
|
|
Jy kan omgekeerde IP-reekse navraag doen by [https://bgp.he.net/net/205.166.76.0/24#\_dns](https://bgp.he.net/net/205.166.76.0/24#\_dns) (hierdie hulpmiddel is ook nuttig met BGP).
|
|
|
|
### DNS - Subdomeine BF
|
|
```bash
|
|
dnsenum --dnsserver <IP_DNS> --enum -p 0 -s 0 -o subdomains.txt -f subdomains-1000.txt <DOMAIN>
|
|
dnsrecon -D subdomains-1000.txt -d <DOMAIN> -n <IP_DNS>
|
|
dnscan -d <domain> -r -w subdomains-1000.txt #Bruteforce subdomains in recursive way, https://github.com/rbsec/dnscan
|
|
```
|
|
### Aktiewe Gids servers
|
|
```bash
|
|
dig -t _gc._tcp.lab.domain.com
|
|
dig -t _ldap._tcp.lab.domain.com
|
|
dig -t _kerberos._tcp.lab.domain.com
|
|
dig -t _kpasswd._tcp.lab.domain.com
|
|
|
|
nslookup -type=srv _kerberos._tcp.<CLIENT_DOMAIN>
|
|
nslookup -type=srv _kerberos._tcp.domain.com
|
|
|
|
nmap --script dns-srv-enum --script-args "dns-srv-enum.domain='domain.com'"
|
|
```
|
|
### DNSSec
|
|
```bash
|
|
#Query paypal subdomains to ns3.isc-sns.info
|
|
nmap -sSU -p53 --script dns-nsec-enum --script-args dns-nsec-enum.domains=paypal.com ns3.isc-sns.info
|
|
```
|
|
### IPv6
|
|
|
|
Brute force met "AAAA" versoeke om die IPv6 van die subdomeine te versamel.
|
|
```bash
|
|
dnsdict6 -s -t <domain>
|
|
```
|
|
Bruteforce omgekeerde DNS met behulp van IPv6 adresse
|
|
```bash
|
|
dnsrevenum6 pri.authdns.ripe.net 2001:67c:2e8::/48 #Will use the dns pri.authdns.ripe.net
|
|
```
|
|
### DNS Rekursie DDoS
|
|
|
|
As **DNS-rekursie geaktiveer is**, kan 'n aanvaller **spoof** die **oorsprong** op die UDP-pakket om die **DNS die antwoord na die slagofferbediener** te laat stuur. 'n Aanvaller kan **ANY** of **DNSSEC** rekordtipes misbruik, aangesien hulle groter antwoorde het.\
|
|
Die manier om te **kontroleer** of 'n DNS **rekursie** ondersteun, is om 'n domeinnaam te vra en te **kontroleer** of die **vlag "ra"** (_rekursie beskikbaar_) in die antwoord is:
|
|
```bash
|
|
dig google.com A @<IP>
|
|
```
|
|
**Nie beskikbaar**:
|
|
|
|
![](<../.gitbook/assets/image (123).png>)
|
|
|
|
**Beskikbaar**:
|
|
|
|
![](<../.gitbook/assets/image (146).png>)
|
|
|
|
<figure><img src="/.gitbook/assets/pentest-tools.svg" alt=""><figcaption></figcaption></figure>
|
|
|
|
**Onmiddellik beskikbare opstelling vir kwesbaarheidsevaluering & penetrasietoetsing**. Voer 'n volledige pentest vanaf enige plek uit met 20+ gereedskap & funksies wat van rekognisie tot verslagdoening strek. Ons vervang nie pentesters nie - ons ontwikkel pasgemaakte gereedskap, opsporing & eksploitasiemodules om hulle weer 'n bietjie tyd te gee om dieper te delf, shells te pop, en pret te hê.
|
|
|
|
{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %}
|
|
|
|
### Pos aan nie-bestaande rekening
|
|
|
|
Deur die ondersoek van 'n nie-aflewering kennisgewing (NDN) wat veroorsaak is deur 'n e-pos wat na 'n ongeldige adres binne 'n teikendom gestuur is, word waardevolle interne netwerkbesonderhede dikwels bekend gemaak.
|
|
|
|
Die verskafde nie-afleweringsverslag sluit inligting in soos:
|
|
|
|
* Die genererende bediener is geïdentifiseer as `server.example.com`.
|
|
* 'n Foutkennisgewing vir `user@example.com` met die foutkode `#550 5.1.1 RESOLVER.ADR.RecipNotFound; nie gevind nie` is teruggestuur.
|
|
* Interne IP-adresse en gasheername is in die oorspronklike boodskapkoppe bekend gemaak.
|
|
```markdown
|
|
The original message headers were modified for anonymity and now present randomized data:
|
|
|
|
Generating server: server.example.com
|
|
|
|
user@example.com
|
|
#550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##
|
|
|
|
Original message headers:
|
|
|
|
Received: from MAILSERVER01.domain.example.com (192.168.1.1) by
|
|
mailserver02.domain.example.com (192.168.2.2) with Microsoft SMTP Server (TLS)
|
|
id 14.3.174.1; Mon, 25 May 2015 14:52:22 -0700
|
|
Received: from filter.example.com (203.0.113.1) by
|
|
MAILSERVER01.domain.example.com (192.168.1.1) with Microsoft SMTP Server (TLS)
|
|
id 14.3.174.1; Mon, 25 May 2015 14:51:22 -0700
|
|
X-ASG-Debug-ID: 1432576343-0614671716190e0d0001-zOQ9WJ
|
|
Received: from gateway.domainhost.com (gateway.domainhost.com [198.51.100.37]) by
|
|
filter.example.com with ESMTP id xVNPkwaqGgdyH5Ag for user@example.com; Mon,
|
|
25 May 2015 14:52:13 -0700 (PDT)
|
|
X-Envelope-From: sender@anotherdomain.org
|
|
X-Apparent-Source-IP: 198.51.100.37
|
|
```
|
|
## Konfigurasie lêers
|
|
```
|
|
host.conf
|
|
/etc/resolv.conf
|
|
/etc/bind/named.conf
|
|
/etc/bind/named.conf.local
|
|
/etc/bind/named.conf.options
|
|
/etc/bind/named.conf.log
|
|
/etc/bind/*
|
|
```
|
|
Dangerous settings when configuring a Bind server:
|
|
|
|
| **Option** | **Description** |
|
|
| ----------------- | ------------------------------------------------------------------------------ |
|
|
| `allow-query` | Definieer watter hosts toegelaat is om versoeke na die DNS-bediener te stuur. |
|
|
| `allow-recursion` | Definieer watter hosts toegelaat is om rekursiewe versoeke na die DNS-bediener te stuur. |
|
|
| `allow-transfer` | Definieer watter hosts toegelaat is om sone-oordragte van die DNS-bediener te ontvang. |
|
|
| `zone-statistics` | Versamel statistiese data van sones. |
|
|
|
|
## References
|
|
|
|
* [https://www.myrasecurity.com/en/knowledge-hub/dns/](https://www.myrasecurity.com/en/knowledge-hub/dns/)
|
|
* Book: **Network Security Assessment 3rd edition**
|
|
|
|
## HackTricks Automatic Commands
|
|
```
|
|
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'
|
|
```
|
|
<figure><img src="/.gitbook/assets/pentest-tools.svg" alt=""><figcaption></figcaption></figure>
|
|
|
|
**Onmiddellik beskikbare opstelling vir kwesbaarheidsevaluering & penetrasietoetsing**. Voer 'n volledige pentest vanaf enige plek uit met 20+ gereedskap & funksies wat van rekognisie tot verslagdoening strek. Ons vervang nie pentesters nie - ons ontwikkel pasgemaakte gereedskap, opsporing & eksploitasiemodules om hulle weer 'n bietjie tyd te gee om dieper te delf, shells te pop en pret te hê.
|
|
|
|
{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %}
|
|
|
|
{% hint style="success" %}
|
|
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
|
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
|
|
|
<details>
|
|
|
|
<summary>Ondersteun HackTricks</summary>
|
|
|
|
* Kyk na die [**subskripsieplanne**](https://github.com/sponsors/carlospolop)!
|
|
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
|
* **Deel hacking truuks deur PR's in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
|
|
|
</details>
|
|
{% endhint %}
|