bot: Use alt hex reader
All checks were successful
Build Docker / Build Docker (push) Successful in 16s
All checks were successful
Build Docker / Build Docker (push) Successful in 16s
This commit is contained in:
parent
d3c82b6c05
commit
6cce762dd3
36
bot.py
36
bot.py
@ -8,6 +8,7 @@ import markdownify
|
|||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import re
|
import re
|
||||||
|
import binascii
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
TOKEN = os.getenv('DISCORD_TOKEN')
|
TOKEN = os.getenv('DISCORD_TOKEN')
|
||||||
@ -180,40 +181,21 @@ async def ssl(ctx, domain: str):
|
|||||||
|
|
||||||
if certificates:
|
if certificates:
|
||||||
cert = certificates[0]
|
cert = certificates[0]
|
||||||
message = message + "\n## Website Certificate:\n`" + cert + "`\n"
|
message = message + "\n## Website Certificate:\n```\n" + cert + "\n```\n"
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile(mode="w", delete=False) as temp_cert_file:
|
with tempfile.NamedTemporaryFile(mode="w", delete=False) as temp_cert_file:
|
||||||
temp_cert_file.write(cert)
|
temp_cert_file.write(cert)
|
||||||
temp_cert_file.seek(0) # Move back to the beginning of the temporary file
|
temp_cert_file.seek(0) # Move back to the beginning of the temporary file
|
||||||
|
|
||||||
tlsa_command = [
|
tlsa_command = ["openssl","x509","-in",temp_cert_file.name,"-pubkey","-noout","|","openssl","pkey","-pubin","-outform","der","|","openssl","dgst","-sha256","-binary",]
|
||||||
"openssl",
|
|
||||||
"x509",
|
|
||||||
"-in",
|
|
||||||
temp_cert_file.name,
|
|
||||||
"-pubkey",
|
|
||||||
"-noout",
|
|
||||||
"|",
|
|
||||||
"openssl",
|
|
||||||
"pkey",
|
|
||||||
"-pubin",
|
|
||||||
"-outform",
|
|
||||||
"der",
|
|
||||||
"|",
|
|
||||||
"openssl",
|
|
||||||
"dgst",
|
|
||||||
"-sha256",
|
|
||||||
"-binary",
|
|
||||||
"|",
|
|
||||||
"xxd",
|
|
||||||
"-p",
|
|
||||||
"-u",
|
|
||||||
"-c",
|
|
||||||
"32",
|
|
||||||
]
|
|
||||||
tlsa_process = subprocess.Popen(" ".join(tlsa_command), shell=True, stdout=subprocess.PIPE)
|
tlsa_process = subprocess.Popen(" ".join(tlsa_command), shell=True, stdout=subprocess.PIPE)
|
||||||
tlsa_output, _ = tlsa_process.communicate()
|
tlsa_output, _ = tlsa_process.communicate()
|
||||||
message = message + "\n## TLSA Record from webserver: `3 1 1 " + tlsa_output.decode("utf-8") + "`\n"
|
|
||||||
|
tlsa_hex = binascii.hexlify(tlsa_output).decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
message = message + "\n## TLSA Record from webserver: `3 1 1 " + tlsa_hex + "`\n"
|
||||||
await ctx.response.send_message(message)
|
await ctx.response.send_message(message)
|
||||||
else:
|
else:
|
||||||
ctx.response.send_message(f"No certificate found for {domain}")
|
ctx.response.send_message(f"No certificate found for {domain}")
|
||||||
|
Loading…
Reference in New Issue
Block a user