Hak5 Cloud C2 as a service on a Ubuntu server (or alike) without domain name or https

First, make sure that the C2 instance runs without any problems when started manually from the command line. The C2 instance also has to be fully set up with a registered/valid license.

A good advise is to rename the executable C2 binary so that the service doesn't have to be renamed for every new version, for example rename to:
c2_community_linux64

Move the Cloud C2 binary to a more suitable location in the file system
sudo mv c2_community_linux64 /usr/local/bin

Create a directory for database file
sudo mkdir /var/cloudc2

Move the database file
sudo mv c2.db /var/cloudc2/

Create a systemd service file for Cloud C2
sudo nano /etc/systemd/system/cloudc2.service

Add the lines below (replace parameters as necessary for this specific C2 instance if needed)

[Unit]
Description=Hak5 Cloud C2
After=cloudc2.service
[Service]
Type=idle
ExecStart=/usr/local/bin/c2_community_linux64 -hostname <ip address> -db /var/cloudc2/c2.db
[Install]
WantedBy=multi-user.target

Run the following commands to reload, enable on boot, start and inspect the newly created Cloud C2 service
sudo systemctl daemon-reload
sudo systemctl enable cloudc2.service
sudo systemctl start cloudc2.service
sudo systemctl status cloudc2.service

Reboot the server and verify that Cloud C2 is available as a service (i.e. browse to the C2 instance)

It's also possible to ssh into the server and run ps ax and look for the C2 process

If the C2 service does not start (can be checked with the same command as above: sudo systemctl status cloudc2.service) then it might be a fact that the service tries to start before the server has gotten a connection to the internet, hence not possible for it to validate the C2 license and therefore the service will not start. In that case, it's possible to add a sleep in the service to let it sleep for a specified amount of time before the C2 instance starts. In the [Service] section, add the following line before ExecStart (adjust the time as needed)
ExecStartPre=/bin/sleep 30

Save and reboot the server again... Verify...

(Based on information in the 2703 episode Hak5 video by Darren)

Popular posts from this blog

Hak5 Cloud C2 on a Raspberry Pi

Hak5 Cloud C2 as a Windows service

Project name: WEIRDFEED