Skip to content

Commit 4ce6cf0

Browse files
diogoosorioDiogo Osório
authored andcommitted
Make the lib/helpers/output_helper_.py adhere to the pep8 convention
1 parent 64eca91 commit 4ce6cf0

File tree

1 file changed

+65
-30
lines changed

1 file changed

+65
-30
lines changed

lib/helpers/output_helper.py

Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,40 @@ def __init__(self, scanner, arguments):
1313
self.arguments = arguments
1414

1515
def write_normal(self, filename):
16-
1716
file = file_helper(filename)
1817

1918
# todo: finish check_directory (needs regex to split out filename)
2019
# file.check_directory(filename)
2120

2221
output = self.generate_header()
2322
output += self.output_normal_likely()
24-
23+
2524
if(self.arguments.fuzzy_logic):
2625
output += self.output_fuzzy()
27-
26+
2827
output += self.output_normal_detail()
29-
28+
3029
file.write_file(output)
3130

3231
def output_normal_likely(self):
3332
uniques = False
3433
depth = str(self.scanner.unique_depth)
35-
output = "\n[+] Most likely matches with a unique count of {} or less:".format(depth)
36-
37-
for p in self.scanner.likely_matches():
34+
output = "\n[+] Most likely matches with a unique count "\
35+
"of {} or less:".format(depth)
36+
37+
for p in self.scanner.likely_matches():
3838
output += "\n\t[>] {}".format(p)
3939
uniques = True
40-
40+
4141
if(uniques):
4242
return output
4343
else:
44-
return "\n[!] No matches with a unique count of {} or less.".format(depth)
45-
44+
return "\n[!] No matches with an" \
45+
" unique count of {} or less.".format(depth)
4646

4747
def output_json(self, filename):
4848
file = file_helper(filename)
4949
output = dict()
50-
output['Start Time'] = '{} {}'.format(time.strftime("%d/%m/%Y"), time.strftime("%H:%M:%S"))
5150
output['Target'] = self.scanner.target
5251
output['Base Host'] = self.scanner.base_host
5352
output['Port'] = self.scanner.port
@@ -57,46 +56,82 @@ def output_json(self, filename):
5756
output['Wordlist'] = self.scanner.wordlist
5857
output['Unique Depth'] = self.scanner.unique_depth
5958
output['SSL'] = self.scanner.ssl
59+
output['Start Time'] = '{} {}'.format(
60+
time.strftime("%d/%m/%Y"),
61+
time.strftime("%H:%M:%S")
62+
)
63+
6064
result = dict()
6165
for host in self.scanner.hosts:
6266
headers = dict()
6367
for header in host.keys:
6468
headers[header.split(':')[0]] = header.split(':')[1].strip()
6569

66-
result[host.hostname] = {'Code': host.response_code,
67-
'Hash': host.hash,
68-
'Headers': headers}
70+
result[host.hostname] = {
71+
'Code': host.response_code,
72+
'Hash': host.hash,
73+
'Headers': headers
74+
}
75+
6976
output['Result'] = result
7077
file.write_file(json.dumps(output, indent=2))
7178

72-
7379
def output_fuzzy(self):
7480
output = "\n\n[+] Match similarity using fuzzy logic:"
7581
request_hashes = {}
76-
82+
7783
for host in self.scanner.hosts:
7884
request_hashes[host.hash] = host.content
79-
85+
8086
for a, b in itertools.combinations(request_hashes.keys(), 2):
81-
output += "\n\t[>] {} is {}% similar to {}".format(a, fuzz.ratio(request_hashes[a], request_hashes[b]), b)
82-
83-
return output
87+
output += "\n\t[>] {} is {}% similar to {}".format(
88+
a,
89+
fuzz.ratio(request_hashes[a], request_hashes[b]),
90+
b
91+
)
8492

93+
return output
8594

8695
def output_normal_detail(self):
8796
output = "\n\n[+] Full scan results"
8897

89-
for host in self.scanner.hosts:
90-
output += "\n\n{} (Code: {}) hash: {}".format(str(host.hostname), str(host.response_code), str(host.hash))
91-
for key in host.keys: output += "\n\t{}".format(key)
92-
93-
return output
98+
for host in self.scanner.hosts:
99+
output += "\n\n{} (Code: {}) hash: {}".format(
100+
str(host.hostname),
101+
str(host.response_code),
102+
str(host.hash)
103+
)
104+
105+
for key in host.keys:
106+
output += "\n\t{}".format(key)
94107

108+
return output
95109

96110
def generate_header(self):
97-
output = "VHostScanner Log: {} {}\n".format(time.strftime("%d/%m/%Y"), time.strftime("%H:%M:%S"))
98-
output += "\tTarget: {}\n\tBase Host: {}\n\tPort: {}".format(self.scanner.target, self.scanner.base_host, self.scanner.port)
99-
output += "\n\tReal Port {}\n\tIgnore HTTP Codes: {}".format(self.scanner.real_port,self.scanner.ignore_http_codes)
100-
output += "\n\tIgnore Content Length: {}\n\tWordlist: {}".format(self.scanner.ignore_content_length, self.scanner.wordlist)
101-
output += "\n\tUnique Depth: {}\n\tSSL: {}\n\t".format(self.scanner.unique_depth, self.scanner.ssl)
111+
output = "VHostScanner Log: {} {}\n".format(
112+
time.strftime("%d/%m/%Y"),
113+
time.strftime("%H:%M:%S")
114+
)
115+
116+
output += "\tTarget: {}\n\tBase Host: {}\n\tPort: {}".format(
117+
self.scanner.target,
118+
self.scanner.base_host,
119+
self.scanner.port
120+
)
121+
122+
output += "\n\tReal Port {}\n\tIgnore HTTP Codes: {}".format(
123+
self.scanner.real_port,
124+
self.scanner.ignore_http_codes
125+
)
126+
127+
output += "\n\tIgnore Content Length: {}\n\tWordlist: {}".format(
128+
self.scanner.ignore_content_length,
129+
self.scanner.wordlist
130+
)
131+
132+
output += "\n\tUnique Depth: {}\n\tSSL: {}\n\t".format(
133+
self.scanner.unique_depth,
134+
self.scanner.ssl
135+
)
136+
102137
return output

0 commit comments

Comments
 (0)