mirror of https://github.com/avast/PurpleDome
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
""" Base class for Caldera plugins
|
|
|
|
Special for this plugin class: If there is no plugin matching a specified attack-id the system can fallback to default handling.
|
|
You only gotta write a plugin if you want some special features
|
|
"""
|
|
|
|
from plugins.base.plugin_base import BasePlugin
|
|
from typing import Optional
|
|
|
|
|
|
class CalderaPlugin(BasePlugin):
|
|
""" Class to execute a command on a caldera system targeting another system """
|
|
|
|
# Boilerplate
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
ttp: Optional[str] = None
|
|
references = None
|
|
|
|
required_files: list[str] = []
|
|
|
|
# TODO: parse results
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.conf: dict = {} # Plugin specific configuration
|
|
# self.sysconf = {} # System configuration. common for all plugins
|
|
|
|
def teardown(self):
|
|
""" Cleanup afterwards """
|
|
pass # pylint: disable=unnecessary-pass
|
|
|
|
def run(self, targets: list[str]):
|
|
""" Run the command
|
|
|
|
@param targets: A list of targets, ip addresses will do
|
|
"""
|
|
raise NotImplementedError
|
|
|
|
def __execute__(self, targets: list[str]) -> str:
|
|
""" Execute the plugin. This is called by the code
|
|
|
|
@param targets: A list of targets, ip addresses will do
|
|
"""
|
|
|
|
self.setup()
|
|
self.attack_logger.start_kali_attack(self.machine_plugin.config.vmname(), targets, self.name, ttp=self.get_ttp())
|
|
res = self.run(targets)
|
|
self.teardown()
|
|
self.attack_logger.stop_kali_attack(self.machine_plugin.config.vmname(), targets, self.name, ttp=self.get_ttp())
|
|
return res
|
|
|
|
def get_ttp(self):
|
|
""" Returns the ttp of the plugin, please set in boilerplate """
|
|
if self.ttp:
|
|
return self.ttp
|
|
|
|
raise NotImplementedError
|
|
|
|
def get_references(self):
|
|
""" Returns the references of the plugin, please set in boilerplate """
|
|
if self.references:
|
|
return self.references
|
|
|
|
raise NotImplementedError
|