forked from queercat/BannerGrab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHULK-Grabber(Mark-4).py
56 lines (48 loc) · 1.7 KB
/
HULK-Grabber(Mark-4).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
import socket
import requests
logo = '''
__ ____ ____ __ __ ______ __ __
/ / / / / / / / / //_/ / ____/________ _/ /_ / /_ ___ _____
/ /_/ / / / / / / ,< / / __/ ___/ __ `/ __ \/ __ \/ _ \/ ___/
/ __ / /_/ / /___/ /| | / /_/ / / / /_/ / /_/ / /_/ / __/ /
/_/ /_/\____/_____/_/ |_| \____/_/ \__,_/_.___/_.___/\___/_/
coded by Sumalya Chatterjee
'''
print(logo)
def get_headers(url):
resp = ''
if url.startswith('http') or url.startswith('https'):
pass
else:
url = 'http://'+url
try:
resp = requests.get(url)
return (80, resp.headers)
except requests.exceptions.MissingSchema as e:
print(e)
return None
def grab_banner(target: str, port: int, timeout=10.0):
if port == 80:
return get_headers(target)
s = socket.socket()
try:
if target.startswith('http'):
target = target.split("//")[1]
s.connect((target, port))
s.settimeout(timeout) # stop connection
banner = str(s.recv(1024).strip('b'))
return (port, banner)
except Exception as e:
print(e)
return s.close()
def main(ports: list, target: str):
banners = []
for port in ports:
banner = grab_banner(target, int(port))
if banner:
banners.append(banner)
print(f"Target : {target}")
print("Banners: ", banners)
ports = input("Enter ports (seperated by ,) > ").split(",")
target = input("Enter target URL or domain > ")
main(ports, target)