Created
October 6, 2019 20:20
-
-
Save cyb3rsalih/5d2388e7bcdaf9ce53975effb54b9e3c to your computer and use it in GitHub Desktop.
Basic Subdomain Lister based on https://github.com/PaulSec/crt.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
import json | |
import requests, json | |
""" | |
Unoffical cert.sh API from https://github.com/PaulSec/crt.sh | |
""" | |
class crtshAPI(object): | |
"""crtshAPI main handler.""" | |
def search(self, domain, wildcard=True): | |
base_url = "https://crt.sh/?q={}&output=json" | |
if wildcard: | |
domain = "%25.{}".format(domain) | |
url = base_url.format(domain) | |
ua = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' | |
req = requests.get(url, headers={'User-Agent': ua}) | |
if req.ok: | |
try: | |
content = req.content.decode('utf-8') | |
data = json.loads("[{}]".format(content.replace('}{', '},{'))) | |
return data | |
except Exception as err: | |
print("Error retrieving information.") | |
return None | |
""" | |
AND THIS IS MY CODE | |
""" | |
if(len(sys.argv) == 1 or len(sys.argv) > 2 ): | |
print("*"*20+"\nUSAGE\npython "+sys.argv[0]+" theSite.com\n"+"*"*20) | |
sys.exit() | |
site = sys.argv[1] | |
result = [] | |
f= open("./output_"+site+".txt","a+") | |
out =json.dumps(crtshAPI().search(site)) | |
data = json.loads(out) | |
j = data[0] | |
for i in range(len(j)): | |
result.append(json.dumps(j[i]['name_value']).strip('"')) | |
result= list(dict.fromkeys(result)) | |
for at in result: | |
#print(at) Console output | |
f.write(at+'\r\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment