forked from p15670423/monkey
Common, Agent: Rename get_plain_text to get_plaintext
This commit is contained in:
parent
6e254c71d7
commit
5608bb3f11
|
@ -11,7 +11,7 @@ Secret = Union[Password, LMHash, NTHash, SSHKeypair]
|
|||
Identity = Username
|
||||
|
||||
|
||||
def get_plain_text(secret: Union[SecretStr, SecretBytes, None, str]) -> Optional[str]:
|
||||
def get_plaintext(secret: Union[SecretStr, SecretBytes, None, str]) -> Optional[str]:
|
||||
if isinstance(secret, (SecretStr, SecretBytes)):
|
||||
return secret.get_secret_value()
|
||||
else:
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import Sequence, Tuple
|
|||
import pymssql
|
||||
|
||||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
|
||||
from common.credentials.credentials import get_plain_text
|
||||
from common.credentials.credentials import get_plaintext
|
||||
from common.utils.exceptions import FailedExploitationError
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
|
@ -112,7 +112,7 @@ class MSSQLExploiter(HostExploiter):
|
|||
conn = pymssql.connect(
|
||||
host,
|
||||
user,
|
||||
get_plain_text(password),
|
||||
get_plaintext(password),
|
||||
port=port,
|
||||
login_timeout=self.LOGIN_TIMEOUT,
|
||||
timeout=self.QUERY_TIMEOUT,
|
||||
|
|
|
@ -11,7 +11,7 @@ from pypsrp.powershell import PowerShell, RunspacePool
|
|||
from typing_extensions import Protocol
|
||||
from urllib3 import connectionpool
|
||||
|
||||
from common.credentials.credentials import get_plain_text
|
||||
from common.credentials.credentials import get_plaintext
|
||||
from infection_monkey.exploit.powershell_utils.auth_options import AuthOptions
|
||||
from infection_monkey.exploit.powershell_utils.credentials import Credentials, SecretType
|
||||
|
||||
|
@ -43,7 +43,7 @@ def format_password(credentials: Credentials) -> Optional[str]:
|
|||
if credentials.secret_type == SecretType.CACHED:
|
||||
return None
|
||||
|
||||
plaintext_secret = get_plain_text(credentials.secret)
|
||||
plaintext_secret = get_plaintext(credentials.secret)
|
||||
|
||||
if credentials.secret_type == SecretType.PASSWORD:
|
||||
return plaintext_secret
|
||||
|
|
|
@ -4,7 +4,7 @@ from impacket.dcerpc.v5 import scmr, transport
|
|||
from impacket.dcerpc.v5.scmr import DCERPCSessionError
|
||||
|
||||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT
|
||||
from common.credentials.credentials import get_plain_text
|
||||
from common.credentials.credentials import get_plaintext
|
||||
from common.utils.attack_utils import ScanStatus, UsageEnum
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
|
@ -110,10 +110,10 @@ class SMBExploiter(HostExploiter):
|
|||
# This method exists only for selected protocol sequences.
|
||||
rpctransport.set_credentials(
|
||||
user,
|
||||
get_plain_text(password),
|
||||
get_plaintext(password),
|
||||
"",
|
||||
get_plain_text(lm_hash),
|
||||
get_plain_text(ntlm_hash),
|
||||
get_plaintext(lm_hash),
|
||||
get_plaintext(ntlm_hash),
|
||||
None,
|
||||
)
|
||||
rpctransport.set_kerberos(SMBExploiter.USE_KERBEROS)
|
||||
|
|
|
@ -5,7 +5,7 @@ from pathlib import PurePath
|
|||
import paramiko
|
||||
|
||||
from common.common_consts.timeouts import LONG_REQUEST_TIMEOUT, MEDIUM_REQUEST_TIMEOUT
|
||||
from common.credentials.credentials import get_plain_text
|
||||
from common.credentials.credentials import get_plaintext
|
||||
from common.utils import Timer
|
||||
from common.utils.attack_utils import ScanStatus
|
||||
from common.utils.exceptions import FailedExploitationError
|
||||
|
@ -60,7 +60,7 @@ class SSHExploiter(HostExploiter):
|
|||
|
||||
for user, ssh_key_pair in ssh_key_pairs_iterator:
|
||||
# Creating file-like private key for paramiko
|
||||
pkey = io.StringIO(get_plain_text(ssh_key_pair["private_key"]))
|
||||
pkey = io.StringIO(get_plaintext(ssh_key_pair["private_key"]))
|
||||
ssh_string = "%s@%s" % (user, self.host.ip_addr)
|
||||
|
||||
ssh = paramiko.SSHClient()
|
||||
|
|
|
@ -10,7 +10,7 @@ from impacket.smb3structs import SMB2_DIALECT_002, SMB2_DIALECT_21
|
|||
from impacket.smbconnection import SMB_DIALECT, SMBConnection
|
||||
from pydantic import SecretStr
|
||||
|
||||
from common.credentials.credentials import get_plain_text
|
||||
from common.credentials.credentials import get_plaintext
|
||||
from common.utils.attack_utils import ScanStatus
|
||||
from infection_monkey.network.tools import get_interface_to_target
|
||||
from infection_monkey.telemetry.attack.t1105_telem import T1105Telem
|
||||
|
@ -218,10 +218,10 @@ class SmbTools(object):
|
|||
try:
|
||||
smb.login(
|
||||
username,
|
||||
get_plain_text(password),
|
||||
get_plaintext(password),
|
||||
"",
|
||||
get_plain_text(lm_hash),
|
||||
get_plain_text(ntlm_hash),
|
||||
get_plaintext(lm_hash),
|
||||
get_plaintext(ntlm_hash),
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.error(f'Error while logging into {host} using user "{username}": {exc}')
|
||||
|
|
|
@ -5,7 +5,7 @@ import traceback
|
|||
|
||||
from impacket.dcerpc.v5.rpcrt import DCERPCException
|
||||
|
||||
from common.credentials.credentials import get_plain_text
|
||||
from common.credentials.credentials import get_plaintext
|
||||
from infection_monkey.exploit.HostExploiter import HostExploiter
|
||||
from infection_monkey.exploit.tools.helpers import get_agent_dst_path
|
||||
from infection_monkey.exploit.tools.smb_tools import SmbTools
|
||||
|
@ -48,10 +48,10 @@ class WmiExploiter(HostExploiter):
|
|||
wmi_connection.connect(
|
||||
self.host,
|
||||
user,
|
||||
get_plain_text(password),
|
||||
get_plaintext(password),
|
||||
None,
|
||||
get_plain_text(lm_hash),
|
||||
get_plain_text(ntlm_hash),
|
||||
get_plaintext(lm_hash),
|
||||
get_plaintext(ntlm_hash),
|
||||
)
|
||||
except AccessDeniedException:
|
||||
self.report_login_attempt(False, user, password, lm_hash, ntlm_hash)
|
||||
|
|
|
@ -17,7 +17,7 @@ from tests.data_for_tests.propagation_credentials import (
|
|||
|
||||
from common.base_models import InfectionMonkeyBaseModel
|
||||
from common.credentials import Credentials
|
||||
from common.credentials.credentials import get_plain_text
|
||||
from common.credentials.credentials import get_plaintext
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -69,4 +69,4 @@ _hidden = [PASSWORD_1, PRIVATE_KEY, LM_HASH, "", "already_plaintext", Path("C:\\
|
|||
|
||||
@pytest.mark.parametrize("expected, hidden", list(zip(_plaintext, _hidden)))
|
||||
def test_get_plain_text(expected, hidden):
|
||||
assert expected == get_plain_text(hidden)
|
||||
assert expected == get_plaintext(hidden)
|
||||
|
|
Loading…
Reference in New Issue