#2925 Fixed TAP003 error and failing tests.

This commit is contained in:
Archer Bowen
2025-02-28 14:27:07 +00:00
committed by Marek Wolan
parent 908dbe4722
commit f532b5e0da
11 changed files with 67 additions and 56 deletions

View File

@@ -257,7 +257,7 @@ class TAP003(AbstractTAP, discriminator="tap-003"):
self.logger.debug(f"Updating network knowledge. Changed {username}'s password to {password} on {hostname}.")
self._change_password_target_host = ""
# local password change
elif last_hist_item.action == "node-accounts-change-password" and last_hist_item.response.status == "success":
elif last_hist_item.action == "node-account-change-password" and last_hist_item.response.status == "success":
self.network_knowledge["current_session"] = {}
username = last_hist_item.request[6]
password = last_hist_item.request[8]
@@ -338,15 +338,17 @@ class TAP003(AbstractTAP, discriminator="tap-003"):
"""
if self.current_kill_chain_stage == self.selected_kill_chain.MANIPULATION:
if self._agent_trial_handler(self.config.agent_settings.kill_chain.MANIPULATION.probability):
self.logger.info(f"TAP003 reached the {self.current_kill_chain_stage.name}")
if self.current_stage_progress == KillChainStageProgress.PENDING:
self.logger.info(f"TAP003 reached the {self.current_kill_chain_stage.name}.")
self.current_stage_progress = KillChainStageProgress.IN_PROGRESS
self.current_host = self.starting_node
account_changes = self.config.agent_settings.kill_chain.MANIPULATION.account_changes
if len(account_changes) > 0:
if len(account_changes) > 0 or self._next_account_change:
if not self._next_account_change:
self._next_account_change = account_changes.pop(0)
if self._next_account_change["host"] == self.current_host:
# do a local password change
self.chosen_action = "node-accounts-change-password", {
self.chosen_action = "node-account-change-password", {
"node_name": self.current_host,
"username": self._next_account_change["username"],
"current_password": self.network_knowledge["credentials"][self.current_host]["password"],
@@ -382,14 +384,15 @@ class TAP003(AbstractTAP, discriminator="tap-003"):
],
}
self.logger.info(f"Changing password on remote node {hostname}")
self._next_account_change = account_changes.pop(0)
try:
self._next_account_change = account_changes.pop(0)
except IndexError:
self.logger.info("No further account changes required.")
self._next_account_change = None
self._change_password_target_host = hostname
if len(account_changes) == 0:
self._next_account_change = None
self.logger.info("Finished changing passwords.")
if not self._next_account_change:
self.logger.info("Manipulation complete. Progressing to exploit...")
self._progress_kill_chain()
self.current_stage_progress = KillChainStageProgress.PENDING
else:
if self.config.agent_settings.repeat_kill_chain_stages == False:
self.current_kill_chain_stage = self.selected_kill_chain.FAILED

View File

@@ -38,6 +38,7 @@
"# Importing the necessary PrimAITE libraries\n",
"from primaite.session.environment import PrimaiteGymEnv\n",
"import yaml\n",
"from primaite.game.agent.scripted_agents.TAP001 import TAP001, MobileMalwareKillChain\n",
"from primaite.config.load import load, _EXAMPLE_CFG\n",
"from deepdiff.diff import DeepDiff"
]

View File

@@ -50,6 +50,7 @@
"from primaite.simulator.network.hardware.nodes.host.computer import Computer\n",
"from primaite.simulator.system.applications.web_browser import WebBrowser\n",
"from primaite.simulator.network.hardware.nodes.network.router import Router\n",
"from primaite.game.agent.scripted_agents.TAP003 import TAP003, InsiderKillChain, InsiderKillChainOptions\n",
"from primaite.config.load import load, _EXAMPLE_CFG\n",
"from pprint import pprint\n",
"from deepdiff.diff import DeepDiff\n",
@@ -1503,7 +1504,7 @@
"metadata": {},
"outputs": [],
"source": [
"account_changes = [{\"host\":\"ST_PROJ-A-PRV-PC-2\", \"ip_address\": \"192.168.230.2\", \"user_name\": user_username, \"old_password\": user_password, \"new_password\": tap003_new_password}]"
"account_changes = [{\"host\":\"ST_PROJ-A-PRV-PC-2\", \"ip_address\": \"192.168.230.2\", \"username\": user_username, \"old_password\": user_password, \"new_password\": tap003_new_password}]"
]
},
{