Agent: Move get_auth_options() to auth_options.py

This commit is contained in:
Mike Salvatore 2021-09-01 13:33:06 -04:00
parent da3475c645
commit a060313d09
4 changed files with 19 additions and 26 deletions

View File

@ -17,8 +17,8 @@ from infection_monkey.exploit.powershell_utils.auth_options import (
AUTH_NEGOTIATE,
ENCRYPTION_AUTO,
AuthOptions,
get_auth_options,
)
from infection_monkey.exploit.powershell_utils.auth_options_generators import get_auth_options
from infection_monkey.exploit.powershell_utils.credential_generators import get_credentials
from infection_monkey.exploit.powershell_utils.credentials import Credentials
from infection_monkey.exploit.powershell_utils.utils import (

View File

@ -1,4 +1,7 @@
from dataclasses import dataclass
from typing import List
from infection_monkey.exploit.powershell_utils.credentials import Credentials
AUTH_BASIC = "basic"
AUTH_NEGOTIATE = "negotiate"
@ -11,3 +14,17 @@ class AuthOptions:
auth_type: str
encryption: str
ssl: bool
def get_auth_options(credentials: List[Credentials], use_ssl: bool) -> List[AuthOptions]:
auth_options = []
for creds in credentials:
# Passwordless login only works with SSL false, AUTH_BASIC and ENCRYPTION_NEVER
ssl = False if creds.password == "" else use_ssl
auth_type = AUTH_BASIC if creds.password == "" else AUTH_NEGOTIATE
encryption = ENCRYPTION_NEVER if creds.password == "" else ENCRYPTION_AUTO
auth_options.append(AuthOptions(auth_type, encryption, ssl))
return auth_options

View File

@ -1,24 +0,0 @@
from typing import List
from infection_monkey.exploit.powershell_utils.auth_options import (
AUTH_BASIC,
AUTH_NEGOTIATE,
ENCRYPTION_AUTO,
ENCRYPTION_NEVER,
AuthOptions,
)
from infection_monkey.exploit.powershell_utils.credentials import Credentials
def get_auth_options(credentials: List[Credentials], use_ssl: bool) -> List[AuthOptions]:
auth_options = []
for creds in credentials:
# Passwordless login only works with SSL false, AUTH_BASIC and ENCRYPTION_NEVER
ssl = False if creds.password == "" else use_ssl
auth_type = AUTH_BASIC if creds.password == "" else AUTH_NEGOTIATE
encryption = ENCRYPTION_NEVER if creds.password == "" else ENCRYPTION_AUTO
auth_options.append(AuthOptions(auth_type, encryption, ssl))
return auth_options

View File

@ -4,8 +4,8 @@ from infection_monkey.exploit.powershell_utils.auth_options import (
AUTH_NEGOTIATE,
ENCRYPTION_AUTO,
ENCRYPTION_NEVER,
get_auth_options,
)
from infection_monkey.exploit.powershell_utils.auth_options_generators import get_auth_options
from infection_monkey.exploit.powershell_utils.credentials import Credentials
CREDENTIALS = [