Skip to content

Commit 97bc0c7

Browse files
committed
Island: Strip credentials out of config before sending to agent
The credentials for credential reuse attacks will now be retrieved by the agent via a new endpoint that returns only credentials in order to reduce unnecessary network traffic (issue #1538).
1 parent 2e7f5d8 commit 97bc0c7

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

monkey/monkey_island/cc/resources/monkey.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get(self, guid=None, config_format=None, **kw):
3131
if config_format == "legacy":
3232
ConfigService.decrypt_flat_config(monkey_json["config"])
3333
else:
34-
ConfigService.format_config_for_agent(monkey_json["config"])
34+
ConfigService.format_flat_config_for_agent(monkey_json["config"])
3535

3636
return monkey_json
3737

monkey/monkey_island/cc/services/config.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -428,5 +428,18 @@ def get_config_propagation_credentials():
428428
}
429429

430430
@staticmethod
431-
def format_config_for_agent(config: Dict):
432-
ConfigService.decrypt_flat_config(config)
431+
def format_flat_config_for_agent(config: Dict):
432+
ConfigService._remove_credentials_from_flat_config(config)
433+
434+
@staticmethod
435+
def _remove_credentials_from_flat_config(config: Dict):
436+
fields_to_remove = {
437+
"exploit_lm_hash_list",
438+
"exploit_ntlm_hash_list",
439+
"exploit_password_list",
440+
"exploit_ssh_keys",
441+
"exploit_user_list",
442+
}
443+
444+
for field in fields_to_remove:
445+
config.pop(field, None)

monkey/tests/unit_tests/monkey_island/cc/services/test_config.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js
77

88

9-
class MockClass:
10-
pass
11-
12-
139
@pytest.fixture(scope="function", autouse=True)
1410
def mock_port(monkeypatch, PORT):
1511
monkeypatch.setattr("monkey_island.cc.services.config.ISLAND_PORT", PORT)
@@ -27,3 +23,13 @@ def test_set_server_ips_in_config_current_server(config, IPS, PORT):
2723
ConfigService.set_server_ips_in_config(config)
2824
expected_config_current_server = f"{IPS[0]}:{PORT}"
2925
assert config["internal"]["island_server"]["current_server"] == expected_config_current_server
26+
27+
28+
def test_format_config_for_agent__credentials_removed(flat_monkey_config):
29+
ConfigService.format_flat_config_for_agent(flat_monkey_config)
30+
31+
assert "exploit_lm_hash_list" not in flat_monkey_config
32+
assert "exploit_ntlm_hash_list" not in flat_monkey_config
33+
assert "exploit_password_list" not in flat_monkey_config
34+
assert "exploit_ssh_keys" not in flat_monkey_config
35+
assert "exploit_user_list" not in flat_monkey_config

0 commit comments

Comments
 (0)