From d0161776a6947b217a0e12e3e823c1402515566e Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Sat, 15 Jan 2022 19:20:41 -0600 Subject: [PATCH] Added optional domain intercepting --- main.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/main.py b/main.py index 6bfa25e..bca3b70 100755 --- a/main.py +++ b/main.py @@ -6,6 +6,11 @@ import dns.query import dns.message import netifaces import os +import argparse +parser = argparse.ArgumentParser(description='a DoT Proxy resolver.') +parser.add_argument('-r',action="store_true", help='Optional: Disable request intercepting') +args = parser.parse_args() +print(args) listeningIPs = [] print("DoT (DNS over TLS) Proxy resolver - ") # ASCII Art because why not @@ -74,26 +79,26 @@ except: print("Detected posix environment. Linux requires root privleges to open port 53") exit() #server.start_thread() + # Query upstream DoH server def DoTquery(domain, query_type): - #response = pythonDoh.client.query(str(domain), type=str(query_type), server="calebfontenot.com", verbose=True, fallback=False) - if "nintendowifi.net." in str(domain): - print(bcolors.FAIL+"Intercepted query!"+bcolors.RESET) - return ["172.104.88.237"] + if args.r == True: + if "nintendowifi.net." in str(domain): + print(bcolors.FAIL+"Intercepted query!"+bcolors.RESET) + return ["172.104.88.237"] + q = dns.message.make_query(str(domain), str(query_type)) + response = dns.query.tls(q, "74.80.18.217", server_hostname="calebfontenot.com", port=853) + print(response) + # There's probably a better way of doing this, but I can't figure it out... + if str(query_type) == "A": + IP = regex4.findall(str(response.answer)) + print(bcolors.OK+"IP is", str(IP[0])+bcolors.RESET) + elif str(query_type) == "AAAA": + IP = regex6.findall(str(response.answer)) + #print("Not implemented yet!") else: - q = dns.message.make_query(str(domain), str(query_type)) - response = dns.query.tls(q, "74.80.18.217", server_hostname="calebfontenot.com", port=853) - print(response) - # There's probably a better way of doing this, but I can't figure it out... - if str(query_type) == "A": - IP = regex4.findall(str(response.answer)) - print(bcolors.OK+"IP is", str(IP[0])+bcolors.RESET) - elif str(query_type) == "AAAA": - IP = regex6.findall(str(response.answer)) - #print("Not implemented yet!") - else: - print(bcolors.FAIL+"Queries beyond A or AAAA are not implemented"+bcolors.RESET) - return IP + print(bcolors.FAIL+"Queries beyond A or AAAA are not implemented"+bcolors.RESET) + return IP #server.start_thread() server.start()