Skip to content

Commit 52a4938

Browse files
committed
v0.4.16
InteractiveMessageType lookup and processing fixes
1 parent 00c4b75 commit 52a4938

5 files changed

Lines changed: 57 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

2+
## [v0.4.16] - 2024-04-08
3+
4+
### Changed
5+
6+
- Added InteractiveTaskType dictionary lookup in MythicCommandBase based on InteractiveTaskType
7+
- Updated the processing of payload type commands to be based on root module name
8+
29
## [v0.4.14] - 2024-03-20
310

411
### Changed

mythic_container/MythicCommandBase.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,11 +990,11 @@ def to_json(self, base_path: Path):
990990
)
991991
if code_file.exists():
992992
code = code_file.read_bytes().decode()
993-
#code = base64.b64encode(code).decode()
993+
# code = base64.b64encode(code).decode()
994994
return {"script": code, "name": self.script_name, "author": self.author}
995995
elif Path(self.script_name).exists():
996996
code = Path(self.script_name).read_bytes().decode()
997-
#code = base64.b64encode(code).decode()
997+
# code = base64.b64encode(code).decode()
998998
return {"script": code, "name": self.script_name, "author": self.author}
999999
else:
10001000
raise Exception(
@@ -1290,6 +1290,35 @@ def __str__(self):
12901290
return json.dumps(self.to_json(), sort_keys=True, indent=2)
12911291

12921292

1293+
InteractiveMessageType = {
1294+
0: ("Input", 0),
1295+
1: ("Output", 1),
1296+
2: ("Error", 2),
1297+
3: ("Exit", 3),
1298+
4: ("^[", 0x1B),
1299+
5: ("^A", 0x01),
1300+
6: ("^B", 0x02),
1301+
7: ("^C", 0x03),
1302+
8: ("^D", 0x04),
1303+
9: ("^E", 0x05),
1304+
10: ("^F", 0x06),
1305+
11: ("^G", 0x07),
1306+
12: ("^H", 0x08),
1307+
13: ("^I", 0x09),
1308+
14: ("^K", 0x0B),
1309+
15: ("^L", 0x0C),
1310+
16: ("^N", 0x0E),
1311+
17: ("^P", 0x10),
1312+
18: ("^Q", 0x11),
1313+
19: ("^R", 0x12),
1314+
20: ("^S", 0x13),
1315+
21: ("^U", 0x15),
1316+
22: ("^W", 0x17),
1317+
23: ("^Y", 0x19),
1318+
24: ("^Z", 0x1A)
1319+
}
1320+
1321+
12931322
class PTTaskMessageTaskData:
12941323
"""A container for all information about a task.
12951324
@@ -1334,6 +1363,7 @@ class PTTaskMessageTaskData:
13341363
Functions:
13351364
to_json(self): return dictionary form of class
13361365
"""
1366+
13371367
def __init__(self,
13381368
id: int = 0,
13391369
display_id: int = 0,
@@ -1369,6 +1399,9 @@ def __init__(self,
13691399
tasking_location: str = "",
13701400
parameter_group_name: str = "",
13711401
token_id: int = None,
1402+
response_count: int = None,
1403+
is_interactive_task: bool = None,
1404+
interactive_task_type: int = None,
13721405
**kwargs):
13731406
self.ID = id
13741407
self.DisplayID = display_id
@@ -1406,6 +1439,9 @@ def __init__(self,
14061439
self.TokenID = token_id
14071440
if self.TokenID is not None and self.TokenID <= 0:
14081441
self.TokenID = None
1442+
self.ResponseCount = response_count
1443+
self.IsInteractiveTask = is_interactive_task
1444+
self.InteractiveTaskType = interactive_task_type
14091445

14101446
def to_json(self):
14111447
return {
@@ -1443,6 +1479,9 @@ def to_json(self):
14431479
"tasking_location": self.TaskingLocation,
14441480
"parameter_group_name": self.ParameterGroupName,
14451481
"token_id": self.TokenID,
1482+
"response_count": self.ResponseCount,
1483+
"is_interactive_task": self.IsInteractiveTask,
1484+
"interactive_task_type": self.InteractiveTaskType
14461485
}
14471486

14481487
def __str__(self):
@@ -1487,6 +1526,7 @@ class PTTaskMessageCallbackData:
14871526
Functions:
14881527
to_json(self): return dictionary form of class
14891528
"""
1529+
14901530
def __init__(self,
14911531
id: int = 0,
14921532
display_id: int = 0,
@@ -1599,6 +1639,7 @@ class PTTaskMessagePayloadData:
15991639
Functions:
16001640
to_json(self): return dictionary form of class
16011641
"""
1642+
16021643
def __init__(self,
16031644
os: str = "",
16041645
uuid: str = "",
@@ -1758,6 +1799,7 @@ class PTOnNewCallbackResponse:
17581799
Functions:
17591800
to_json(self): return dictionary form of class
17601801
"""
1802+
17611803
def __init__(self,
17621804
AgentCallbackID: str,
17631805
Success: bool = True,
@@ -1843,6 +1885,7 @@ class PTTaskCompletionFunctionMessageResponse:
18431885
Functions:
18441886
to_json(self): return dictionary form of class
18451887
"""
1888+
18461889
def __init__(self,
18471890
TaskID: int = 0,
18481891
ParentTaskId: int = 0,
@@ -1909,6 +1952,7 @@ class PTTaskProcessResponseMessageResponse:
19091952
Functions:
19101953
to_json(self): return dictionary form of class
19111954
"""
1955+
19121956
def __init__(self,
19131957
TaskID: int,
19141958
Success: bool = True,

mythic_container/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
containerVersion = "v1.1.9"
55

6-
PyPi_version = "0.4.15"
6+
PyPi_version = "0.4.16"
77

88
RabbitmqConnection = rabbitmqConnectionClass()
99

mythic_container/mythic_service.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,8 @@ async def syncPayloadData(pt: PayloadBuilder.PayloadType) -> None:
111111
"commands": [],
112112
"container_version": mythic_container.containerVersion
113113
}
114-
115-
modulePieces = pt.__module__.split(".")
116-
modulePrefix = ".".join(modulePieces[:-1])
117114
for cls in MythicCommandBase.CommandBase.__subclasses__():
118-
if cls.__module__.startswith(modulePrefix):
115+
if cls.__module__.split(".")[0] == pt.name:
119116
logger.info(f"[*] Processing command {cls.cmd}")
120117
if pt.name not in MythicCommandBase.commands:
121118
MythicCommandBase.commands[pt.name] = []
@@ -447,10 +444,8 @@ async def test_command(payload_type_name: str,
447444
payload_type = cls()
448445
if payload_type.name == payload_type_name:
449446
logger.info(f"[+] Found payload type: {payload_type.name}")
450-
modulePieces = payload_type.__module__.split(".")
451-
modulePrefix = ".".join(modulePieces[:-1])
452447
for cmdcls in MythicCommandBase.CommandBase.__subclasses__():
453-
if cmdcls.__module__.startswith(modulePrefix):
448+
if cmdcls.__module__.split(".")[0] == payload_type.name:
454449
if cmdcls.cmd == command_name:
455450
commandInstance = cmdcls(payload_type.agent_path, payload_type.agent_code_path,
456451
payload_type.agent_browserscript_path)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# This call to setup() does all the work
1111
setup(
1212
name="mythic_container",
13-
version="0.4.15",
13+
version="0.4.16",
1414
description="Functionality for Mythic Services",
1515
long_description=README,
1616
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)