DNS-Sandbox is a lightweight, zero-dependency, full-stack UDP DNS Server, recursive resolver visualizer, and cache poisoning security simulator.
Instead of traditional HTTP wrappers, this project operates at the transport layer, implementing raw UDP socket networking (dgram) and low-level binary protocol parsing. It runs a functional DNS server on port 8053 and hosts an interactive SRE observability dashboard on port 8060.
-
UDP Packet Parser & Encoder (Port
8053)- Binds to a local UDP socket using Node's native
dgrammodule. - Decodes standard incoming binary DNS query headers (Transaction ID, Flag masks, QDCOUNT) and extracts domain label sequences.
- Encodes DNS answers natively into standardized binary payload answers (A, CNAME, MX, TXT) incorporating standard compression pointers (
0xc00cpointing to the question domain).
- Binds to a local UDP socket using Node's native
-
Recursive Lookup Tree Simulator
- Traces query hops dynamically when a record misses the local cache:
Client ➔ Recursive Resolver ➔ Root Name Server (.) ➔ TLD Name Server (.com) ➔ Authoritative Name Server - Simulates internet lookup latency delays at each hop and pushes real-time status updates via WebSockets.
- Traces query hops dynamically when a record misses the local cache:
-
DNS Cache Poisoning Hijacker
- Spoofs DNS caching maps: when spoofing is active, the resolver intercepts queries for targeted domains and replies with a custom malicious IP address.
- Highlights safety warning paths and alert badges in the UI, demonstrating how security exploits redirect traffic.
-
Interactive Dashboard (Port
8060)- Visual Canvas: Renders real-time vector connections and floating packet animations mapping the recursive routing paths.
- Zone Editor: Add or remove authoritative zone records in the registry.
- Local Traffic Injector: Triggers real local UDP queries from the browser loops to audit cache expirations and TTL counts.
dns-sandbox/
├── README.md # SRE guides and UDP usage instructions
├── package.json # Node.js configurations and dependencies
├── server.js # Dual Server (Console on 8060, UDP DNS Server on 8053)
├── test.js # Low-level protocol binary unit tests
├── lib/
│ ├── DnsServer.js # Packet parser, encoder, and query builder
│ ├── CacheManager.js # Cache DB holding active TTL countdowns
│ ├── Registry.js # Authoritative zone records registry
│ └── PoisonEngine.js # Cache poisoning redirect exploit engine
└── public/
├── index.html # Observability control portal
├── css/
│ └── styles.css # Cyber-glassmorphism styles
└── js/
├── app.js # Main dashboard coordinator
├── dns-visual.js # Canvas packet path animator
└── charts.js # Live metrics accumulator
- Node.js: Version 18+ (tested on Node v20/v24).
npm installVerify binary encoders/decoders and cache decay logic:
npm testnpm startOpen your web browser and navigate to: http://localhost:8060/index.html
You can query your custom DNS server directly from your machine's command line using standard networking tools:
nslookup -port=8053 google.com 127.0.0.1dig @127.0.0.1 -p 8053 google.com AObserve how the CLI outputs the authoritative IP and the visual dashboard instantly highlights the packet flow client-to-resolver and counts the resolution latency!