Skip to content

DNS Lookup

CarterPerez-dev edited this page Feb 11, 2026 · 1 revision

DNS Lookup

Professional DNS reconnaissance tool for security research and network analysis.

Overview

A CLI tool that performs DNS queries, reverse lookups, resolution tracing, WHOIS lookups, and batch domain reconnaissance. Unlike simple dig wrappers, this implements concurrent async DNS queries, resolution path tracing from root servers, and structured output formatting.

Status: Complete | Difficulty: Beginner

Tech Stack

Technology Version Purpose
Python 3.13+ Async support
Typer - CLI framework
Rich - Terminal formatting
dnspython - DNS protocol operations
asyncio - Concurrent queries

Features

Core Functionality

  • Multi-type DNS record queries (A, AAAA, MX, NS, TXT, CNAME, SOA)
  • Reverse DNS lookups (IPv4 and IPv6 PTR records)
  • DNS resolution trace from root servers through TLD to authoritative nameservers
  • Batch operations with concurrent async queries
  • WHOIS domain registration lookups
  • Custom DNS server selection
  • JSON output for automation

Security Relevance

  • Reconnaissance techniques used in penetration testing
  • DNS infrastructure enumeration (MITRE T1590.002)
  • Understanding DNS hijacking (Sea Turtle, DNSpionage campaigns)
  • Detecting DNS tunneling and cache poisoning
  • Investigating suspicious domains during incident response

Architecture

User Command
    ↓
cli.py (Typer: query, reverse, trace, batch, whois)
    ↓
┌──────────────────┬──────────────────┐
│   resolver.py    │  whois_lookup.py │
│   Async DNS      │  Domain          │
│   operations     │  registration    │
│   (~400 lines)   │  details         │
└──────────────────┴──────────────────┘
    ↓
output.py (Rich formatting, ~400 lines)
    ↓
Terminal Display

Quick Start

cd PROJECTS/beginner/dns-lookup

# Install dependencies
uv sync

# Query all record types
uv run dnslookup query example.com

# Specific records with custom server
uv run dnslookup query example.com --type A,MX --server 8.8.8.8

# Trace resolution path
uv run dnslookup trace example.com

# Reverse lookup
uv run dnslookup reverse 8.8.8.8

# Batch reconnaissance
echo "example.com" > domains.txt
uv run dnslookup batch domains.txt --output results.json

# WHOIS lookup
uv run dnslookup whois example.com

Project Structure

dns-lookup/
├── src/dnslookup/
│   ├── cli.py            # Typer command interface
│   ├── resolver.py       # Core DNS logic
│   ├── output.py         # Rich terminal formatting
│   └── whois_lookup.py   # WHOIS operations
├── tests/
└── pyproject.toml

Development

# Run tests
uv run pytest tests/ -v

# Linting
uv run ruff check .

# Format
uv run ruff format .

Source Code

View on GitHub

Clone this wiki locally