Skip to content

Commit

Permalink
added models prebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
checkymander committed Jan 23, 2025
1 parent ca8c90d commit f1c16ad
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Payload_Type/athena/athena/mythic/agent_functions/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class athena(PayloadType):
BuildStep(step_name="Configure C2 Profiles", step_description="Configuring C2 Profiles"),
BuildStep(step_name="Configure Agent", step_description="Updating the Agent Configuration"),
BuildStep(step_name="Add Tasks", step_description="Adding built-in commands to the agent"),
BuildStep(step_name="Compile Models Dll", step_description="Compiling Models DLL"),
BuildStep(step_name="Compile", step_description="Compiling final executable"),
BuildStep(step_name="Zip", step_description="Zipping final payload"),
]
Expand Down Expand Up @@ -373,6 +374,12 @@ async def getBuildCommand(self, rid):
self.get_parameter("output-type") == "windows service",
self.get_parameter("assemblyname")
)
async def getBuildCommentModels(self):
return "dotnet build Agent.Models -c {} /p:Obfuscate={} /p:PayloadUUID={}".format(
self.get_parameter("configuration"),
self.get_parameter("obfuscate"),
self.get_parameter(self.uuid)
)

async def build(self) -> BuildResponse:
# self.Get_Parameter returns the values specified in the build_parameters above.
Expand Down Expand Up @@ -494,12 +501,28 @@ async def build(self) -> BuildResponse:

await self.updateRootsFile(agent_build_path, roots_replace)



if self.get_parameter("output-type") == "source":
shutil.make_archive(f"{agent_build_path.name}/output", "zip", f"{agent_build_path.name}")
return await self.returnSuccess(resp, "File built succesfully!", agent_build_path)

mCommand = self.getBuildCommentModels()

try:
mProc = await asyncio.create_subprocess_shell(mCommand, stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
cwd=agent_build_path.name)
except:
build_stdout, build_stderr = await proc.communicate()
logger.critical(e)
logger.critical("command: {}".format(command))
return await self.returnFailure(resp, str(traceback.format_exc()), e)

await SendMythicRPCPayloadUpdatebuildStep(MythicRPCPayloadUpdateBuildStepMessage(
PayloadUUID=self.uuid,
StepName="Compile Models Dll",
StepStdout="Successfully compiled models dll",
StepSuccess=True
))

command = await self.getBuildCommand(rid)

Expand Down

0 comments on commit f1c16ad

Please sign in to comment.