Monarch C2
  • Introduction to Monarch
  • Installation
    • Resources
    • Uninstall Monarch
  • Interface
  • Features
    • External integration
    • Multiplayer
    • Management (server)
    • HTTP customization
  • Architecture
  • Usage
    • Builders
    • Agents
    • Listeners
    • Stage
    • Sessions
    • Players (server)
    • Chat
  • Integration
    • Project configuration
    • Builder
      • Architecture
      • API
      • Build routine
      • Build service
    • C2 server
      • Registering implants
      • Talking to implants
    • Implant development
      • Registration
      • Tasks
      • The TCP handler
Powered by GitBook
On this page
  1. Integration
  2. Builder

API

Last updated 1 year ago

Monarch build services leverage the python package for handling build requests. Under the hood, a build service is a simple HTTP server that handles post requests from the build client that comes pre-installed in monarch builder containers.

Each request is automatically reformatted into a BuildRequest object, predefined by the monarch package, that contains the build parameters as a dictionary of values.

class BuildRequest:
    def __init__(self, params: dict):
        """
        An object representing a build request received from the main C2 server.
        :param params: a dictionary of build parameters.
        """
        self.params = params

After this, a registered callback, your build routine, is called with the BuildRequest passed as a parameter. Your callback is expected to return a BuildResponse object, which tells Monarch's build client whether build was successful, if any errors were reported, and if none, the actual binary that was built.

class BuildResponse:
    def __init__(self, status: int, error: str, build: str):
        """
        An object representing a response to a build request received from the main C2 server.
        A build would typically end with a status (STATUS_SUCCESS | STATUS_ERROR), an error message (if applicable),
        and the binary or file produced by the build.
        :param status: build status, either STATUS_SUCCESS or STATUS_ERROR
        :param error: build error message, if any
        :param build: the build file. If multiple files are produced, then return an archive.
        """
        self.status = status
        self.error = error
        self.build = build
monarch-c2-sdk