C2 Docker Containers
Last updated
Last updated
All C2 profiles are backed by a Docker container or intermediary layer of some sort.
What do the C2 docker containers do? Why are things broken out this way? In order to make things more modular within Mythic, most services are broken out into their own containers. When it comes to C2 profiles, they simply serve as an intermediary layer that translates between your special sauce C2 mechanism and the normal RESTful interface that Mythic uses. This allows you to create any number of completely disjoint C2 types without having to modify anything in the main Mythic codebase.
There are a few things needed to make a C2 container. For this example, let's assume the name of the C2 profile is ABC
:
Make the following folder structure by copying Example_C2_Profile
as ABC
under /Mythic/C2_Profiles/
. The result should look like:
2. Within c2_code should be a file called server
(this is what will be executed when you select to start the c2 profile. If you want this to pick up something from the environment, be sure to put it as a #!
at the top. For example, the default containers leverage python3, so they have #! /usr/bin/env python3
at the top. This file is always executed via bash, so as a sub-process like ./server
3. Within c2_code should be a file called config.json
, this is what the operator is able to edit through the UI and should contain all of the configuration components. The one piece that doesn't need to be here are if the operator needs to add additional files (like SSL certs). There are too many security concerns and processes that go into arbitrary file upload currently that make this process require you to ssh into the host where Mythic is running and put the files there manually. This might change in the future, but that's the current expectation.
4. Within ABC
there should be a Dockerfile
that sets up your environment. In most cases, you'll simply start it off with:
But you can customize this as well
5. Within the mythic
folder are all the basic files for processing tasking. The rabbitmq_config.json
file is fine being left alone if you're doing a local Docker container. If you're turning another computer into your C2 container, similar to what you can do with Payload Types, then this will need to be modified in the same way as Payload Type Development.
6. Within the mythic
folder is the c2_functions
folder. This is analogous to the agent_functions
folder within Payload Types. This is where you'll put your Python files that define the C2 Profile metadata and establish any RPC functions you want to expose to other containers. This technically allows you to chain C2 containers together for RPC calls.
7. You can now start the C2 profile container from the command line via sudo ./start_c2_profiles.sh ABC
. This will start the container and have it sending heartbeats to the main Mythic instance. If you already have the C2 profile registered in the UI, you'll now see the docker container light turn green.
At this point though, the container is checking in and can be tasked, but there's no inner logic that's going on to actually translate anything for a C2 profile.
Within the /Mythic/C2_Profiles/ABC/mythic/c2_functions
folder is a python file (name doesn't matter, typically matches the c2 profile name though) with a new class that extends the base C2 Profile class. An example would be:
This is a small class that just defines the metadata aspects of the C2 profile. The main piece here is the definition of the parameters
array. Each element here is a C2ProfileParameter
class instance with a few possible arguments: