Skip to main content

dns-spoofer

Send spoofed DNS queries over UDP.

Installation

pip install git+https://github.com/kimbo/dns-spoofer.git

That will install two scripts

  • dns-spoof - send DNS queries with a different source port and source IP address than your own.
  • dns-listen - listen for and print UDP packets (i.e. DNS queries) on a port and address

Quick example

This will be a little bit cooler if you have access to two different computers on the same network, but it'll work just the same on just one.

Step #1:

Open up a terminal and run:

$ dns-listen 53535
Listening on port 53535 and address ...

You can replace 53535 with whatever port number you want (I'd recommend one bigger than 1024).

Note that the address is blank (meaning we're listening on all addresses).

If you have two computers, take note of the first computer's IP address (look into ip addr, or ifconfig if you're on a Mac)

Step #2

If you have two computers, you'll need the IP address from your first machine here:

$ dns-spoof example.com 1.1.1.1 --sport 53535 --src-addr <IP-address-here>

Otherwise, if you're doing this on one computer, run:

$ dns-spoof example.com 1.1.1.1 --sport 53535

Your output after running dns-spoof should look something like this:

(query) 192.168.0.25#53535 --> 1.1.1.1#53, "example.com" type "A"

### QUERY TIME: 0.00028133392333984375

Soon after running dns-spoof, look at the terminal you were running dns-listen on. It should have printed out something like this:

Got 45 bytes from ('1.1.1.1', 53)
id 62725
opcode QUERY
rcode NOERROR
flags QR RD RA
;QUESTION
example.com. IN A
;ANSWER
example.com. 3574 IN A 93.184.216.34
;AUTHORITY
;ADDITIONAL

Congratulations! You just sent a spoofed DNS query :smile:

Usage for dns-spoof

$ dns-spoof -h
usage: dns-spoof [-h] [--dport DST_PORT] [--src-addr SRC_ADDR]
                 [--sport SRC_PORT] [-t RDTYPE] [-n NUM_QUERIES]
                 qname dst_addr

positional arguments:
  qname
  dst_addr              The address to send the DNS query to

optional arguments:
  -h, --help            show this help message and exit
  --dport DST_PORT, --destintaion-port DST_PORT
  --src-addr SRC_ADDR, --source-address SRC_ADDR
  --sport SRC_PORT, --source-port SRC_PORT
  -t RDTYPE, --rdtype RDTYPE
  -n NUM_QUERIES, --num-queries NUM_QUERIES

Usage for dns-listen

$ dns-listen -h
usage: dns-listen [-h] [--addr ADDRESS] port

positional arguments:
  port

optional arguments:
  -h, --help            show this help message and exit
  --addr ADDRESS, --address ADDRESS

Disclaimers

  • I've only tested this from behind a NAT
  • Only works with UDP and IPv4
  • I'm not responsible for what you do with this.

License

see LICENSE

Release files for dns-spoofer 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dns-spoofer 1.0
File Size Uploaded
dns-spoofer-1.0.tar.gz 4.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for dns-spoofer 1.0
File Interpreter ABI Platform
dns_spoofer-1.0-py3.7.egg Legacy Egg format - - Details
dns_spoofer-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.4 kB

Release files / dns-spoofer-1.0.tar.gz

Download URL dns-spoofer-1.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8681441b8544cca92c114558511a98b82762e08fbc4f21070296b7801285663a
BLAKE2b-256 checksum
How to use checksums
ef115df8c2a515c4bf491d9d5b718f5b527db4c550c029dbaac51240dfc12e91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.0

Release files / dns_spoofer-1.0-py3.7.egg

Download URL dns_spoofer-1.0-py3.7.egg
Size 8.7 kB
Tags Egg
SHA-256 checksum
How to use checksums
f643afca3c8fe045052ba0a0564dd56a3aefa65488adc78d8355e3448fb60d7a
BLAKE2b-256 checksum
How to use checksums
f5d83effebfed66b39408aaaff6f4ef5923291eca4ab6a2128dbbf913ecd6ddc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.0

Release files / dns_spoofer-1.0-py3-none-any.whl

Download URL dns_spoofer-1.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
271753be9bb36bb6275a63eef7a8c70e411a316afb0158e73b735d6079f2500b
BLAKE2b-256 checksum
How to use checksums
1a2eb0c4e3b292b6ba711df2dc897bcfc6a55d0c1f1334537be9b01068996daa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.0

Release history Release notifications | RSS feed

This release

1.0 This release

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page