-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirtualhost.py
37 lines (30 loc) · 1.06 KB
/
virtualhost.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
import requests
from testsbase import testsbase
from numpy import mean
class virtualhost(testsbase):
"""
Virtual hosting testing class
"""
def __init__(self, config):
super().__init__(config)
def run(self):
test_list = [self.test1, self.test2, self.test3]
results = []
for vh in self.config['server'][1:]:
print("testing vs {}".format(vh))
# r.append(super().run(vh))
results.append(super().run(tests=test_list, vh=vh, testfile='index.html'))
return mean(results)
def test1(self):
""" unknown domain """
headers = {'host': 'google.com'}
response = requests.get(self.url, headers=headers)
return ((response.status_code == 404)
and ('REQUESTED DOMAIN NOT FOUND' in response.text.upper()))
def test2(self):
""" GET file, check sha254 """
response = self.get
return self.check_byhash(response)
def test3(self):
""" HOST header routing """
return self.domain in self.get.text