mirror of
https://github.com/Aryma-f4/Ares-mythic.git
synced 2026-06-12 17:54:11 +00:00
- Use absolute path to pyinstaller executable to avoid PATH issues - Add --clean flag to prevent permission problems with cache - Fix Windows registry path escaping in persistence mechanism - Include generated build artifacts (spec, config, warnings, PYZ toc) - Add base_library.zip for standalone executable distribution
84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Build script for Ares BlueHammer Mythic agent
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import shutil
|
|
from pathlib import Path
|
|
|
|
def build_agent():
|
|
"""Build the Mythic agent"""
|
|
print("[Build] Building Ares BlueHammer agent...")
|
|
|
|
# Load configuration
|
|
config_path = Path("hammer_agent_config.json")
|
|
if not config_path.exists():
|
|
print("[Error] Configuration file not found")
|
|
return False
|
|
|
|
with open(config_path, 'r') as f:
|
|
config = json.load(f)
|
|
|
|
# Create build directory
|
|
build_dir = Path("build")
|
|
build_dir.mkdir(exist_ok=True)
|
|
|
|
# Copy agent files
|
|
agent_files = ["hammer_agent.py", "hammer_agent_config.json"]
|
|
for file in agent_files:
|
|
if Path(file).exists():
|
|
shutil.copy2(file, build_dir / file)
|
|
|
|
# Build with PyInstaller
|
|
try:
|
|
build_cmd = [
|
|
"/Users/dsi/Library/Python/3.14/bin/pyinstaller", "--onefile", "--console",
|
|
"--name", "AresAgent",
|
|
"--distpath", str(build_dir / "dist"),
|
|
"--workpath", str(build_dir / "build"),
|
|
"--clean", # Clean cache to avoid permission issues
|
|
"hammer_agent.py"
|
|
]
|
|
|
|
result = subprocess.run(build_cmd, capture_output=True, text=True, cwd=build_dir)
|
|
|
|
if result.returncode != 0:
|
|
print(f"[Error] Build failed: {result.stderr}")
|
|
return False
|
|
|
|
print("[Build] Agent built successfully!")
|
|
|
|
# Create deployment package
|
|
deploy_dir = build_dir / "deploy"
|
|
deploy_dir.mkdir(exist_ok=True)
|
|
|
|
# Copy built executable
|
|
built_exe = build_dir / "dist" / "AresAgent.exe"
|
|
if built_exe.exists():
|
|
shutil.copy2(built_exe, deploy_dir / "AresAgent.exe")
|
|
|
|
# Create deployment manifest
|
|
deploy_manifest = {
|
|
"agent_name": config["name"],
|
|
"version": config["version"],
|
|
"files": ["AresAgent.exe"],
|
|
"install_script": "install.bat"
|
|
}
|
|
|
|
with open(deploy_dir / "deploy.json", 'w') as f:
|
|
json.dump(deploy_manifest, f, indent=2)
|
|
|
|
print("[Build] Deployment package created!")
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"[Error] Build failed: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = build_agent()
|
|
sys.exit(0 if success else 1) |