From b4f9f39fce9d09f1f9d57ed64686ff86d1be3ad4 Mon Sep 17 00:00:00 2001 From: stefan Date: Sat, 28 Dec 2024 01:39:03 +0100 Subject: [PATCH] Add python/dds-quick-test.py --- python/dds-quick-test.py | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 python/dds-quick-test.py diff --git a/python/dds-quick-test.py b/python/dds-quick-test.py new file mode 100644 index 0000000..cde2191 --- /dev/null +++ b/python/dds-quick-test.py @@ -0,0 +1,63 @@ +#!/usr/bin/python3 +import argparse +import dns.resolver + +print ("______ ___ ___ ___ ______ _____ ______ _ __ _____ ___ ___ _____ ______ ______ ") +print ("| _ \| \/ | / _ \ | ___ \/ __ \ | _ \| | / /|_ _|| \/ | / ___|| ___ \| ___|") +print ("| | | || . . |/ /_\ \| |_/ /| / \/ | | | || |/ / | | | . . | \ `--. | |_/ /| |_ ") +print ("| | | || |\/| || _ || / | | | | | || \ | | | |\/| | `--. \| __/ | _| ") +print ("| |/ / | | | || | | || |\ \ | \__/\ | |/ / | |\ \ _| |_ | | | | /\__/ /| | | | ") +print ("|___/ \_| |_/\_| |_/\_| \_| \____/ |___/ \_| \_/ \___/ \_| |_/ \____/ \_| \_| ") +print (" | _ ' _ | |_ _ ,_ |_ ") +print (" Copyright (C) 2021 Stefan Thierolf | (_| (_) | (_ |< |_ (/_ _\ |_ ") +print (" License GPLv3 | | ") +print () + + +parser = argparse.ArgumentParser(description='Simple DMARC DKIM SPF quick test.') +parser.add_argument('domain', help='Domain name to test') +parser.add_argument('selector', help='DKIM Selector, can be extracted from email') +args = parser.parse_args() +domain = args.domain +selector = args.selector + +# +# Testing DMARC +# +print() +print ("Testing domain", domain, "for DMARC record...") +try: + test_dmarc = dns.resolver.resolve('_dmarc.' + domain , 'TXT') + for dns_data in test_dmarc: + if 'DMARC1' in str(dns_data): + print (" [PASS] DMARC record found :",dns_data) +except: + print (" [FAIL] DMARC record not found.") + pass +# +# Testing DKIM +# +print() +print ("Testing domain", domain, "for DKIM record with selector", selector, "...") +try: + test_dkim = dns.resolver.resolve(selector + '._domainkey.' + domain , 'TXT') + for dns_data in test_dkim: + if 'DKIM1' in str(dns_data): + print (" [PASS] DKIM record found :",dns_data) +except: + print (" [FAIL] DKIM record not found.") + pass + +# +# Testing SPF +# +print() +print ("Testing domain", domain, "for SPF record...") +try: + test_spf = dns.resolver.resolve(domain , 'TXT') + for dns_data in test_spf: + if 'spf1' in str(dns_data): + print (" [PASS] SPF record found :",dns_data) +except: + print (" [FAIL] SPF record not found.") + pass \ No newline at end of file