forked from p15670423/monkey
Island, Agent: fixed imports to reference credential type enum in common
This commit is contained in:
parent
73434537fe
commit
c96674f834
|
@ -4,7 +4,8 @@ from collections import namedtuple
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Dict, List, Sequence
|
from typing import Dict, List, Sequence
|
||||||
|
|
||||||
from . import Credentials, PluginType
|
from . import PluginType
|
||||||
|
from .credential_collection import Credentials
|
||||||
|
|
||||||
|
|
||||||
class PortStatus(Enum):
|
class PortStatus(Enum):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from infection_monkey.i_puppet import CredentialType
|
from common.common_consts.credentials_type import CredentialsType
|
||||||
|
|
||||||
from .identities.username_processor import process_username
|
from .identities.username_processor import process_username
|
||||||
from .secrets.lm_hash_processor import process_lm_hash
|
from .secrets.lm_hash_processor import process_lm_hash
|
||||||
|
@ -11,21 +11,21 @@ from .secrets.ssh_key_processor import process_ssh_key
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
SECRET_PROCESSORS = {
|
SECRET_PROCESSORS = {
|
||||||
CredentialType.PASSWORD: process_password,
|
CredentialsType.PASSWORD: process_password,
|
||||||
CredentialType.NT_HASH: process_nt_hash,
|
CredentialsType.NT_HASH: process_nt_hash,
|
||||||
CredentialType.LM_HASH: process_lm_hash,
|
CredentialsType.LM_HASH: process_lm_hash,
|
||||||
CredentialType.SSH_KEYPAIR: process_ssh_key,
|
CredentialsType.SSH_KEYPAIR: process_ssh_key,
|
||||||
}
|
}
|
||||||
|
|
||||||
IDENTITY_PROCESSORS = {
|
IDENTITY_PROCESSORS = {
|
||||||
CredentialType.USERNAME: process_username,
|
CredentialsType.USERNAME: process_username,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def parse_credentials(credentials: dict):
|
def parse_credentials(credentials: dict):
|
||||||
for credential in credentials["credentials"]:
|
for credential in credentials["credentials"]:
|
||||||
if is_ssh_keypair(credentials):
|
if is_ssh_keypair(credentials):
|
||||||
IDENTITY_PROCESSORS[CredentialType.SSH_KEYPAIR](credential, credentials["monkey_guid"])
|
IDENTITY_PROCESSORS[CredentialsType.SSH_KEYPAIR](credential, credentials["monkey_guid"])
|
||||||
else:
|
else:
|
||||||
for identity in credential["identities"]:
|
for identity in credential["identities"]:
|
||||||
IDENTITY_PROCESSORS[identity["type"]](identity)
|
IDENTITY_PROCESSORS[identity["type"]](identity)
|
||||||
|
@ -35,5 +35,5 @@ def parse_credentials(credentials: dict):
|
||||||
|
|
||||||
def is_ssh_keypair(credentials: dict) -> bool:
|
def is_ssh_keypair(credentials: dict) -> bool:
|
||||||
return bool(
|
return bool(
|
||||||
filter(credentials["secrets"], lambda secret: secret["type"] == CredentialType.SSH_KEYPAIR)
|
filter(credentials["secrets"], lambda secret: secret["type"] == CredentialsType.SSH_KEYPAIR)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue