# 5. DNS Enumeration

## 1. DNS Enumeration using zone transfer

### dig

find the nameserver of a domain

```
dig ns zonetransfer.me
```

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2FPtm0DBF5lsOsdyrDpMFg%2Fimage.png?alt=media&#x26;token=22aa2dd9-2268-4aeb-9f14-58b0b69ecff0" alt=""><figcaption></figcaption></figure>

Now try the zone transfer for the domain from its primary and secondary name servers

```
dig axfr zonetransfer.me @nsztm2.digi.ninja
```

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2FvPLrZ1aeYj49YzrS9A3f%2Fimage.png?alt=media&#x26;token=c5f8fe6a-3222-409b-a5b7-c7da31d37c58" alt=""><figcaption></figcaption></figure>

### nslookup

Fire up the tool on windows

```
nslookup
set querytype=soa
```

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2FOs4fiK1q5ZuXKHWCsBsV%2Fimage.png?alt=media&#x26;token=4ad72dfd-ae34-4da3-aa43-749741a08445" alt=""><figcaption></figcaption></figure>

Now execute the zone transfer

```
ls -d nsztm2.digi.ninja
```

## <mark style="color:red;">2. Zone transfer using DNSSEC transfer</mark>

{% embed url="<https://github.com/darkoperator/dnsrecon>" %}

```
./dnsrecon.py -d zonetransfer.me -z
```

{% hint style="info" %}
-d target domain

-z DNSSEC Zone walk
{% endhint %}

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2FLFKiahJ29swPL9tCmJKG%2Fimage.png?alt=media&#x26;token=6e7cacfc-19d3-4ee0-bd8e-e549ced4a8da" alt=""><figcaption></figcaption></figure>

**Other tools**

{% embed url="<https://github.com/davebarr/dnswalk>" %}

## <mark style="color:red;">3. DNS Enumeration using Nmap</mark>

```
nmap --script=broadcast-dns-service-discovery zonetransfer.me
```

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2Fx38eQfyswRWvMnnSgyJn%2Fimage.png?alt=media&#x26;token=b7bbd6b0-313e-459e-b8d1-bfea1d0c8bb7" alt=""><figcaption></figcaption></figure>

DNS brute forcing

```
nmap -T5 -p 53 --script dns-brute zonetransfer.me
```

<figure><img src="https://2218819509-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrUBnODuUX4EQ8P27uc5D%2Fuploads%2FdwNaWBIdctUX8v7OQhlN%2Fimage.png?alt=media&#x26;token=b94dd333-45a6-480d-bf78-50891096b944" alt=""><figcaption></figcaption></figure>

common service records

```
nmap --script dns-srv-enum --script-args "dns-srv-enum.domain='zonetransfer.me'"
```

{% embed url="<https://www.youtube.com/watch?v=PvDS1ZBFPwk&list=PL-Fa25Pu8l6wrp7rSDuZYRe1pbtmpEGa-&index=4&pp=gAQBiAQB>" %}

{% embed url="<https://youtu.be/sBq73tI9BKM>" %}

{% embed url="<https://www.udemy.com/course/ethical-hacker-practical/?referralCode=289CF01CF51246BCAD6C>" %}
