-
Notifications
You must be signed in to change notification settings - Fork 3
/
Sub-Z.py
118 lines (99 loc) · 4.7 KB
/
Sub-Z.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
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
import requests
import re
import subprocess
from subprocess import Popen, PIPE
import os
import os.path
from os import path
from termcolor import colored
import terminal_banner
import socket
import argparse
import subprocess
import shutil
import itertools
import time
parser = argparse.ArgumentParser(description='\u001b[36mSubZ - A Subdomain Enumeration Tool \u001b[0m')
parser.add_argument('-d','--domain' , help = 'Domain name of the taget [ex : bugcrowd.com]' , required=True)
parser.add_argument('-ip', help='To get the IP address of the Subdomains',action='store_true')
parser.add_argument('-live', help='To find only live subdomains',action='store_true')
args = parser.parse_args()
banner = ("""\u001b[36m
███████╗██╗ ██╗██████╗ ███████╗
██╔════╝██║ ██║██╔══██╗ ╚══███╔╝
███████╗██║ ██║██████╔╝█████╗ ███╔╝
╚════██║██║ ██║██╔══██╗╚════╝███╔╝
███████║╚██████╔╝██████╔╝ ███████╗
╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ \u001b[0m
Made with \u001b[31m❤️\u001b[0m
For the Community, By the Community
###################################
Developed by \u001b[36mJitesh Kumar\u001b[0m
Intagram - \u001b[36mhttps://instagram.com/jitesh.haxx\u001b[0m
linkedin - \u001b[36mhttps://linkedin.com/j1t3sh\u001b[0m
Github - \u001b[36mhttps://github.com/j1t3sh\u001b[0m
( DONT COPY THE CODE. CONTRIBUTIONS ARE MOST WELCOME \u001b[31m❤️\u001b[0m )
""")
print(banner)
def subez(): #SubZ function main function
spinner=itertools.cycle(['|','/','-','\\'])
process=subprocess.Popen(".\wassetfinder.exe --subs-only " + args.domain + " | .\httprobe > " + args.domain +".txt",shell=True)
while process.poll() is None:
time.sleep(0.5)
cols=" "*(shutil.get_terminal_size((80, 20))[0]-65)
count = len(open(args.domain+".txt").read().split('\n')) - 1
print("\r[+]Searching Subdomains "+next(spinner)+ cols+ "\u001b[32mFound: "+str(count),end=''+"\u001b[0m ")
list_sub = []
new_list=[]
file1 = open(args.domain + '.txt','r')
count = 0
while True:
count +=1
line = file1.readline()
if not line:
break
list_sub.append(line)
print("\n")
for i in range(len(list_sub)):
z = str(list_sub[i])
z = re.sub("\\n$","",z)
new_list.append(z)
for q in new_list:
def ip(): #to find ip for given domains
if "https" in q:
ipaddr = q.replace("https://","")
return ipaddr
else:
ipaddr = q.replace("http://","")
return ipaddr
if args.ip:
args.ip = socket.gethostbyname(ip())
else:
args.ip = ""
if args.live:
print("[+]Scanning for only Live Subdomains....\n") #to find sudomains live
for m in new_list:
try:
response = requests.get(m)
if response.status_code == 200:
print("\u001b[32m"+m + " - " +args.ip+" :",response.status_code,response.reason+"\u001b[0m ")
except:
continue
else:
print("[+]Scanning for the Services....\n")
for m in new_list:
try:
response = requests.get(m)
if response.status_code == 200:
print("\u001b[32m"+m + " - " +args.ip+" :",response.status_code,response.reason+"\u001b[0m ")
elif(400<response.status_code<500):
print("\u001b[31m"+m+ " - " +args.ip+" :",response.status_code,response.reason+"\u001b[0m")
else:
print("\u001b[36m"+m+ " - " +args.ip+" :",response.status_code,response.reason+"\u001b[0m")
except:
continue
file1.close()
try:
subez()
except:
print("Check your Internet Connection or Try Again Later")