-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsubreaker.py
More file actions
179 lines (137 loc) · 7.33 KB
/
subreaker.py
File metadata and controls
179 lines (137 loc) · 7.33 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Developing BY Emir Güner github: github.com/heqmat
# Modules
import time
import requests
import urllib3
import os
import sys
import urllib.request
from datetime import datetime
import signal
import threading
# Colors
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
PURPLE = '\033[90m'
CYAN = '\033[0;36;47m'
RED = "\033[1;31m"
CYAN = '\033[1;36m'
GREEN = "\033[0;32m"
RESET = "\033[0;0m"
BOLD = "\033[;1m"
REVERSE = "\033[;7m"
# Tool Version
version = 0.1
time1 = datetime.now().strftime('%H:%M:%S')
# parameters
def parse_args():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--domain', type=str, required=True, help='Target Web Domain.(Example: google.com,facebook.com,twitter.com,udemy.com)')
parser.add_argument('-o', '--output', type=str, required=False, help='Save output as file.')
return parser.parse_args()
#Check internet connection
def connecct(host='http://google.com'):
try:
urllib.request.urlopen(host) #Python 3.x
return True
except:
return False
if connecct():
print("") # have internet connection.
else:
print(bcolors.OKGREEN + f"""
▄▄▄▄▄ ▄ ███ █▄▄▄▄ ▄███▄ ██ █ █▀ ▄███▄ █▄▄▄▄
█ ▀▄ █ █ █ █ ▄▀ █▀ ▀ █ █ █▄█ █▀ ▀ █ ▄▀
▄ ▀▀▀▀▄ █ █ █ ▀ ▄ █▀▀▌ ██▄▄ █▄▄█ █▀▄ ██▄▄ █▀▀▌
▀▄▄▄▄▀ █ █ █ ▄▀ █ █ █▄ ▄▀ █ █ █ █ █▄ ▄▀ █ █
█▄ ▄█ ███ █ ▀███▀ █ █ ▀███▀ █
▀▀▀ ▀ █ ▀ ▀
▀
Subdomain Scanner - By: @heqmat - Emir Güner
Version: {version}
============================================================
Usage of Subreaker for attacking targets without prior mutual consent is illegal.
It is the end user's responsibility to obey all applicable local, state and federal laws.
Developers assume no liability and are not responsible for any misuse or damage caused by this program.
""" + bcolors.ENDC)
print("[" + bcolors.FAIL + "ERROR" + bcolors.ENDC + "] " + "You do not have an internet connection or not enough.") # dont have internet connection
print("[" + bcolors.FAIL + "ERROR" + bcolors.ENDC + "] " + "You do not have an internet connection or not enough.") # dont have internet connection
print("[" + bcolors.FAIL + "ERROR" + bcolors.ENDC + "] " + "You do not have an internet connection or not enough.") # dont have internet connection
print("Press CTRL + C to exit")
time.sleep(3600)
# Banner - Welcome page
def banner():
global version
print(bcolors.OKGREEN + f"""
▄▄▄▄▄ ▄ ███ █▄▄▄▄ ▄███▄ ██ █ █▀ ▄███▄ █▄▄▄▄
█ ▀▄ █ █ █ █ ▄▀ █▀ ▀ █ █ █▄█ █▀ ▀ █ ▄▀
▄ ▀▀▀▀▄ █ █ █ ▀ ▄ █▀▀▌ ██▄▄ █▄▄█ █▀▄ ██▄▄ █▀▀▌
▀▄▄▄▄▀ █ █ █ ▄▀ █ █ █▄ ▄▀ █ █ █ █ █▄ ▄▀ █ █
█▄ ▄█ ███ █ ▀███▀ █ █ ▀███▀ █
▀▀▀ ▀ █ ▀ ▀
▀
Subdomain Scanner - By: @heqmat - Emir Güner
Version: {version}
============================================================
Usage of Subreaker for attacking targets without prior mutual consent is illegal.
It is the end user's responsibility to obey all applicable local, state and federal laws.
Developers assume no liability and are not responsible for any misuse or damage caused by this program.
""" + bcolors.ENDC)
print(bcolors.PURPLE + "This process may take a few minutes" + bcolors.ENDC)
time.sleep(1)
def parse_url(url):
try:
host = urllib3.util.url.parse_url(url).host
except Exception as e:
print(bcolors.OKGREEN + f"""
▄▄▄▄▄ ▄ ███ █▄▄▄▄ ▄███▄ ██ █ █▀ ▄███▄ █▄▄▄▄
█ ▀▄ █ █ █ █ ▄▀ █▀ ▀ █ █ █▄█ █▀ ▀ █ ▄▀
▄ ▀▀▀▀▄ █ █ █ ▀ ▄ █▀▀▌ ██▄▄ █▄▄█ █▀▄ ██▄▄ █▀▀▌
▀▄▄▄▄▀ █ █ █ ▄▀ █ █ █▄ ▄▀ █ █ █ █ █▄ ▄▀ █ █
█▄ ▄█ ███ █ ▀███▀ █ █ ▀███▀ █
▀▀▀ ▀ █ ▀ ▀
▀
Subdomain Scanner - By: @heqmat - Emir Güner
Version: {version}
============================================================
Usage of Forgery Tool for attacking targets without prior mutual consent is illegal.
It is the end user's responsibility to obey all applicable local, state and federal laws.
Developers assume no liability and are not responsible for any misuse or damage caused by this program.
""" + bcolors.ENDC)
print("[" + bcolors.FAIL + "ERROR" + bcolors.ENDC + "]" + " Invalid domain address please try again.")
sys.exit(1)
return host
def write_subs_to_file(subdomain, output_file):
with open(output_file, 'a') as fp:
fp.write(subdomain + '\n')
fp.close()
def main():
banner()
subdomains = []
args = parse_args()
target = parse_url(args.domain)
output = args.output
req = requests.get(f'https://crt.sh/?q=%.{target}&output=json')
if req.status_code != 200:
print("[" + bcolors.FAIL + "ERROR" + bcolors.ENDC + "] " + "System not working try again please (Code: code != 200 )")
sys.exit(1)
for (key,value) in enumerate(req.json()):
subdomains.append(value['name_value'])
print("[" + bcolors.OKBLUE + "INFO" + bcolors.ENDC + "] " + f"Subreaker's Target: {target} ")
subs = sorted(set(subdomains))
for s in subs:
print("[" + bcolors.OKGREEN + "SUBDOMAIN" + bcolors.ENDC + f"] {s} " + bcolors.OKBLUE + "Subdomain was found." + bcolors.ENDC)
if output is not None:
write_subs_to_file(s, output)
print("[" + bcolors.PURPLE + "FINISH" + bcolors.ENDC + "] " + "Process is complete, all subdomains have been found.")
print(bcolors.PURPLE + f"The program was stopped at {time1}, if this is a error or not normal please let me know" + bcolors.ENDC)
if __name__=='__main__':
main()