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. Implant development

Registration

Last updated 1 year ago

CtrlK

Registration is defined as the first time an agent connects to a server to authenticate. Each connection is given a token that runs on a time limit. If an operator hasn't administered a request for a period of time, the token will expire, resulting in a 401 response, and the agent will need to re-authenticate. Your agent must be capable of re-registering with the server, otherwise you will have to restart the binary itself.

Your implant should be able to handle several possible scenarios:

  • Server goes offline unexpectedly (connection-refused) - the implant should attempt to reconnect until it is able to establish a session again

  • The session expires (401) - the implant should authenticate at the registration endpoint once again.

  • The compromised machine restarts - assuming a persistence mechanism is already in place, the implant should know to re-register to the server.

  • Here is a simple logic example from an early version of 'Empress', Monarch's first implant integration written in Go.

    The server integration page goes into more detail about how registration and polling objects are structured.

    // c is our c2 client
    resp, err := c.HttpClient.Do(req)
    if err != nil {
    	return Registration(), err
    }
    if resp.StatusCode != http.StatusOK {
    	// probably unauthorised, must re-register.
    	// Registration() returns a registration object
    
    reg := Registration()
    return reg, nil
    }