From cfbd3ae18c12dd53dde7ad7f32eff9820403ccf1 Mon Sep 17 00:00:00 2001 From: Omar Santos Date: Sun, 10 Sep 2023 16:05:37 -0400 Subject: [PATCH] Create mx_record_extractor.py --- .../dns_recon/mx_record_extractor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 programming_and_scripting_for_cybersecurity/recon_scripts/dns_recon/mx_record_extractor.py diff --git a/programming_and_scripting_for_cybersecurity/recon_scripts/dns_recon/mx_record_extractor.py b/programming_and_scripting_for_cybersecurity/recon_scripts/dns_recon/mx_record_extractor.py new file mode 100644 index 0000000..c364683 --- /dev/null +++ b/programming_and_scripting_for_cybersecurity/recon_scripts/dns_recon/mx_record_extractor.py @@ -0,0 +1,16 @@ +import dns.resolver + +def get_mx_record(domain): + try: + result = dns.resolver.resolve(domain, 'MX') + for rdata in result: + print(f'MX Record: {rdata.exchange.to_text()} with priority {rdata.preference}') + except dns.resolver.NoAnswer: + print(f"No MX records found for domain {domain}") + except dns.resolver.NXDOMAIN: + print(f"The domain {domain} does not exist") + except Exception as e: + print(f"An error occurred: {e}") + +# Replace 'websploit.org' with the domain you are interested in +get_mx_record('websploit.org')