-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.py
More file actions
167 lines (143 loc) · 5.36 KB
/
run.py
File metadata and controls
167 lines (143 loc) · 5.36 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
#!/usr/bin/python3
import requests
import socket
from colorama import init
from termcolor import colored
import os
init()
logo=(
"""
▁ ▂ ▄ ▅ ▆ ▇ █ 🎀 【 AltSub 】 🎀 █ ▇ ▆ ▅ ▄ ▂ ▁
Developed By : Jimmi Simon
linkedin - https://www.linkedin.com/in/jimmisimon/
Site - http://jimmisimon.in/projects.php
"""
)
print(logo)
def main():
print(colored('File Should Not Contain http:// or https:// ','white','on_red'))
fname = input("Enter file name : ")
if os.path.exists(fname) == True:
with open(fname, 'r') as f:
str1 = "http://";str2 = "https://"
http ="http";https="https";both="both"
if str1 in f.read():
print(colored("File Have [ http:// ] or [ https:// ] remove that and try again",'white','on_red'))
elif str2 in f.read():
print(colored("File Have [ https:// ] or [ https:// ] remove that and try again",'white','on_red'))
else:
method = input("Enter The Method You Want to search http/https/both : ")
num_lines = 0
with open(fname, 'r') as f:
for line in f:
num_lines += 1
total_counts=num_lines
with open(fname) as f:
content = f.readlines()
content = [x.strip() for x in content]
print("")
print('{:<50} {:<10} {:<20} {:<20}'.format("Host_Address","Status","Server","IP_Address"))
print('{:<50} {:<10} {:<20} {:<20}'.format("------------","------","------","----------"))
if method == http:
for i in range(total_counts):
try:
ip = socket.gethostbyname(content[i])
url = "http://"+content[i]
req = requests.get(url)
code = req.status_code
if req:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'green'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'green'))
else:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'yellow'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'yellow'))
except KeyboardInterrupt:
exit()
except:
continue
print(colored("Completed Happy Hunting....",'white'))
elif method == https:
for i in range(total_counts):
try:
ip = socket.gethostbyname(content[i])
url = "https://"+content[i]
req = requests.get(url)
code = req.status_code
if req:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'green'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'green'))
else:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'yellow'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'yellow'))
except KeyboardInterrupt:
exit()
except:
continue
print(colored("Completed Happy Hunting....",'white'))
elif method == both:
for i in range(total_counts):
def http1():
try:
ip = socket.gethostbyname(content[i])
url = "http://"+content[i]
req = requests.get(url)
code = req.status_code
if req:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'green'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'green'))
else:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'yellow'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'yellow'))
except KeyboardInterrupt:
exit()
except:
return 0
def http2():
try:
ip = socket.gethostbyname(content[i])
url = "https://"+content[i]
req = requests.get(url)
code = req.status_code
if req:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'green'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'green'))
else:
if "server" in req.headers:
server = req.headers['server']
print(colored('{:<50} {:<10} {:<20} {:<20}'.format(url,code,server,ip),'yellow'))
else:
print(colored('{:<50} {:<10} {:>34}'.format(url,code,ip),'yellow'))
except KeyboardInterrupt:
exit()
except:
return 0
http1()
http2()
print(colored("Completed Happy Hunting....",'white'))
else:
print("Enter Correct Option")
else:
print("File Not Found")
if __name__== "__main__":
main()