Agent: Move get_auth_options() to auth_options.py
This commit is contained in:
parent
da3475c645
commit
a060313d09
|
@ -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 (
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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 = [
|
Loading…
Reference in New Issue