-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathdomainCollector.py
83 lines (64 loc) · 2.45 KB
/
domainCollector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import re
import sys
import os
import requests
from bs4 import BeautifulSoup
from colorama import init
from colorama import Fore, Back, Style
init()
def banner():
banner="""
_ _ ___ _ _ _
__| | ___ _ __ ___ __ _(_)_ __ / __\___ | | | ___ ___| |_ ___ _ __
/ _` |/ _ \| '_ ` _ \ / _` | | '_ \ / / / _ \| | |/ _ \/ __| __/ _ \| '__|
| (_| | (_) | | | | | | (_| | | | | | / /__| (_) | | | __/ (__| || (_) | |
\__,_|\___/|_| |_| |_|\__,_|_|_| |_| \____/\___/|_|_|\___|\___|\__\___/|_|
By: CyberGuy & BadBot
"""
print(banner)
isfile=False
def usage():
usage="""
[+] Welcome to Domain Collector tool, it's a python based tool to get the domains from the crt.sh using the organization name
[-] python3 domainCollector.py "Org+Inc" => Searching for single organization domains
[-] python3 domainCollector.py <orgList> => Searching for multiple organizations domains
"""
print(usage)
exit()
def collect(org):
print(Fore.YELLOW+ f"\nCollecting [" + Fore.RED + f"{org}" + Fore.YELLOW + "] domains\n")
domains=[]
filename=org.replace(" ", "_")+".txt"
url="https://crt.sh/?O=%25."
req=requests.get(url+org)
soup = BeautifulSoup(req.text, "html.parser")
td=soup.find_all("td")
for dom in td:
domain = re.search('([\w+\d+\-]*)\.(\w+)\.?(jp|es|ar|eu|ca|gov|is|edu|net|it|cn|eg|us|tw|au|sa|info|tr|kr)?$', dom.text.strip())
if domain:
domain = re.sub(r'^\.', '', domain.group(0))
domains.append(domain.lower())
x=set(domains)
with open(filename, "a") as out:
for i in x:
print(Fore.RED + "[+] Collected [ "+ Fore.CYAN + i + Fore.RED + " ]")
out.write(i+"\n")
out.close()
print(Fore.RED + f"\nFound => [" + Fore.CYAN + f"{len(x)}" + Fore.RED + "] domains")
print(Fore.RED + f"\nSaved in => [" + Fore.CYAN + f"{filename}" + Fore.RED + "] file")
domains=[]
def main():
if len(sys.argv)==2:
if os.path.isfile(sys.argv[1]):
isfile=True
with open(sys.argv[1]) as orgs:
for org in orgs:
collect(org.strip())
else:
collect(sys.argv[1])
else:
usage()
if __name__=="__main__":
banner()
main()
print(Fore.WHITE + f"\nHappy Hacking " + Fore.RED + ";)")