forked from p15670423/monkey
Agent: Move add_credentials_from_event to agent_event_handlers package
This commit is contained in:
parent
37b884a5b8
commit
adee0b4063
|
@ -1,2 +1,5 @@
|
||||||
from .notify_relay_on_propagation import notify_relay_on_propagation
|
from .notify_relay_on_propagation import notify_relay_on_propagation
|
||||||
from .agent_event_forwarder import AgentEventForwarder
|
from .agent_event_forwarder import AgentEventForwarder
|
||||||
|
from .add_stolen_credentials_to_repository import (
|
||||||
|
add_stolen_credentials_to_propagation_credentials_repository,
|
||||||
|
)
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from common.agent_events import CredentialsStolenEvent
|
from common.agent_events import CredentialsStolenEvent
|
||||||
|
from infection_monkey.credential_repository import IPropagationCredentialsRepository
|
||||||
from . import IPropagationCredentialsRepository
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class add_credentials_from_event_to_propagation_credentials_repository:
|
class add_stolen_credentials_to_propagation_credentials_repository:
|
||||||
def __init__(self, credentials_repository: IPropagationCredentialsRepository):
|
def __init__(self, credentials_repository: IPropagationCredentialsRepository):
|
||||||
self._credentials_repository = credentials_repository
|
self._credentials_repository = credentials_repository
|
||||||
|
|
|
@ -2,6 +2,3 @@ from .i_propagation_credentials_repository import IPropagationCredentialsReposit
|
||||||
from .aggregating_propagation_credentials_repository import (
|
from .aggregating_propagation_credentials_repository import (
|
||||||
AggregatingPropagationCredentialsRepository,
|
AggregatingPropagationCredentialsRepository,
|
||||||
)
|
)
|
||||||
from .add_credentials_from_event import (
|
|
||||||
add_credentials_from_event_to_propagation_credentials_repository,
|
|
||||||
)
|
|
||||||
|
|
|
@ -21,7 +21,11 @@ from common.types import SocketAddress
|
||||||
from common.utils.argparse_types import positive_int
|
from common.utils.argparse_types import positive_int
|
||||||
from common.utils.attack_utils import ScanStatus, UsageEnum
|
from common.utils.attack_utils import ScanStatus, UsageEnum
|
||||||
from common.version import get_version
|
from common.version import get_version
|
||||||
from infection_monkey.agent_event_handlers import AgentEventForwarder, notify_relay_on_propagation
|
from infection_monkey.agent_event_handlers import (
|
||||||
|
AgentEventForwarder,
|
||||||
|
add_stolen_credentials_to_propagation_credentials_repository,
|
||||||
|
notify_relay_on_propagation,
|
||||||
|
)
|
||||||
from infection_monkey.config import GUID
|
from infection_monkey.config import GUID
|
||||||
from infection_monkey.control import ControlClient
|
from infection_monkey.control import ControlClient
|
||||||
from infection_monkey.credential_collectors import (
|
from infection_monkey.credential_collectors import (
|
||||||
|
@ -31,7 +35,6 @@ from infection_monkey.credential_collectors import (
|
||||||
from infection_monkey.credential_repository import (
|
from infection_monkey.credential_repository import (
|
||||||
AggregatingPropagationCredentialsRepository,
|
AggregatingPropagationCredentialsRepository,
|
||||||
IPropagationCredentialsRepository,
|
IPropagationCredentialsRepository,
|
||||||
add_credentials_from_event_to_propagation_credentials_repository,
|
|
||||||
)
|
)
|
||||||
from infection_monkey.exploit import CachingAgentBinaryRepository, ExploiterWrapper
|
from infection_monkey.exploit import CachingAgentBinaryRepository, ExploiterWrapper
|
||||||
from infection_monkey.exploit.hadoop import HadoopExploiter
|
from infection_monkey.exploit.hadoop import HadoopExploiter
|
||||||
|
@ -299,7 +302,7 @@ class InfectionMonkey:
|
||||||
):
|
):
|
||||||
agent_event_queue.subscribe_type(
|
agent_event_queue.subscribe_type(
|
||||||
CredentialsStolenEvent,
|
CredentialsStolenEvent,
|
||||||
add_credentials_from_event_to_propagation_credentials_repository(
|
add_stolen_credentials_to_propagation_credentials_repository(
|
||||||
propagation_credentials_repository
|
propagation_credentials_repository
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,10 +3,10 @@ from uuid import UUID
|
||||||
|
|
||||||
from common.agent_events import CredentialsStolenEvent
|
from common.agent_events import CredentialsStolenEvent
|
||||||
from common.credentials import Credentials, Password, Username
|
from common.credentials import Credentials, Password, Username
|
||||||
from infection_monkey.credential_repository import (
|
from infection_monkey.agent_event_handlers import (
|
||||||
IPropagationCredentialsRepository,
|
add_stolen_credentials_to_propagation_credentials_repository,
|
||||||
add_credentials_from_event_to_propagation_credentials_repository,
|
|
||||||
)
|
)
|
||||||
|
from infection_monkey.credential_repository import IPropagationCredentialsRepository
|
||||||
|
|
||||||
credentials = [
|
credentials = [
|
||||||
Credentials(
|
Credentials(
|
||||||
|
@ -25,7 +25,7 @@ credentials_stolen_event = CredentialsStolenEvent(
|
||||||
|
|
||||||
def test_add_credentials_from_event_to_propagation_credentials_repository():
|
def test_add_credentials_from_event_to_propagation_credentials_repository():
|
||||||
mock_propagation_credentials_repository = MagicMock(spec=IPropagationCredentialsRepository)
|
mock_propagation_credentials_repository = MagicMock(spec=IPropagationCredentialsRepository)
|
||||||
fn = add_credentials_from_event_to_propagation_credentials_repository(
|
fn = add_stolen_credentials_to_propagation_credentials_repository(
|
||||||
mock_propagation_credentials_repository
|
mock_propagation_credentials_repository
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue