#2706 - Actioning review comments on example notebook and terminal class
This commit is contained in:
@@ -50,7 +50,9 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"demonstrate how we obtain the Terminal component"
|
"The terminal can be accessed from a `HostNode` via the `software_manager` as demonstrated below. \n",
|
||||||
|
"\n",
|
||||||
|
"In the example, we have a basic network consisting of two computers "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -89,7 +91,7 @@
|
|||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"The Terminal can be used to install new software. The code block below demonstrates how the Terminal class allows the user of `terminal_a`, on `computer_a`, to send a command to `computer_b` to install the `RansomwareScript` application. \n"
|
"The Terminal can be used to send requests to install new software. The code block below demonstrates how the Terminal class allows the user of `terminal_a`, on `computer_a`, to send a command to `computer_b` to install the `RansomwareScript` application. \n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -111,7 +113,7 @@
|
|||||||
" target_ip_address=computer_b.network_interface[1].ip_address,\n",
|
" target_ip_address=computer_b.network_interface[1].ip_address,\n",
|
||||||
")\n",
|
")\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Send commmand to install RansomwareScript\n",
|
"# Send command to install RansomwareScript\n",
|
||||||
"terminal_a.send(payload=payload, dest_ip_address=computer_b.network_interface[1].ip_address)"
|
"terminal_a.send(payload=payload, dest_ip_address=computer_b.network_interface[1].ip_address)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -124,13 +124,13 @@ class Terminal(Service):
|
|||||||
return RequestResponse(status="failure", data={})
|
return RequestResponse(status="failure", data={})
|
||||||
|
|
||||||
def _remote_login(request: List[Any], context: Any) -> RequestResponse:
|
def _remote_login(request: List[Any], context: Any) -> RequestResponse:
|
||||||
self._process_remote_login(username=request[0], password=request[1], ip_address=request[2])
|
login = self._process_remote_login(username=request[0], password=request[1], ip_address=request[2])
|
||||||
if self.is_connected:
|
if login:
|
||||||
return RequestResponse(status="success", data={})
|
return RequestResponse(status="success", data={})
|
||||||
else:
|
else:
|
||||||
return RequestResponse(status="failure", data={})
|
return RequestResponse(status="failure", data={})
|
||||||
|
|
||||||
def _execute(request: List[Any], context: Any) -> RequestResponse:
|
def _execute_request(request: List[Any], context: Any) -> RequestResponse:
|
||||||
"""Execute an instruction."""
|
"""Execute an instruction."""
|
||||||
command: str = request[0]
|
command: str = request[0]
|
||||||
self.execute(command)
|
self.execute(command)
|
||||||
@@ -156,7 +156,7 @@ class Terminal(Service):
|
|||||||
|
|
||||||
rm.add_request(
|
rm.add_request(
|
||||||
"Execute",
|
"Execute",
|
||||||
request_type=RequestType(func=_execute, validator=_login_valid),
|
request_type=RequestType(func=_execute_request, validator=_login_valid),
|
||||||
)
|
)
|
||||||
|
|
||||||
rm.add_request("Logoff", request_type=RequestType(func=_logoff, validator=_login_valid))
|
rm.add_request("Logoff", request_type=RequestType(func=_logoff, validator=_login_valid))
|
||||||
|
|||||||
Reference in New Issue
Block a user