⚠️ For authorized penetration testing, CTF challenges, and security research ONLY. Using this tool against systems you do not own or have explicit written permission to test may violate local, national, and international laws. The authors accept no liability.
IamDNS is a modular, multi-threaded DNS spoofing framework built on top of Scapy. It performs a full ARP-poisoning MITM attack to intercept DNS traffic from a target host, injects crafted DNS responses to redirect specified domains to attacker-controlled IPs, and forwards all other traffic transparently.
Target Host ──ARP poison──► Attacker (IamDNS) ──forward──► Gateway / Internet
↑ sniffs DNS queries
│ injects spoofed answers
└ forwards non-matched queries
| Feature | Details |
|---|---|
| ARP Poisoning | Bi-directional ARP cache poisoning (target + gateway) |
| DNS Interception | BPF-filtered sniff of UDP/53 from the target only |
| Domain Matching | Exact match + wildcard prefix (*.example.com) |
| Rules File | Load domain=ip rules from a plain-text file |
| Inline Rules | Pass rules directly via --spoof CLI flag |
| Config File | INI-style config file (--config config.ini) |
| Network Scan | ARP sweep of local /24 to enumerate hosts |
| Live Stats | Periodic dashboard: ARP count, DNS spoofed/forwarded, top domains |
| pcap Export | Save spoofed packets to .pcap for analysis in Wireshark |
| ARP Restoration | Automatically restores target & gateway ARP tables on exit |
| IP Forwarding | Auto-enables (and restores) Linux IP forwarding |
| Signal Handling | Clean SIGINT/SIGTERM shutdown |
| Privilege Check | Aborts early if not running as root/Administrator |
- Python 3.8+
- Root / Administrator privileges (raw socket access)
- Linux (primary), macOS, Windows (see notes)
pip install -r requirements.txt| Package | Purpose |
|---|---|
scapy |
Packet crafting, ARP, DNS, sniffing |
netifaces |
Interface IP/gateway discovery |
tabulate |
Pretty-printed scan results |
git clone https://github.com/youruser/IamDNS
cd IamDNS
pip install -r requirements.txtsudo python3 iamDNS.py -i eth0 -t 192.168.1.50 -g 192.168.1.1 \
--spoof example.com=10.10.10.1sudo python3 iamDNS.py -i eth0 -t 192.168.1.50 \
--spoof '*.bank.com=192.168.1.99' 'update.corp.local=192.168.1.20'sudo python3 iamDNS.py -i eth0 -t 192.168.1.50 --rules dns_rules.txtsudo python3 iamDNS.py -i eth0 --scan -t 192.168.1.50 --rules dns_rules.txt -vsudo python3 iamDNS.py -i eth0 -t 192.168.1.50 --rules dns_rules.txt \
--pcap capture.pcapsudo python3 iamDNS.py --config config.iniFor a high-fidelity, interactive experience, IamDNS includes a real-time web dashboard.
- Live Activity Charts: Real-time visualization of ARP and DNS spoofing rates.
- Interactive Network Scanner: Visual radar for host discovery.
- Dynamic Rules Management: Add/remove spoofing rules without restarting.
- Packet Log: Integrated terminal-style view of all intercepted traffic.
- Emergency Stop: One-click restoration of all network tables.
chmod +x start_dashboard.sh
./start_dashboard.shThen navigate to: http://localhost:5000
usage: iamDNS [-h] [--config FILE] [-i IFACE] [-t IP] [-g IP]
[--spoof DOMAIN=IP [DOMAIN=IP ...]] [--rules FILE]
[--scan] [--arp-interval SECS] [--stats-interval SECS]
[--no-restore-forward] [-v] [--pcap FILE] [--log-file FILE]
Network:
-i, --iface IFACE Network interface (e.g. eth0, wlan0)
-t, --target IP Target host IP address
-g, --gateway IP Gateway IP (auto-detected if omitted)
DNS Spoofing Rules:
--spoof DOMAIN=IP Inline rules: --spoof example.com=1.2.3.4
--rules FILE Rules file (one domain=ip per line)
Behaviour:
--scan ARP-scan the /24 subnet before starting
--arp-interval SECS ARP re-send interval (default: 2.0)
--stats-interval SECS Stats print interval (default: 10.0)
--no-restore-forward Skip disabling IP forwarding on exit
Output:
-v, --verbose Debug output
--pcap FILE Save spoofed packets to pcap
--log-file FILE Write log to file
dns_rules.txt — one rule per line:
# Comments start with '#'
example.com=192.168.1.10
*.corp.local=10.0.0.5
login.phishme.fake=192.168.1.99
[iamDNS]
iface = eth0
target = 192.168.1.50
gateway = 192.168.1.1
rules = dns_rules.txt
arp_interval = 2.0
stats_interval = 10.0
verbose = false
scan = falseEvery --stats-interval seconds (default: 10 s), IamDNS prints a dashboard:
── IamDNS Live Stats ──────────────────────────────
Uptime : 42.3s
ARP packets : 84
DNS captured : 17
DNS spoofed : 12
DNS forwarded : 5
Top spoofed domains:
example.com 12 hits
───────────────────────────────────────────────────
IamDNS resolves the MAC addresses of both the target and the gateway via ARP. It then repeatedly sends forged ARP replies:
- To target: "the gateway's IP is at my MAC"
- To gateway: "the target's IP is at my MAC"
This routes all target↔internet traffic through the attacker.
Scapy's sniff() with a BPF filter (src host <target> and udp port 53) captures all DNS queries leaving the target.
Each queried FQDN is tested against the configured rules:
- Exact match:
example.com - Wildcard prefix:
*.example.comcatchessub.example.com,www.example.com, etc.
For matched queries, a crafted DNS A-record response is injected:
qr=1(response),aa=1(authoritative), TTL=300- Source IP/MAC spoofed to appear as the target's real DNS server
Non-matched DNS queries are counted and forwarded via the normal IP-forwarding path (enabled automatically on Linux).
On Ctrl-C or SIGTERM:
- ARP poisoner stops → sends 5× genuine ARP replies to restore tables
- DNS spoofer stops → writes any buffered pcap
- IP forwarding is disabled (restored)
- Final statistics printed
| Platform | Status | Notes |
|---|---|---|
| Linux | ✅ Full support | Auto IP-forwarding, BPF, raw sockets |
| macOS | Manual sysctl -w net.inet.ip.forwarding=1 required |
|
| Windows | Npcap required; IP forwarding not managed |
The core packet engine. Used for:
srp()— ARP resolution and network scanningsendp()— Layer-2 packet injectionsniff()— Live packet capture with BPF filtersARP,Ether,IP,UDP,DNS,DNSQR,DNSRR— Packet layers
Used to query interface addresses and default gateway without shelling out to ip route.
Optional — renders the ARP scan results as a formatted table. If not installed, a plain-text fallback is used.
- Privilege requirements are enforced at startup via
os.geteuid(). - Input validation is applied to all IPs (via
ipaddress), interfaces, domains, and file paths before use. - ARP restoration guarantees the network is left in a clean state even if the process crashes (via
SIGTERMhandler). - IP forwarding is only enabled while the tool runs and is disabled on exit (unless
--no-restore-forward).
MIT — see LICENSE.