forked from p15670423/monkey
Agent: Return credentials when credentials propagation fails
This commit is contained in:
parent
9e6a569393
commit
e4f7707b66
|
@ -63,12 +63,11 @@ class AggregatingPropagationCredentialsRepository(IPropagationCredentialsReposit
|
||||||
try:
|
try:
|
||||||
propagation_credentials = self._get_credentials_from_control_channel()
|
propagation_credentials = self._get_credentials_from_control_channel()
|
||||||
self.add_credentials(propagation_credentials)
|
self.add_credentials(propagation_credentials)
|
||||||
|
|
||||||
return self._stored_credentials
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self._stored_credentials = {}
|
|
||||||
logger.error(f"Error while attempting to retrieve credentials for propagation: {ex}")
|
logger.error(f"Error while attempting to retrieve credentials for propagation: {ex}")
|
||||||
|
|
||||||
|
return self._stored_credentials
|
||||||
|
|
||||||
def _set_attribute(self, attribute_to_be_set: str, credentials_values: Iterable[Any]):
|
def _set_attribute(self, attribute_to_be_set: str, credentials_values: Iterable[Any]):
|
||||||
if not credentials_values:
|
if not credentials_values:
|
||||||
return
|
return
|
||||||
|
|
|
@ -122,3 +122,16 @@ def test_all_keys_if_credentials_empty():
|
||||||
assert "exploit_password_list" in actual_stored_credentials
|
assert "exploit_password_list" in actual_stored_credentials
|
||||||
assert "exploit_ntlm_hash_list" in actual_stored_credentials
|
assert "exploit_ntlm_hash_list" in actual_stored_credentials
|
||||||
assert "exploit_ssh_keys" in actual_stored_credentials
|
assert "exploit_ssh_keys" in actual_stored_credentials
|
||||||
|
|
||||||
|
|
||||||
|
def test_credentials_obtained_if_propagation_credentials_fails():
|
||||||
|
control_channel = MagicMock()
|
||||||
|
control_channel.get_credentials_for_propagation.return_value = EMPTY_CHANNEL_CREDENTIALS
|
||||||
|
control_channel.get_credentials_for_propagation.side_effect = Exception(
|
||||||
|
"No credentials for you!"
|
||||||
|
)
|
||||||
|
credentials_repository = AggregatingPropagationCredentialsRepository(control_channel)
|
||||||
|
|
||||||
|
credentials = credentials_repository.get_credentials()
|
||||||
|
|
||||||
|
assert credentials is not None
|
||||||
|
|
Loading…
Reference in New Issue