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:
Aryma committed 2026-04-15 05:54:00 +07:00
1 parent 0c209d7201
commit dfb7ea177c
5 files changed
+18 -9

No files matched your search

@@ -648,12 +648,17 @@ NOTE: v2.3.2+ uses a different BOF loader than v2.3.1 and they are not compatibl
StepSuccess=True StepSuccess=True
)) ))
resp.status = BuildStatus.Success 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: for candidate in candidates:
if os.path.exists(candidate): if os.path.exists(candidate):
shutil.move(candidate, target_path) shutil.move(candidate, target_path)
return return True
raise FileNotFoundError(f"Unable to locate artifact for {target_path}: {candidates}") 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" targetExeAsmPath = "/srv/ExecuteAssembly.exe"
targetPowerPickPath = "/srv/PowerShellHost.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}/{buildPath}/AresInterop.dll",
f"{agent_build_path.name}/AresInterop/bin/Release/net451/AresInterop.dll", f"{agent_build_path.name}/AresInterop/bin/Release/net451/AresInterop.dll",
], targetInteropPath) ], 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": if self.get_parameter('output_type') == "Source":
shutil.make_archive(f"/tmp/{agent_build_path.name}/source", "zip", f"{agent_build_path.name}") shutil.make_archive(f"/tmp/{agent_build_path.name}/source", "zip", f"{agent_build_path.name}")
await SendMythicRPCPayloadUpdatebuildStep(MythicRPCPayloadUpdateBuildStepMessage( await SendMythicRPCPayloadUpdatebuildStep(MythicRPCPayloadUpdateBuildStepMessage(
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="218" height="250" viewBox="0 0 218 250"> <svg xmlns="http://www.w3.org/2000/svg" width="218" height="250" viewBox="0 0 218 250">
<image width="218" height="250" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANoAAAD6CAYAAADHsVntAAAgAElEQVR4Xu19ebxVxZXuVUPkqShxtokM0TgCQY2tGOMUR5xnQcVAJ0GMwRCeNjaYx1NoaX2EQIxokoaICmqcRRzjFCPaRiUMTtEwGFqccXwYoukftc5Hbn3sdVbtffY598Jd55999t61a9deVV99tVatWrVOU4N+nbt2+3ueVy1euGCdPOk9rUtgpQRaaztrWGNurQLw5rl2SaC1trMygZbJWJ27dgs1efIZ5yTV6G+uuzKkc0ZLEpcnIgkAaAXamybLUjBSSiaVEjrQvNm3uATaDNCO6zsoEvbQYTGT3Xn7/dH9V199JTq/ffrVOC+zE2jxBuAFaJgEQofP7XC77baPCnDMcYdG5+PHyUgKv7LbYZmNOfMDHWgNa2D+IpFA2wDaHLine truncated <image href="/static/XF-09_Ares.png" width="218" height="250" preserveAspectRatio="xMidYMid meet" />
</svg> </svg>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 198 B

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="218" height="250" viewBox="0 0 218 250"> <svg xmlns="http://www.w3.org/2000/svg" width="218" height="250" viewBox="0 0 218 250">
<image width="218" height="250" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANoAAAD6CAYAAADHsVntAAAgAElEQVR4Xu19ebxVxZXuVUPkqShxtokM0TgCQY2tGOMUR5xnQcVAJ0GMwRCeNjaYx1NoaX2EQIxokoaICmqcRRzjFCPaRiUMTtEwGFqccXwYoukftc5Hbn3sdVbtffY598Jd55999t61a9deVV99tVatWrVOU4N+nbt2+3ueVy1euGCdPOk9rUtgpQRaaztrWGNurQLw5rl2SaC1trMygZbJWJ27dgs1efIZ5yTV6G+uuzKkc0ZLEpcnIgkAaAXamybLUjBSSiaVEjrQvNm3uATaDNCO6zsoEvbQYTGT3Xn7/dH9V199JTq/ffrVOC+zE2jxBuAFaJgEQofP7XC77baPCnDMcYdG5+PHyUgKv7LbYZmNOfMDHWgNa2D+IpFA2wDaHLine truncated <image href="/static/XF-09_Ares.png" width="218" height="250" preserveAspectRatio="xMidYMid meet" />
</svg> </svg>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 198 B

+2 -2
View File
@@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="218" height="250" viewBox="0 0 218 250"> <svg xmlns="http://www.w3.org/2000/svg" width="218" height="250" viewBox="0 0 218 250">
<image width="218" height="250" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANoAAAD6CAYAAADHsVntAAAgAElEQVR4Xu19ebxVxZXuVUPkqShxtokM0TgCQY2tGOMUR5xnQcVAJ0GMwRCeNjaYx1NoaX2EQIxokoaICmqcRRzjFCPaRiUMTtEwGFqccXwYoukftc5Hbn3sdVbtffY598Jd55999t61a9deVV99tVatWrVOU4N+nbt2+3ueVy1euGCdPOk9rUtgpQRaaztrWGNurQLw5rl2SaC1trMygZbJWJ27dgs1efIZ5yTV6G+uuzKkc0ZLEpcnIgkAaAXamybLUjBSSiaVEjrQvNm3uATaDNCO6zsoEvbQYTGT3Xn7/dH9V199JTq/ffrVOC+zE2jxBuAFaJgEQofP7XC77baPCnDMcYdG5+PHyUgKv7LbYZmNOfMDHWgNa2D+IpFA2wDaHLine truncated <image href="/static/XF-09_Ares.png" width="218" height="250" preserveAspectRatio="xMidYMid meet" />
</svg> </svg>

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 198 B