#2689 Address a couple of TODOs and other misc changes.
This commit is contained in:
@@ -180,7 +180,7 @@
|
||||
"source": [
|
||||
"## **Command and Control** | C2 Beacon Actions\n",
|
||||
"\n",
|
||||
"Before the Red Agent is able to perform any C2 Server commands, it must first establish connection with a C2 beacon.\n",
|
||||
"Before any C2 Server commands is able to accept any commands, it must first establish connection with a C2 beacon.\n",
|
||||
"\n",
|
||||
"This can be done by installing, configuring and then executing a C2 Beacon. "
|
||||
]
|
||||
@@ -341,6 +341,37 @@
|
||||
"# TODO: Post Terminal.\n",
|
||||
"#env.step(7)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## **Command and Control** | Blue Agent Relevance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **Command and Control** | Blue Agent Relevance | Observation Space"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### **Command and Control** | Blue Agent Relevance | Action Space"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
@@ -184,8 +184,6 @@ class C2Beacon(AbstractC2, identifier="C2Beacon"):
|
||||
:return: The Request Response provided by the terminal execute method.
|
||||
:rtype Request Response:
|
||||
"""
|
||||
# TODO: Probably could refactor this to be a more clean.
|
||||
# The elif's are a bit ugly when they are all calling the same method.
|
||||
command = payload.command
|
||||
if not isinstance(command, C2Command):
|
||||
self.sys_log.warning(f"{self.name}: Received unexpected C2 command. Unable to resolve command")
|
||||
@@ -253,19 +251,26 @@ class C2Beacon(AbstractC2, identifier="C2Beacon"):
|
||||
"""
|
||||
C2 Command: Ransomware Configuration.
|
||||
|
||||
Creates a request that configures the ransomware based off the configuration options given.
|
||||
This request is then sent to the terminal service in order to be executed.
|
||||
Calls the locally installed RansomwareScript application's configure method
|
||||
and passes the given parameters.
|
||||
|
||||
The class attribute self._host_ransomware_script will return None if the host
|
||||
does not have an instance of the RansomwareScript.
|
||||
|
||||
:payload MasqueradePacket: The incoming INPUT command.
|
||||
:type Masquerade Packet: MasqueradePacket.
|
||||
:return: Returns the Request Response returned by the Terminal execute method.
|
||||
:rtype: Request Response
|
||||
"""
|
||||
# TODO: replace and use terminal
|
||||
# return RequestResponse(status="success", data={"Reason": "Placeholder."})
|
||||
given_config = payload.payload
|
||||
host_ransomware = self._host_ransomware_script
|
||||
return RequestResponse.from_bool(host_ransomware.configure(server_ip_address=given_config["server_ip_address"]))
|
||||
if self._host_ransomware_script is None:
|
||||
return RequestResponse(
|
||||
status="failure",
|
||||
data={"Reason": "Cannot find any instances of a RansomwareScript. Have you installed one?"},
|
||||
)
|
||||
return RequestResponse.from_bool(
|
||||
self._host_ransomware_script.configure(server_ip_address=given_config["server_ip_address"])
|
||||
)
|
||||
|
||||
def _command_ransomware_launch(self, payload: MasqueradePacket) -> RequestResponse:
|
||||
"""
|
||||
@@ -280,6 +285,11 @@ class C2Beacon(AbstractC2, identifier="C2Beacon"):
|
||||
:return: Returns the Request Response returned by the Terminal execute method.
|
||||
:rtype: Request Response
|
||||
"""
|
||||
if self._host_ransomware_script is None:
|
||||
return RequestResponse(
|
||||
status="failure",
|
||||
data={"Reason": "Cannot find any instances of a RansomwareScript. Have you installed one?"},
|
||||
)
|
||||
return RequestResponse.from_bool(self._host_ransomware_script.attack())
|
||||
|
||||
def _command_terminal(self, payload: MasqueradePacket) -> RequestResponse:
|
||||
|
||||
@@ -219,7 +219,7 @@ class C2Server(AbstractC2, identifier="C2Server"):
|
||||
"""
|
||||
Creates and returns a Masquerade Packet using the arguments given.
|
||||
|
||||
Creates Masquerade Packet with a payload_type INPUT C2Payload
|
||||
Creates Masquerade Packet with a payload_type INPUT C2Payload.
|
||||
|
||||
:param given_command: The C2 command to be sent to the C2 Beacon.
|
||||
:type given_command: C2Command.
|
||||
@@ -228,7 +228,6 @@ class C2Server(AbstractC2, identifier="C2Server"):
|
||||
:return: Returns the construct MasqueradePacket
|
||||
:rtype: MasqueradePacket
|
||||
"""
|
||||
# TODO: Validation on command_options.
|
||||
constructed_packet = MasqueradePacket(
|
||||
masquerade_protocol=self.current_masquerade_protocol,
|
||||
masquerade_port=self.current_masquerade_port,
|
||||
|
||||
Reference in New Issue
Block a user