mirror of
https://github.com/Aryma-f4/Ares-mythic.git
synced 2026-06-13 10:24:12 +00:00
fix(builder): handle multiple possible artifact paths during build
The build process previously assumed artifacts were located in a single directory. However, due to project structure changes, artifacts may now be in different locations. This change adds a helper function to try multiple candidate paths for each artifact, moving the first existing file to the target location. This ensures compatibility across different build configurations.
This commit is contained in:
@@ -648,18 +648,43 @@ 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):
|
||||
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}")
|
||||
|
||||
targetExeAsmPath = "/srv/ExecuteAssembly.exe"
|
||||
targetPowerPickPath = "/srv/PowerShellHost.exe"
|
||||
targetScreenshotInjectPath = "/srv/ScreenshotInject.exe"
|
||||
targetKeylogInjectPath = "/srv/KeylogInject.exe"
|
||||
targetExecutePEPath = "/srv/ExecutePE.exe"
|
||||
targetInteropPath = "/srv/AresInterop.dll"
|
||||
shutil.move(f"{agent_build_path.name}/{buildPath}/ExecuteAssembly.exe", targetExeAsmPath)
|
||||
shutil.move(f"{agent_build_path.name}/{buildPath}/PowerShellHost.exe", targetPowerPickPath)
|
||||
shutil.move(f"{agent_build_path.name}/{buildPath}/ScreenshotInject.exe", targetScreenshotInjectPath)
|
||||
shutil.move(f"{agent_build_path.name}/{buildPath}/KeylogInject.exe", targetKeylogInjectPath)
|
||||
shutil.move(f"{agent_build_path.name}/{buildPath}/ExecutePE.exe", targetExecutePEPath)
|
||||
shutil.move(f"{agent_build_path.name}/{buildPath}/AresInterop.dll", targetInteropPath)
|
||||
move_first_existing([
|
||||
f"{agent_build_path.name}/{buildPath}/ExecuteAssembly.exe",
|
||||
f"{agent_build_path.name}/ExecuteAssembly/bin/Release/net451/ExecuteAssembly.exe",
|
||||
], targetExeAsmPath)
|
||||
move_first_existing([
|
||||
f"{agent_build_path.name}/{buildPath}/PowerShellHost.exe",
|
||||
f"{agent_build_path.name}/PowerShellHost/bin/Release/net451/PowerShellHost.exe",
|
||||
], targetPowerPickPath)
|
||||
move_first_existing([
|
||||
f"{agent_build_path.name}/{buildPath}/ScreenshotInject.exe",
|
||||
f"{agent_build_path.name}/ScreenshotInject/bin/Release/net451/ScreenshotInject.exe",
|
||||
], targetScreenshotInjectPath)
|
||||
move_first_existing([
|
||||
f"{agent_build_path.name}/{buildPath}/KeylogInject.exe",
|
||||
f"{agent_build_path.name}/KeylogInject/bin/Release/net451/KeylogInject.exe",
|
||||
], targetKeylogInjectPath)
|
||||
move_first_existing([
|
||||
f"{agent_build_path.name}/{buildPath}/ExecutePE.exe",
|
||||
f"{agent_build_path.name}/ExecutePE/bin/Release/net451/ExecutePE.exe",
|
||||
], targetExecutePEPath)
|
||||
move_first_existing([
|
||||
f"{agent_build_path.name}/{buildPath}/AresInterop.dll",
|
||||
f"{agent_build_path.name}/AresInterop/bin/Release/net451/AresInterop.dll",
|
||||
], targetInteropPath)
|
||||
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