Compilation
Goauld can build the server, client, full agent, agent stager, and Windows DLL from the same source tree. For normal agent builds, use tealc compile; use direct Go compilation or the build wrapper when developing Goauld itself.
Recommended workflow
With a client binary built using the client build tag, compile the required component with:
tealc compile --id COMPONENT
Valid component IDs are client, server, agent, agent-mini, and agent.dll.
For example, compile a Windows AMD64 agent with:
tealc compile --id agent --goos windows --goarch amd64
tealc compile handles compile-time configuration and writes its output below output/. See Compile agent for build variables and agent-specific options.
Optional build dependencies
garblefor binary obfuscation (https://github.com/burrowers/garble)upxfor binary compression https://github.com/upx/upxgoreleaserfor automated builds https://github.com/goreleaser/goreleaser
The project can also be built using GoReleaser.
When obfuscation is enabled, Garble must be built for the same Go toolchain
version used by the build. Garble patches parts of the Go linker; a Garble
binary built against a different patch release can fail with a modified-linker
or tool-version mismatch. If this occurs, reinstall or rebuild Garble after
selecting the exact go version used for the compilation.
Build tags
Some component variants require a Go build tag:
client:-tags clientagent-mini:-tags miniagent-dll:-tags dll
The client tag embeds the source tree that tealc compile uses to build components on demand. A client built without this tag can start normally, but tealc compile fails because the embedded source is unavailable.
agent-mini is a small stager that downloads the full agent from the server over the encrypted control channel and executes it. This is separate from the /binaries/ endpoint described in Agent downloading.
Agent
Use tealc compile for normal agent builds. The following source-build methods are useful during development.
Direct compilation
go build -o goauld ./agent
Use this for simple builds without customization.
Using the wrapper script
go run ./scripts/build/ --id agent --goos windows --goarch amd64 --no-seed --gen-age-key=false --gen-access-token=false
Use this for fine-grained control over build parameters.
Building as a Windows DLL
A DLL can be loaded by another process instead of executed as a standalone binary. This build requires CGO and the c-shared build mode.
go build -tags dll -buildmode=c-shared -o goauld.dll ./agent
With tealc compile, use --id agent.dll.
Server
Direct compilation
go build -o goauld_server ./server
Using the wrapper script
go run ./scripts/build/ --gen-age-key=false --gen-access-token=false --id server --goos linux --goarch amd64 -vvv
Client
Direct compilation
go build -tags client -o tealc ./client
Using the wrapper script
go run ./scripts/build/ --gen-age-key=false --gen-access-token=false --id client --goos linux --goarch amd64 -vvv