mirror of
https://github.com/Aryma-f4/Ares-mythic.git
synced 2026-06-14 05:34:11 +00:00
fix(builder): improve artifact packaging with optional helper support
Update move_first_existing function to handle optional artifacts gracefully instead of raising FileNotFoundError. When optional artifacts are missing, append informative messages to stdout_err instead of failing the build. Also update agent icons to reference external PNG files instead of embedded base64 data for better maintainability.
This commit is contained in:
@@ -648,12 +648,17 @@ NOTE: v2.3.2+ uses a different BOF loader than v2.3.1 and they are not compatibl
|
||||
StepSuccess=True
|
||||
))
|
||||
resp.status = BuildStatus.Success
|
||||
def move_first_existing(candidates, target_path):
|
||||
missing_optional_artifacts = []
|
||||
|
||||
def move_first_existing(candidates, target_path, required=False):
|
||||
for candidate in candidates:
|
||||
if os.path.exists(candidate):
|
||||
shutil.move(candidate, target_path)
|
||||
return
|
||||
raise FileNotFoundError(f"Unable to locate artifact for {target_path}: {candidates}")
|
||||
return True
|
||||
if required:
|
||||
raise FileNotFoundError(f"Unable to locate artifact for {target_path}: {candidates}")
|
||||
missing_optional_artifacts.append((target_path, candidates))
|
||||
return False
|
||||
|
||||
targetExeAsmPath = "/srv/ExecuteAssembly.exe"
|
||||
targetPowerPickPath = "/srv/PowerShellHost.exe"
|
||||
@@ -685,6 +690,10 @@ NOTE: v2.3.2+ uses a different BOF loader than v2.3.1 and they are not compatibl
|
||||
f"{agent_build_path.name}/{buildPath}/AresInterop.dll",
|
||||
f"{agent_build_path.name}/AresInterop/bin/Release/net451/AresInterop.dll",
|
||||
], targetInteropPath)
|
||||
if missing_optional_artifacts:
|
||||
stdout_err += "\nOptional helper artifacts were not packaged:\n" + "\n".join(
|
||||
f"{target}: {candidates}" for target, candidates in missing_optional_artifacts
|
||||
)
|
||||
if self.get_parameter('output_type') == "Source":
|
||||
shutil.make_archive(f"/tmp/{agent_build_path.name}/source", "zip", f"{agent_build_path.name}")
|
||||
await SendMythicRPCPayloadUpdatebuildStep(MythicRPCPayloadUpdateBuildStepMessage(
|
||||
|
||||
Reference in New Issue
Block a user