Git Product home page Git Product logo

scapy-nfqueue-dnsspoof's Introduction

Simple DNS spoof with scapy and nfqueue

Description

Intercept all dns queries, spoof the answer by requested FQDN.

It's just a simple poc to test scapy+nfqueue toghether.

Usage:

dnsSpoof -q 1 -s www.youporn.com/1.2.3.4

Requirements

  • python 2.7 (yes, I know)
  • Scapy
  • gcc compiler, netfilter headers etc...

Setup

Install packages, on a Centos/RHEL machine:

yum -y install python-pip scapy
yum -y install gcc python-devel libnfnetlink-devel libnetfilter_queue-devel libnetfilter_conntrack-devel

Install the required python modules:

pip install -r requirements.txt

Run it

Activate the spoofer:

# ./dnsSpoof.py -q 1 -s www.youporn.com/1.2.3.4
Intercepting nfqueue: 1
Spoofing www.youporn.com to 1.2.3.4
------------------------------------------

Nothing will happen right now, we've just activated the spoofer and its binding to nfqueue 1

Let's redirect all dns responses (udp and source port 53) to dnsSpoof.py:

[root@spoofmachine ~]# iptables -A INPUT -p udp  --sport 53 -j NFQUEUE --queue-num 1
[root@spoofmachine ~]# iptables -L -nv
Chain INPUT (policy ACCEPT 9 packets, 680 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 NFQUEUE    udp  --  *      *       0.0.0.0/0            0.0.0.0/0            udp spt:53 NFQUEUE num 1

Spoofing in action, but only for the target domain

[root@spoofmachine ~]# ping www.youporn.com
PING www.youporn.com (1.2.3.4) 56(84) bytes of data.

[root@spoofmachine ~]# ping www.google.com
PING www.google.com (216.58.205.132) 56(84) bytes of data.

The spoofer shows the summary of the packets (pkt.summary() scapy function):

Intercepted DNS request for www.youporn.com: IP / UDP / DNS Ans "youporn.com."
Spoofing DNS response to: IP / UDP / DNS Ans "1.2.3.4"
------------------------------------------
Intercepted DNS request for www.youporn.com: IP / UDP / DNS Ans "youporn.com."
Spoofing DNS response to: IP / UDP / DNS Ans "1.2.3.4"
------------------------------------------

Important: if you deactivate the spoofer, your system will be unable to resolve anything until you deactivate the iptables rule as well!

References

scapy-nfqueue-dnsspoof's People

Contributors

simone-zabberoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

yldzvl 5l1v3r1

scapy-nfqueue-dnsspoof's Issues

No response

I've tried it on a few machines, Debian/Centos 7 all python 2.7 and it looks like it gets to the server and it says its poisoning it but it never seems to send the response packet.

[root@computer scapy-nfqueue-dnsspoof]# python dnsSpoof.py
Intercepting nfqueue: 1
Spoofing www.youporn.com to 1.1.1.1

Intercepted DNS request for www.youporn.com: IP / UDP / DNS Qry "www.youporn.com."
Spoofing DNS response to: IP / UDP / DNS Ans "1.1.1.1"

Intercepted DNS request for www.youporn.com: IP / UDP / DNS Qry "www.youporn.com."
Spoofing DNS response to: IP / UDP / DNS Ans "1.1.1.1"

Intercepted DNS request for www.youporn.com: IP / UDP / DNS Qry "www.youporn.com."
Spoofing DNS response to: IP / UDP / DNS Ans "1.1.1.1"

and on the client it looks like this.

dig www.youporn.com

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.62.rc1.el6_9.5 <<>> www.youporn.com
;; global options: +cmd
;; connection timed out; no servers could be reached

on a packet capture you can see the packet come in but there is no response. Also I did a .show() on the spoofed packet and it appears to have the correct source/dest IP info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.