Vai al contenuto

__FRONTMATTER_78_# DNSx DNS Toolkit Cheat Sheet

Panoramica

DNSx è un toolkit DNS veloce e multiuso sviluppato da Project Discovery che permette di eseguire più sonde DNS utilizzando la libreria retryabledns. È progettato per eseguire varie query DNS con un focus sulla velocità e l'affidabilità. DNSx può gestire più tipi di record DNS e supporta risolutori personalizzati, rendendolo uno strumento versatile per la ricognizione e l'enumerazione DNS.

Ciò che distingue DNSx da altri strumenti DNS è la sua capacità di elaborare un gran numero di domini in modo efficiente e le sue capacità di integrazione con altri strumenti di sicurezza. Può filtrare i record DNS di wildcard, eseguire la camminata DNS ed estrarre preziose informazioni dalle risposte DNS. DNSx è comunemente usato nella fase di ricognizione delle valutazioni di sicurezza per raccogliere informazioni sui domini target e sulla loro infrastruttura.

DNSx supporta vari formati di input e può essere facilmente integrato con altri strumenti in una pipeline, rendendolo un componente essenziale in molti flussi di lavoro di test di sicurezza. La sua capacità di filtrare i risultati in base a vari criteri aiuta i professionisti della sicurezza a concentrarsi sugli obiettivi più rilevanti.

Installazione

Using Go

# Install using Go (requires Go 1.20 or later)
go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest

# Verify installation
dnsx -version

Using Docker

# Pull the latest Docker image
docker pull projectdiscovery/dnsx:latest

# Run DNSx using Docker
docker run -it projectdiscovery/dnsx:latest -h

Using Homebrew (macOS)

# Install using Homebrew
brew install dnsx

# Verify installation
dnsx -version

Using PDTM (Project Discovery Tools Manager)

# Install PDTM first if not already installed
go install -v github.com/projectdiscovery/pdtm/cmd/pdtm@latest

# Install DNSx using PDTM
pdtm -i dnsx

# Verify installation
dnsx -version

On Kali Linux

# Install using apt
sudo apt install dnsx

# Verify installation
dnsx -version

Uso di base

DNS Lookups

# Perform A record lookup for a single domain
dnsx -d example.com -a

# Perform A record lookup for multiple domains
dnsx -d example.com,hackerone.com -a

# Perform A record lookup from a list of domains
dnsx -l domains.txt -a

# Perform A record lookup from STDIN
cat domains.txt|dnsx -a

Tipi di registrazione

# Query A records (IPv4 addresses)
dnsx -l domains.txt -a

# Query AAAA records (IPv6 addresses)
dnsx -l domains.txt -aaaa

# Query CNAME records (Canonical names)
dnsx -l domains.txt -cname

# Query NS records (Name servers)
dnsx -l domains.txt -ns

# Query TXT records (Text records)
dnsx -l domains.txt -txt

# Query MX records (Mail exchange servers)
dnsx -l domains.txt -mx

# Query SOA records (Start of authority)
dnsx -l domains.txt -soa

# Query PTR records (Pointer records)
dnsx -l domains.txt -ptr

# Query multiple record types
dnsx -l domains.txt -a -cname -ns

Opzioni di uscita

# Save results to a file
dnsx -l domains.txt -a -o results.txt

# Output in JSON format
dnsx -l domains.txt -a -json -o results.json

# Output in CSV format
dnsx -l domains.txt -a -csv -o results.csv

# Silent mode (only results)
dnsx -l domains.txt -a -silent

Uso avanzato

Configurazione del solvente

# Use specific DNS resolvers
dnsx -l domains.txt -a -resolver 1.1.1.1,8.8.8.8

# Use resolvers from a file
dnsx -l domains.txt -a -resolver-file resolvers.txt

# Use system resolvers
dnsx -l domains.txt -a -system-resolver

Response Filtering

# Filter by response containing specific string
dnsx -l domains.txt -a -resp-only -resp "1.2.3.4"

# Filter by response matching regex
dnsx -l domains.txt -a -resp-only -resp-regex "^1\.2\.[0-9]+\.[0-9]+$"

Wildcard Filtering

# Enable wildcard filtering
dnsx -l domains.txt -a -wildcard

# Set wildcard threshold
dnsx -l domains.txt -a -wildcard-threshold 5

DNS Walking

# Enable DNS walking
dnsx -l domains.txt -a -walk

# Set DNS walking threads
dnsx -l domains.txt -a -walk -walk-threads 20

Ottimizzazione delle prestazioni

Concurrency and Rate Limiting

# Set concurrency (default: 100)
dnsx -l domains.txt -a -c 200

# Set rate limit
dnsx -l domains.txt -a -rate-limit 100

# Set retries
dnsx -l domains.txt -a -retries 3

Opzioni timeout

# Set timeout for DNS queries (milliseconds)
dnsx -l domains.txt -a -timeout 5000

Ottimizzazione per grandi scansioni

# Use stream mode for large inputs
dnsx -l large-domains.txt -a -stream

# Increase concurrency for faster scanning
dnsx -l domains.txt -a -c 500

Integrazione con altri strumenti

Pipeline with Subfinder

# Find subdomains and resolve them
subfinder -d example.com -silent|dnsx -a -silent

# Find subdomains and check for specific record types
subfinder -d example.com -silent|dnsx -a -cname -silent

Pipeline con HTTPX

# Resolve domains and probe for HTTP services
dnsx -l domains.txt -a -silent|httpx -silent

# Resolve domains, filter by IP, and probe for HTTP services
dnsx -l domains.txt -a -silent -resp "1.2.3.4"|httpx -silent

Pipeline with Naabu

# Resolve domains and scan for open ports
dnsx -l domains.txt -a -silent|naabu -silent

# Resolve domains, filter by IP, and scan for open ports
dnsx -l domains.txt -a -silent -resp "1.2.3.4"|naabu -silent

Personalizzazione dell'uscita

Formato di uscita personalizzato

# Output only domain and IP
dnsx -l domains.txt -a -resp-only

# Output with additional information
dnsx -l domains.txt -a -json

# Count unique IPs
dnsx -l domains.txt -a -resp-only|sort -u|wc -l

# Sort output by IP
dnsx -l domains.txt -a -resp-only|sort -t ' ' -k2

Filtro dell'uscita

# Filter by IP
dnsx -l domains.txt -a -resp-only|grep "1.2.3.4"

# Filter by domain
dnsx -l domains.txt -a -resp-only|grep "example.com"

# Find unique IPs
dnsx -l domains.txt -a -resp-only|awk '\\\\{print $2\\\\}'|sort -u

Filtro avanzato

Filtro IP

# Filter by specific IP
dnsx -l domains.txt -a -resp-only -resp "1.2.3.4"

# Filter by IP range
dnsx -l domains.txt -a -resp-only -resp-regex "^1\.2\.3\.[0-9]+$"

Domain Filtering

# Filter by domain pattern
dnsx -l domains.txt -a -resp-only|grep "api"

# Filter by specific TLD
dnsx -l domains.txt -a -resp-only|grep "\.com$"

CNAME Filtro

# Find domains with specific CNAME
dnsx -l domains.txt -cname -resp-only -resp "cdn.example.com"

# Find domains with CNAME pointing to specific services
dnsx -l domains.txt -cname -resp-only -resp-regex "amazonaws\.com$"

Miscellaneous # Caratteristiche

Reverse DNS Lookup

# Perform reverse DNS lookup
dnsx -l ips.txt -ptr

# Perform reverse DNS lookup with response filtering
dnsx -l ips.txt -ptr -resp-only -resp "example.com"

DNS Traccia

# Perform DNS trace
dnsx -d example.com -trace

# Perform DNS trace with specific resolver
dnsx -d example.com -trace -resolver 1.1.1.1

Health Check

# Check resolver health
dnsx -hc -resolver 1.1.1.1,8.8.8.8

# Check resolver health with timeout
dnsx -hc -resolver 1.1.1.1,8.8.8.8 -timeout 5000

Risoluzione dei problemi

Questioni comuni

  1. Resolver Issues

    Traduzione:

  2. ** Problemi di timeout** Traduzione:

  3. ♪Rate Limits ♪ Traduzione:

  4. ** Problemi di memoria ** Traduzione:

Debugging

# Enable verbose mode
dnsx -l domains.txt -a -v

# Show debug information
dnsx -l domains.txt -a -debug

# Show statistics
dnsx -l domains.txt -a -stats

Configurazione

Configuration File

DNSx utilizza un file di configurazione situato in $HOME/.config/dnsx/config.yaml. È possibile personalizzare varie impostazioni in questo file:

# Example configuration file
concurrency: 100
rate-limit: 100
retries: 3
timeout: 5000
resolvers:
  - 1.1.1.1
  - 8.8.8.8

Variabili ambientali

# Set DNSx configuration via environment variables
export DNSX_CONCURRENCY=100
export DNSX_RATE_LIMIT=100
export DNSX_RETRIES=3
export DNSX_TIMEOUT=5000
export DNSX_RESOLVERS=1.1.1.1,8.8.8.8

Riferimento

Opzioni di riga di comando

Tabella_79_

Tipi di registrazione

Tabella_80_

Risorse


*Questo foglio di scacchi fornisce un riferimento completo per l'utilizzo di DNSx, dalle query DNS di base al filtraggio avanzato e l'integrazione con altri strumenti. Per le informazioni più aggiornate, consultare sempre la documentazione ufficiale. *