Skip to content

Commit 4c43b35

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 f94d1db commit 4c43b35

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
@@ -435,5 +435,18 @@ def get_config_propagation_credentials():
435435
}
436436

437437
@staticmethod
438-
def format_config_for_agent(config: Dict):
439-
ConfigService.decrypt_flat_config(config)
438+
def format_flat_config_for_agent(config: Dict):
439+
ConfigService._remove_credentials_from_flat_config(config)
440+
441+
@staticmethod
442+
def _remove_credentials_from_flat_config(config: Dict):
443+
fields_to_remove = {
444+
"exploit_lm_hash_list",
445+
"exploit_ntlm_hash_list",
446+
"exploit_password_list",
447+
"exploit_ssh_keys",
448+
"exploit_user_list",
449+
}
450+
451+
for field in fields_to_remove:
452+
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)