Agent: Implement run_credential_collector() in Puppet

This commit is contained in:
Mike Salvatore 2022-02-16 15:01:36 -05:00
parent 10ee9f9e75
commit 3a3a5f0c9c
2 changed files with 15 additions and 5 deletions

View File

@ -12,7 +12,10 @@ from common.utils.attack_utils import ScanStatus, UsageEnum
from common.version import get_version
from infection_monkey.config import GUID, WormConfiguration
from infection_monkey.control import ControlClient
from infection_monkey.credential_collectors import MimikatzCredentialCollector
from infection_monkey.credential_collectors import (
MimikatzCredentialCollector,
SSHCredentialCollector,
)
from infection_monkey.i_puppet import IPuppet, PluginType
from infection_monkey.master import AutomatedMaster
from infection_monkey.master.control_channel import ControlChannel
@ -170,7 +173,7 @@ class InfectionMonkey:
def _build_master(self):
local_network_interfaces = InfectionMonkey._get_local_network_interfaces()
puppet = InfectionMonkey._build_puppet()
puppet = self._build_puppet()
victim_host_factory = self._build_victim_host_factory(local_network_interfaces)
@ -190,8 +193,7 @@ class InfectionMonkey:
return local_network_interfaces
@staticmethod
def _build_puppet() -> IPuppet:
def _build_puppet(self) -> IPuppet:
puppet = Puppet()
puppet.load_plugin(
@ -199,6 +201,11 @@ class InfectionMonkey:
MimikatzCredentialCollector(),
PluginType.CREDENTIAL_COLLECTOR,
)
puppet.load_plugin(
"SSHCollector",
SSHCredentialCollector(self.telemetry_messenger),
PluginType.CREDENTIAL_COLLECTOR,
)
puppet.load_plugin("elastic", ElasticSearchFingerprinter(), PluginType.FINGERPRINTER)
puppet.load_plugin("http", HTTPFingerprinter(), PluginType.FINGERPRINTER)

View File

@ -29,7 +29,10 @@ class Puppet(IPuppet):
self._plugin_registry.load_plugin(plugin_name, plugin, plugin_type)
def run_credential_collector(self, name: str, options: Dict) -> Sequence[Credentials]:
return list(self._mock_puppet.run_credential_collector(name, options))
credential_collector = self._plugin_registry.get_plugin(
name, PluginType.CREDENTIAL_COLLECTOR
)
return list(credential_collector.collect_credentials(options))
def run_pba(self, name: str, options: Dict) -> PostBreachData:
return self._mock_puppet.run_pba(name, options)