diff --git a/monkey/infection_monkey/exploit/powershell_utils/auth_options.py b/monkey/infection_monkey/exploit/powershell_utils/auth_options.py index 973c7ec76..925a34169 100644 --- a/monkey/infection_monkey/exploit/powershell_utils/auth_options.py +++ b/monkey/infection_monkey/exploit/powershell_utils/auth_options.py @@ -16,9 +16,21 @@ class AuthOptions: def get_auth_options(credentials: Credentials, use_ssl: bool) -> AuthOptions: - # Passwordless login only works with SSL false, AUTH_BASIC and ENCRYPTION_NEVER - ssl = False if credentials.secret == "" else use_ssl - auth_type = AUTH_BASIC if credentials.secret == "" else AUTH_NEGOTIATE - encryption = ENCRYPTION_NEVER if credentials.secret == "" else ENCRYPTION_AUTO + ssl = _get_ssl(credentials, use_ssl) + auth_type = _get_auth_type(credentials) + encryption = _get_encryption(credentials) return AuthOptions(auth_type, encryption, ssl) + + +def _get_ssl(credentials: Credentials, use_ssl): + # Passwordless login only works with SSL false, AUTH_BASIC and ENCRYPTION_NEVER + return False if credentials.secret == "" else use_ssl + + +def _get_auth_type(credentials: Credentials): + return AUTH_BASIC if credentials.secret == "" else AUTH_NEGOTIATE + + +def _get_encryption(credentials: Credentials): + return ENCRYPTION_NEVER if credentials.secret == "" else ENCRYPTION_AUTO