|
2 | 2 | import requests
|
3 | 3 | import hashlib
|
4 | 4 | import pandas as pd
|
| 5 | +from lib.core.discovered_host import * |
5 | 6 |
|
6 | 7 | class virtual_host_scanner(object):
|
7 | 8 | """Virtual host scanning class
|
@@ -29,9 +30,14 @@ def __init__(self, target, base_host, port=80, real_port=80, ssl=False, unique_d
|
29 | 30 | self.unique_depth = unique_depth
|
30 | 31 | self.ssl = ssl
|
31 | 32 |
|
| 33 | + # this can be made redundant in future with better exceptions |
32 | 34 | self.completed_scan=False
|
| 35 | + |
| 36 | + # this is maintained until likely-matches is refactored to use new class |
33 | 37 | self.results = []
|
34 |
| - |
| 38 | + |
| 39 | + # store associated data for discovered hosts in array for oN, oJ, etc' |
| 40 | + self.hosts = [] |
35 | 41 |
|
36 | 42 | def scan(self):
|
37 | 43 | virtual_host_list = open(self.wordlist).read().splitlines()
|
@@ -65,15 +71,21 @@ def scan(self):
|
65 | 71 |
|
66 | 72 | # hash the page results to aid in identifing unique content
|
67 | 73 | page_hash = hashlib.sha256(res.text.encode('utf-8')).hexdigest()
|
68 |
| - output = '[#] Found: {} (code: {}, length: {}, hash: {})'.format(hostname, res.status_code, |
| 74 | + output = '[#] Found: {} (code: {}, length: {}, hash: {})\n'.format(hostname, res.status_code, |
69 | 75 | res.headers.get('content-length'), page_hash)
|
70 | 76 |
|
71 |
| - # print current results |
72 |
| - print(output) |
73 | 77 | for key, val in res.headers.items():
|
74 |
| - output = ' {}: {}'.format(key, val) |
75 |
| - print(output) |
76 |
| - |
| 78 | + output += ' {}: {}\n'.format(key, val) |
| 79 | + |
| 80 | + # print current results so feedback remains in "realtime" |
| 81 | + print(output) |
| 82 | + |
| 83 | + # temporary host class code |
| 84 | + host = discovered_host() |
| 85 | + host.hostname = hostname |
| 86 | + host.response_code = res.status_code |
| 87 | + self.hosts.append(host) |
| 88 | + |
77 | 89 | # add url and hash into array for likely matches
|
78 | 90 | self.results.append(hostname + ',' + page_hash)
|
79 | 91 |
|
|
0 commit comments