bot: Check TLSA from dns
All checks were successful
Build Docker / Build Docker (push) Successful in 16s

This commit is contained in:
Nathan Woodburn 2023-09-27 17:47:57 +10:00
parent 6cce762dd3
commit d1daee5d02
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

17
bot.py
View File

@ -192,10 +192,23 @@ async def ssl(ctx, domain: str):
tlsa_process = subprocess.Popen(" ".join(tlsa_command), shell=True, stdout=subprocess.PIPE)
tlsa_output, _ = tlsa_process.communicate()
tlsa_hex = binascii.hexlify(tlsa_output).decode("utf-8")
tlsa_server = binascii.hexlify(tlsa_output).decode("utf-8")
message = message + "\n## TLSA Record from webserver:\n`3 1 1 " + tlsa_server + "`\n"
# Check for TLSA record
response = resolver.resolve("_443._tcp."+domain, "TLSA")
tlsa_records = []
message = message + "\n## TLSA Records:\n"
for record in response:
tlsa_records.append(str(record))
message = message + "- " +str(record) + "\n"
if not tlsa_records:
message = message + "\n## TLSA Record not found\n"
message = message + "\n## TLSA Record from webserver: `3 1 1 " + tlsa_hex + "`\n"
await ctx.response.send_message(message)
else:
ctx.response.send_message(f"No certificate found for {domain}")