forked from p34709852/monkey
Fixed some bugs in HTTP fingerprinting
This commit is contained in:
parent
3226ee3f02
commit
8c9014684c
|
@ -21,24 +21,24 @@ class HTTPFinger(HostFinger):
|
||||||
def get_host_fingerprint(self, host):
|
def get_host_fingerprint(self, host):
|
||||||
assert isinstance(host, VictimHost)
|
assert isinstance(host, VictimHost)
|
||||||
from requests import get
|
from requests import get
|
||||||
from requests.exceptions import Timeout
|
from requests.exceptions import Timeout,ConnectionError
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
valid_ports = [port for port in self.HTTP if 'tcp-'+port[1] in host.services]
|
for port in self.HTTP:
|
||||||
for port in valid_ports:
|
|
||||||
# check both http and https
|
# check both http and https
|
||||||
http = "http://"+host.ip_addr+":"+port[1]
|
http = "http://"+host.ip_addr+":"+port[1]
|
||||||
https = "https://"+host.ip_addr+":"+port[1]
|
https = "https://"+host.ip_addr+":"+port[1]
|
||||||
|
|
||||||
# try http, we don't optimise for 443
|
# try http, we don't optimise for 443
|
||||||
try:
|
for url in (http, https):
|
||||||
with closing(get(http, timeout=1, stream=True)) as r_http:
|
try:
|
||||||
server = r_http.headers.get('Server')
|
with closing(get(url, verify=False, timeout=1, stream=True)) as req:
|
||||||
host.services['tcp-'+port[1]] = server
|
server = req.headers.get('Server')
|
||||||
except Timeout:
|
host.services['tcp-'+port[1]] = server
|
||||||
#try https
|
break # https will be the same on the same port
|
||||||
with closing(get(https, timeout=01, stream=True)) as r_http:
|
except Timeout:
|
||||||
server = r_http.headers.get('Server')
|
pass
|
||||||
host.services['tcp-'+port[1]] = server
|
except ConnectionError: # Someone doesn't like us
|
||||||
|
pass
|
||||||
|
|
||||||
return True
|
return True
|
Loading…
Reference in New Issue