forked from p34709852/monkey
PEP8
This commit is contained in:
parent
8c9014684c
commit
4f1dfb4016
|
@ -1,18 +1,14 @@
|
||||||
import re
|
|
||||||
from network import HostFinger
|
from network import HostFinger
|
||||||
from network.tools import check_port_tcp
|
|
||||||
from model.host import VictimHost
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class HTTPFinger(HostFinger):
|
class HTTPFinger(HostFinger):
|
||||||
'''
|
"""
|
||||||
Goal is to recognise HTTP servers, where what we currently care about is apache.
|
Goal is to recognise HTTP servers, where what we currently care about is apache.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._config = __import__('config').WormConfiguration
|
self._config = __import__('config').WormConfiguration
|
||||||
self.HTTP = [(port,str(port)) for port in self._config.HTTP_PORTS]
|
self.HTTP = [(port, str(port)) for port in self._config.HTTP_PORTS]
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _banner_match(service, host, banner):
|
def _banner_match(service, host, banner):
|
||||||
|
@ -21,24 +17,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,ConnectionError
|
from requests.exceptions import Timeout, ConnectionError
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
for port in self.HTTP:
|
for port in self.HTTP:
|
||||||
# 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
|
||||||
for url in (http, https):
|
for url in (http, https):
|
||||||
try:
|
try:
|
||||||
with closing(get(url, verify=False, timeout=1, stream=True)) as req:
|
with closing(get(url, verify=False, timeout=1, stream=True)) as req:
|
||||||
server = req.headers.get('Server')
|
server = req.headers.get('Server')
|
||||||
host.services['tcp-'+port[1]] = server
|
host.services['tcp-' + port[1]] = server
|
||||||
break # https will be the same on the same port
|
break # https will be the same on the same port
|
||||||
except Timeout:
|
except Timeout:
|
||||||
pass
|
pass
|
||||||
except ConnectionError: # Someone doesn't like us
|
except ConnectionError: # Someone doesn't like us
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue