Create concept of Plugin and have all current plugins (fingerprinters/PBAs) inherit from it.
Move plugin manager to their own package. (prep for tests)
This commit is contained in:
parent
3c194e1eb8
commit
2ab885b9b1
|
@ -1,9 +1,10 @@
|
||||||
from abc import ABCMeta, abstractproperty, abstractmethod
|
from abc import ABCMeta, abstractproperty, abstractmethod
|
||||||
|
|
||||||
from infection_monkey.config import WormConfiguration
|
from infection_monkey.config import WormConfiguration
|
||||||
|
from infection_monkey.utils.plugins.plugin import Plugin
|
||||||
|
|
||||||
|
|
||||||
class HostFinger(metaclass=ABCMeta):
|
class HostFinger(Plugin, metaclass=ABCMeta):
|
||||||
@property
|
@property
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def _SCANNED_SERVICE(self):
|
def _SCANNED_SERVICE(self):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
from infection_monkey.utils.load_plugins import get_instances
|
from infection_monkey.utils.plugins.load_plugins import get_instances
|
||||||
from infection_monkey.network.HostFinger import HostFinger
|
from infection_monkey.network.HostFinger import HostFinger
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
|
@ -6,6 +6,7 @@ from infection_monkey.telemetry.post_breach_telem import PostBreachTelem
|
||||||
from infection_monkey.utils.environment import is_windows_os
|
from infection_monkey.utils.environment import is_windows_os
|
||||||
from infection_monkey.config import WormConfiguration
|
from infection_monkey.config import WormConfiguration
|
||||||
from infection_monkey.telemetry.attack.t1064_telem import T1064Telem
|
from infection_monkey.telemetry.attack.t1064_telem import T1064Telem
|
||||||
|
from infection_monkey.utils.plugins.plugin import Plugin
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ __author__ = 'VakarisZ'
|
||||||
EXECUTION_WITHOUT_OUTPUT = "(PBA execution produced no output)"
|
EXECUTION_WITHOUT_OUTPUT = "(PBA execution produced no output)"
|
||||||
|
|
||||||
|
|
||||||
class PBA(object):
|
class PBA(Plugin):
|
||||||
"""
|
"""
|
||||||
Post breach action object. Can be extended to support more than command execution on target machine.
|
Post breach action object. Can be extended to support more than command execution on target machine.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from infection_monkey.utils.environment import is_windows_os
|
from infection_monkey.utils.environment import is_windows_os
|
||||||
from infection_monkey.utils.load_plugins import get_instances
|
from infection_monkey.utils.plugins.load_plugins import get_instances
|
||||||
from infection_monkey.post_breach.pba import PBA
|
from infection_monkey.post_breach.pba import PBA
|
||||||
import infection_monkey.post_breach.actions
|
import infection_monkey.post_breach.actions
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import logging
|
||||||
from os.path import dirname, basename, isfile, join
|
from os.path import dirname, basename, isfile, join
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
|
from infection_monkey.utils.plugins.plugin import Plugin
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,9 +14,11 @@ def _get_candidate_files(base_package_file):
|
||||||
return [basename(f)[:-3] for f in files if isfile(f) and not f.endswith('__init__.py')]
|
return [basename(f)[:-3] for f in files if isfile(f) and not f.endswith('__init__.py')]
|
||||||
|
|
||||||
|
|
||||||
def get_instances(base_package_name, base_package_file, parent_class):
|
def get_instances(base_package_name, base_package_file, parent_class: Plugin):
|
||||||
"""
|
"""
|
||||||
Returns the parent_class type objects from base_package_spec according to configuration
|
Returns the parent_class type objects from base_package_spec.
|
||||||
|
parent_class must be a class object that inherits from Plugin
|
||||||
|
base_package name and file must refer to the same package otherwise bad results
|
||||||
:return: A list of parent_class objects.
|
:return: A list of parent_class objects.
|
||||||
"""
|
"""
|
||||||
objects = []
|
objects = []
|
|
@ -0,0 +1,9 @@
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
|
|
||||||
|
class Plugin(metaclass=ABCMeta):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@abstractmethod
|
||||||
|
def should_run(class_name: str) -> bool:
|
||||||
|
raise NotImplementedError()
|
Loading…
Reference in New Issue