Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.
25 changes: 25 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build

on: [pull_request, push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Install Qt
uses: jurplel/install-qt-action@v3

- name: Build teamserver
run: make ts-build

- name: Build client
run: make client-build
26 changes: 21 additions & 5 deletions client/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@ ifndef VERBOSE
.SILENT:
endif

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

# Check the value of BRANCH and set a target accordingly
ifeq ($(BRANCH), main)
TARGET_BRANCH := main
else ifeq ($(BRANCH), dev)
TARGET_BRANCH := dev
else
TARGET_BRANCH := dev
endif


all:
@ mkdir build; cd build; cmake ..
@ if [ -d "Modules" ]; then echo "Modules installed"; else git clone https://github.com/HavocFramework/Modules Modules; fi
@ cmake --build build -- -j 4
@ git submodule update --init --recursive
@ mkdir -p Build; cd Build; cmake ..
@ if [ -d "Modules" ]; then echo "Modules installed"; else git clone --recurse-submodules https://github.com/HavocFramework/Modules Modules --single-branch --branch $(TARGET_BRANCH); fi
@ cmake --build Build -- -j 4

clean:
@ rm -rf build
@ rm -rf Build
@ rm -rf ../data/client.db
@ rm -rf .idea
@ rm -rf cmake-build-debug
@ rm -rf modules
@ rm -rf Havoc
@ rm -rf Modules


33 changes: 5 additions & 28 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,22 @@ all: ts-build client-build

# teamserver building target
ts-build:
@ echo "[*] building teamserver"
@ ./teamserver/Install.sh
@ cd teamserver; GO111MODULE="on" go build -ldflags="-s -w -X cmd.VersionCommit=$(git rev-parse HEAD)" -o ../havoc main.go
@ sudo setcap 'cap_net_bind_service=+ep' havoc # this allows you to run the server as a regular user
@ make -C teamserver ts-build

dev-ts-compile:
@ echo "[*] compile teamserver"
@ cd teamserver; GO111MODULE="on" go build -ldflags="-s -w -X cmd.VersionCommit=$(git rev-parse HEAD)" -o ../havoc main.go
@ make -C teamserver dev-ts-compile

ts-cleanup:
@ echo "[*] teamserver cleanup"
@ rm -rf ./teamserver/bin
@ rm -rf ./data/loot
@ rm -rf ./data/x86_64-w64-mingw32-cross
@ rm -rf ./data/havoc.db
@ rm -rf ./data/server.*
@ rm -rf ./teamserver/.idea
@ rm -rf ./havoc
@ make -C teamserver clean

# client building and cleanup targets
client-build:
@ echo "[*] building client"
@ git submodule update --init --recursive
@ mkdir client/Build; cd client/Build; cmake ..
@ if [ -d "client/Modules" ]; then echo "Modules installed"; else git clone --recurse-submodules https://github.com/HavocFramework/Modules client/Modules --single-branch --branch `git rev-parse --abbrev-ref HEAD`; fi
@ cmake --build client/Build -- -j 4
@ make -C client

client-cleanup:
@ echo "[*] client cleanup"
@ rm -rf ./client/Build
@ rm -rf ./client/Bin/*
@ rm -rf ./client/Data/database.db
@ rm -rf ./client/.idea
@ rm -rf ./client/cmake-build-debug
@ rm -rf ./client/Havoc
@ rm -rf ./client/Modules

@ make -C client clean

# cleanup target
clean: ts-cleanup client-cleanup
@ rm -rf ./data/*.db
@ rm -rf payloads/Demon/.idea
61 changes: 48 additions & 13 deletions teamserver/Install.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,57 @@
#!/bin/bash

if [ ! -d "dir/x86_64-w64-mingw32-cross" ]; then
sudo apt -qq --yes install golang-go nasm mingw-w64 wget >/dev/null 2>&1
set -e

if [ ! -d "data" ]; then
mkdir data
fi
MYDIR=$(pwd)

if [ ! -f /tmp/mingw-musl-64.tgz ]; then
wget https://musl.cc/x86_64-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-64.tgz
fi
# Check if the script is in the "teamserver" directory and adjust the current directory
if [ "$(basename "$MYDIR")" == "teamserver" ]; then
cd ..
fi

# Check Linux distribution
if [ -x "$(command -v lsb_release)" ]; then
DISTRIBUTION=$(lsb_release -si)
else
DISTRIBUTION=$(cat /etc/os-release | grep "^ID=" | cut -d'=' -f2 | tr -d '"')
fi

tar zxf /tmp/mingw-musl-64.tgz -C data
# Check if DISTRIBUTION is defined
if [ -n "$DISTRIBUTION" ]; then
if [ "$DISTRIBUTION" == "Ubuntu" ] || [ "$DISTRIBUTION" == "Debian" ]; then
echo "Installing required packages on $DISTRIBUTION..."
sudo apt -qq --yes install golang-go nasm mingw-w64 wget >/dev/null 2>&1 || { echo "Error: Failed to install required packages."; exit 1; }
else
echo "Warning: Unsupported distribution: $DISTRIBUTION. Please manual install the required packages."
fi
else
echo "Warning: Failed to determine the OS. Please manual install the required packages."
fi

# Check and download cross-compiler packages if not present
if [ ! -d "data/x86_64-w64-mingw32-cross" ]; then
# Check if wget is available
if ! command -v wget &>/dev/null; then
echo "Error: wget is not installed. Please install wget and run the script again."
exit 1
fi

if [ ! -f /tmp/mingw-musl-32.tgz ]; then
wget https://musl.cc/i686-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-32.tgz
fi
# Create data directory if it doesn't exist
if [ ! -d "data" ]; then
mkdir data || { echo "Error: Failed to create directory 'data'"; exit 1; }
fi

tar zxf /tmp/mingw-musl-32.tgz -C data
# Download and extract x86_64-w64-mingw32-cross.tgz
if [ ! -f /tmp/mingw-musl-64.tgz ]; then
wget https://musl.cc/x86_64-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-64.tgz || { echo "Error: Failed to download https://musl.cc/x86_64-w64-mingw32-cross.tgz"; exit 1; }
fi
tar zxf /tmp/mingw-musl-64.tgz -C data || { echo "Error: Failed to extract /tmp/mingw-musl-64.tgz"; exit 1; }

# Download and extract i686-w64-mingw32-cross.tgz
if [ ! -f /tmp/mingw-musl-32.tgz ]; then
wget https://musl.cc/i686-w64-mingw32-cross.tgz -q -O /tmp/mingw-musl-32.tgz || { echo "Error: Failed to download https://musl.cc/i686-w64-mingw32-cross.tgz"; exit 1; }
fi
tar zxf /tmp/mingw-musl-32.tgz -C data || { echo "Error: Failed to extract /tmp/mingw-musl-32.tgz"; exit 1; }
fi

cd "$MYDIR"
26 changes: 26 additions & 0 deletions teamserver/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
MAKEFLAGS += -s

ifndef VERBOSE
.SILENT:
endif

# teamserver building target
ts-build:
@ echo "[*] building teamserver"
@ GO111MODULE="on" go build -ldflags="-s -w -X cmd.VersionCommit=$(git rev-parse HEAD)" -o ../havoc main.go
@ sudo setcap 'cap_net_bind_service=+ep' ../havoc # this allows you to run the server as a regular user

dev-ts-compile:
@ echo "[*] compile teamserver"
@ GO111MODULE="on" go build -ldflags="-s -w -X cmd.VersionCommit=$(git rev-parse HEAD)" -o ../havoc main.go

clean:
@ rm -rf ../data/loot
@ rm -rf ../data/x86_64-w64-mingw32-cross
@ rm -rf ../data/i686-w64-mingw32-cross
@ rm -rf ../data/teamserver.db
@ rm -rf ../data/server.*
@ rm -rf .idea
@ rm -rf ../havoc
@ rm -rf /tmp/mingw-musl-64.tgz
@ rm -rf /tmp/mingw-musl-32.tgz