diff --git a/monkey/infection_monkey/utils/brute_force.py b/monkey/infection_monkey/utils/brute_force.py index ff74d9712..192905aa8 100644 --- a/monkey/infection_monkey/utils/brute_force.py +++ b/monkey/infection_monkey/utils/brute_force.py @@ -5,6 +5,13 @@ from typing import Any, Iterable, Tuple def generate_identity_secret_pairs( identities: Iterable, secrets: Iterable ) -> Iterable[Tuple[Any, Any]]: + """ + Generates all possible combinations of identities and secrets (e.g. usernames and passwords). + :param identities: An iterable containing identity components of a credential pair + :param secrets: An iterable containing secret components of a credential pair + :return: An iterable of all combinations of identity/secret pairs. If either identities or + secrets is empty, an empty iterator is returned. + """ return product(identities, secrets) @@ -15,8 +22,16 @@ def generate_username_password_or_ntlm_hash_combinations( nt_hashes: Iterable[str], ) -> Iterable[Tuple[str, str, str, str]]: """ - Returns all combinations of the configurations users and passwords or lm/ntlm hashes - :return: + Generates all possible combinations of the following: username/password, username/lm_hash, + username/nt_hash. + :param usernames: An iterable containing usernames + :param passwords: An iterable containing passwords + :param lm_hashes: An iterable containing lm_hashes + :param nt_hashes: An iterable containing nt_hashes + :return: An iterable containing tuples of all possible credentials combinations. Note that each + tuple will contain a username and at most one secret component (i.e. password, lm_hash, + nt_hash). If usernames is empty, an empty iterator is returned. If all secret component + iterators are empty, an empty iterator is returned. """ return chain( product(usernames, passwords, [""], [""]),