Improved exploiter descriptors and usage of them in report.py
This commit is contained in:
parent
6685b24da4
commit
0b34d30fd6
|
@ -36,14 +36,7 @@ class ExploiterDescriptorEnum(Enum):
|
||||||
ZEROLOGON = ExploiterDescriptor('ZerologonExploiter', 'Zerologon Exploiter', ZerologonExploitProcessor)
|
ZEROLOGON = ExploiterDescriptor('ZerologonExploiter', 'Zerologon Exploiter', ZerologonExploitProcessor)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def __dict__() -> Dict[str, ExploiterDescriptor]:
|
def get_by_class_name(class_name: str) -> ExploiterDescriptor:
|
||||||
descriptor_dict = {}
|
return [descriptor.value
|
||||||
for descriptor in ExploiterDescriptorEnum:
|
|
||||||
descriptor_dict[descriptor.value.class_name] = descriptor
|
|
||||||
return descriptor_dict
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_display_name_by_class_name(class_name: str) -> str:
|
|
||||||
return [descriptor.display_name.value
|
|
||||||
for descriptor in ExploiterDescriptorEnum
|
for descriptor in ExploiterDescriptorEnum
|
||||||
if descriptor.class_name.value == class_name][0]
|
if descriptor.value.class_name == class_name][0]
|
||||||
|
|
|
@ -32,7 +32,6 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ReportService:
|
class ReportService:
|
||||||
exploiter_descriptors = ExploiterDescriptorEnum.__dict__
|
|
||||||
|
|
||||||
class DerivedIssueEnum:
|
class DerivedIssueEnum:
|
||||||
WEAK_PASSWORD = "weak_password"
|
WEAK_PASSWORD = "weak_password"
|
||||||
|
@ -145,7 +144,7 @@ class ReportService:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_exploits_used_on_node(node: dict) -> List[str]:
|
def get_exploits_used_on_node(node: dict) -> List[str]:
|
||||||
return list(set([ExploiterDescriptorEnum.get_display_name_by_class_name(exploit['exploiter'])
|
return list(set([ExploiterDescriptorEnum.get_by_class_name(exploit['exploiter']).display_name
|
||||||
for exploit in node['exploits']
|
for exploit in node['exploits']
|
||||||
if exploit['result']]))
|
if exploit['result']]))
|
||||||
|
|
||||||
|
@ -253,9 +252,9 @@ class ReportService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_exploit(exploit) -> ExploiterReportInfo:
|
def process_exploit(exploit) -> ExploiterReportInfo:
|
||||||
exploiter_type = exploit['data']['exploiter']
|
exploiter_type = exploit['data']['exploiter']
|
||||||
exploiter_descriptor = ReportService.exploiter_descriptors[exploiter_type].value
|
exploiter_descriptor = ExploiterDescriptorEnum.get_by_class_name(exploiter_type)
|
||||||
processor = exploiter_descriptor.processor()
|
processor = exploiter_descriptor.processor()
|
||||||
exploiter_info = processor.get_exploit_info_by_dict(exploiter_descriptor.class_name, exploit)
|
exploiter_info = processor.get_exploit_info_by_dict(exploiter_type, exploit)
|
||||||
return exploiter_info
|
return exploiter_info
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -485,7 +484,7 @@ class ReportService:
|
||||||
if exploits == default_exploits:
|
if exploits == default_exploits:
|
||||||
return ['default']
|
return ['default']
|
||||||
|
|
||||||
return [ExploiterDescriptorEnum.get_display_name_by_class_name(exploit)
|
return [ExploiterDescriptorEnum.get_by_class_name(exploit).display_name
|
||||||
for exploit in exploits]
|
for exploit in exploits]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue