-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·50 lines (40 loc) · 1.52 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
from printingtools import res_print, FAIL, ENDC, FAINT, color_test, WARNING
from infofetch import Info
from attacks import Attacks
from sys import argv
import time
def eval_attacks(i: Info):
atks = [getattr(Attacks, method) for method in dir(Attacks) if callable(getattr(Attacks, method)) if
not (method.startswith('_'))]
for a in atks:
ret_val = a(i)
if not ret_val:
print("Error: {} returned None".format(a.__name__))
raise AssertionError
res, res_style, comment = ret_val if len(ret_val) == 3 else (ret_val[0], ret_val[1], "")
res_print(a.__doc__, res, res_style, comment=comment)
if __name__ == '__main__':
debug = False
# DEBUG MODE
if len(argv) >= 2 and "--debug" in argv[1:]:
debug = True
print(f"{FAINT}Debug mode enabled{ENDC}")
color_test()
time.sleep(0.1)
# initialise info
info = Info()
# IGNORE CONTAINER MODE
if len(argv) >= 2 and "--ignore-container" in argv[1:]:
print(f"{WARNING}Ignoring containerisation{ENDC}")
info.virt.container = None
info.virt.current = info.virt.vm
# if assumptions are not met, omit attacks
if not info.valid:
if not debug:
print(f"Ommitting attacks due to {FAIL}failed{ENDC} checks.")
exit(1)
else:
print(f"{FAINT}Warning: Some checks failed, but debug mode is enabled. Output might be incorrect.{ENDC}")
# output attack evaluation
eval_attacks(info)