Skip to content

Commit 6b328b7

Browse files
committed
allow selecting existing files for register_* commands
1 parent 5cbd0bb commit 6b328b7

File tree

4 files changed

+81
-18
lines changed

4 files changed

+81
-18
lines changed

Payload_Type/apollo/CHANGELOG.MD

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [v2.3.6] -
7+
## [v2.3.7] - 2025-03-12
8+
9+
### Changed
10+
11+
- Added the ability to select already uploaded files as part of the register_* commands
12+
13+
## [v2.3.6] - 2025-03-12
814

915
### Changed
1016

Payload_Type/apollo/apollo/mythic/agent_functions/builder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Apollo(PayloadType):
2121
supported_os = [
2222
SupportedOS.Windows
2323
]
24-
version = "2.3.6"
24+
version = "2.3.7"
2525
wrapper = False
2626
wrapped_payloads = ["scarecrow_wrapper", "service_wrapper"]
2727
note = """

Payload_Type/apollo/apollo/mythic/agent_functions/register_file.py

+72-15
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,48 @@ def __init__(self, command_line, **kwargs):
1212
name="file",
1313
cli_name="File",
1414
display_name="File",
15-
type=ParameterType.File)
15+
type=ParameterType.File,
16+
parameter_group_info=[ParameterGroupInfo(
17+
ui_position=1,
18+
required=True,
19+
group_name="Add New File"
20+
)]
21+
),
22+
CommandParameter(
23+
name="existingFile",
24+
cli_name="existingFile",
25+
display_name="Existing File",
26+
type=ParameterType.ChooseOne,
27+
dynamic_query_function=self.get_files,
28+
parameter_group_info=[ParameterGroupInfo(
29+
ui_position=1,
30+
required=True,
31+
group_name="Use Existing File"
32+
)]
33+
)
1634
]
1735

36+
async def get_files( self, inputMsg: PTRPCDynamicQueryFunctionMessage ) -> PTRPCDynamicQueryFunctionMessageResponse:
37+
fileResponse = PTRPCDynamicQueryFunctionMessageResponse(Success=False)
38+
file_resp = await SendMythicRPCFileSearch(
39+
MythicRPCFileSearchMessage(
40+
CallbackID=inputMsg.Callback,
41+
LimitByCallback=False,
42+
Filename="",
43+
)
44+
)
45+
if file_resp.Success:
46+
file_names = []
47+
for f in file_resp.Files:
48+
if f.Filename not in file_names:
49+
file_names.append(f.Filename)
50+
fileResponse.Success = True
51+
fileResponse.Choices = file_names
52+
return fileResponse
53+
else:
54+
fileResponse.Error = file_resp.Error
55+
return fileResponse
56+
1857
async def parse_arguments(self):
1958
if len(self.command_line) == 0:
2059
raise Exception("No arguments given.")
@@ -39,21 +78,39 @@ async def create_go_tasking(self, taskData: PTTaskMessageAllData) -> PTTaskCreat
3978
TaskID=taskData.Task.ID,
4079
Success=True,
4180
)
42-
file_resp = await SendMythicRPCFileSearch(MythicRPCFileSearchMessage(
43-
TaskID=taskData.Task.ID,
44-
AgentFileID=taskData.args.get_arg("file")
45-
))
46-
if file_resp.Success:
47-
original_file_name = file_resp.Files[0].Filename
81+
if taskData.args.get_parameter_group_name() == "Add New File":
82+
file_resp = await SendMythicRPCFileSearch(MythicRPCFileSearchMessage(
83+
TaskID=taskData.Task.ID,
84+
AgentFileID=taskData.args.get_arg("file")
85+
))
86+
if file_resp.Success:
87+
original_file_name = file_resp.Files[0].Filename
88+
else:
89+
raise Exception("Failed to fetch uploaded file from Mythic (ID: {})".format(taskData.args.get_arg("file")))
90+
taskData.args.add_arg("file_name", original_file_name, parameter_group_info=[ParameterGroupInfo(
91+
group_name="Add New File"
92+
)])
93+
taskData.args.add_arg("file_id", taskData.args.get_arg("file"), parameter_group_info=[ParameterGroupInfo(
94+
group_name="Add New File"
95+
)])
96+
response.DisplayParams = original_file_name
4897
else:
49-
raise Exception("Failed to fetch uploaded file from Mythic (ID: {})".format(taskData.args.get_arg("file")))
50-
51-
taskData.args.add_arg("file_name", original_file_name)
52-
53-
taskData.args.add_arg("file_id", taskData.args.get_arg("file"))
54-
55-
response.DisplayParams = original_file_name
56-
98+
file_resp = await SendMythicRPCFileSearch(MythicRPCFileSearchMessage(
99+
TaskID=taskData.Task.ID,
100+
Filename=taskData.args.get_arg("existingFile"),
101+
MaxResults=1,
102+
))
103+
if not file_resp.Success:
104+
raise Exception("Failed to fetch find file from Mythic (name: {})".format(taskData.args.get_arg("existingFile")))
105+
response.DisplayParams = file_resp.Files[0].Filename
106+
taskData.args.add_arg("file_name", file_resp.Files[0].Filename, parameter_group_info=[ParameterGroupInfo(
107+
group_name="Use Existing File"
108+
)])
109+
taskData.args.add_arg("file_id", file_resp.Files[0].AgentFileId, parameter_group_info=[ParameterGroupInfo(
110+
group_name="Use Existing File"
111+
)])
112+
taskData.args.remove_arg("existingFile")
113+
57114
return response
58115

59116
async def process_response(self, task: PTTaskMessageAllData, response: any) -> PTTaskProcessResponseMessageResponse:

agent_capabilities.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"architectures": ["x86_64"],
1212
"c2": ["http", "smb", "tcp", "websocket"],
1313
"mythic_version": "3.3.1-rc42",
14-
"agent_version": "2.3.1",
14+
"agent_version": "2.3.7",
1515
"supported_wrappers": ["service_wrapper", "scarecrow_wrapper"]
1616
}

0 commit comments

Comments
 (0)