bot: Get domains from cert
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
a88376555d
commit
6a23b9cecd
14
bot.py
14
bot.py
@ -141,7 +141,7 @@ async def ssl(ctx, domain: str):
|
||||
await ctx.response.send_message("Please provide a valid domain to check")
|
||||
return
|
||||
|
||||
ctx.response.send_message(f"Checking SSL certificate for {domain}...")
|
||||
await ctx.response.send_message(f"Checking SSL certificate for {domain}...")
|
||||
message = ""
|
||||
resolver = dns.resolver.Resolver()
|
||||
resolver.nameservers = ["100.74.29.146"]
|
||||
@ -177,6 +177,18 @@ async def ssl(ctx, domain: str):
|
||||
certificates.append(current_cert)
|
||||
current_cert = ""
|
||||
|
||||
extracted_domains = []
|
||||
for cert in certificates:
|
||||
domain_line = [line for line in cert.split("\n") if "Subject: CN" in line]
|
||||
if domain_line:
|
||||
domain = domain_line[0].split("Subject: CN=")[1]
|
||||
extracted_domains.append(domain)
|
||||
|
||||
if extracted_domains:
|
||||
message = message + "\n## Extracted domains:\n"
|
||||
for domain in extracted_domains:
|
||||
message = message + "- " + domain + "\n"
|
||||
|
||||
# Remove anything before -----BEGIN CERTIFICATE-----
|
||||
certificates = [cert[cert.find("-----BEGIN CERTIFICATE-----"):] for cert in certificates]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user