-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttpstatus.py
36 lines (30 loc) · 901 Bytes
/
httpstatus.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
import http.client as hc
host = input("Inserisci host/IP del sistema target: ")
port = input("Inserisci la porta del sistema target (default: 80 http/443 https): ")
path = '/'
https = False
if(host.startswith('https://')):
https = True
if (port == ""): port = 443
host = host.replace('https://', '')
else:
host = host.replace('http://', '')
if(port == ""): port = 80
pc = host.split("/")
if(len(pc) > 1):
host = pc[0]
del pc[0]
path = "/" + "/".join(pc)
print(path)
try:
connection = ""
if (https):
connection = hc.HTTPSConnection(host, port)
else:
connection = hc.HTTPConnection(host, port)
connection.request('OPTIONS', path)
response = connection.getresponse()
print(f"i metodi abilitati sono: {response.getheader('Allow')}")
connection.close()
except ConnectionRefusedError:
print("connessione fallita")