diff --git a/Payload_Type/thanatos/Dockerfile b/Payload_Type/thanatos/Dockerfile index d67a684..e5ed1be 100644 --- a/Payload_Type/thanatos/Dockerfile +++ b/Payload_Type/thanatos/Dockerfile @@ -1,24 +1,41 @@ -# Build the Mythic server side code -FROM docker.io/library/golang:1.22-alpine as mythic-builder +### Image for building the server binary +FROM docker.io/library/golang:1.22-alpine as builder RUN apk update \ - && apk add binutils \ + && apk add \ + binutils \ + make \ + protoc \ + git \ && apk cache clean +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + RUN mkdir -p /usr/local/share/app WORKDIR /usr/local/share/app -COPY mythic . +COPY go.mod go.mod +COPY go.sum go.sum + +COPY Makefile Makefile +COPY protobuf protobuf + +COPY cmd cmd +COPY pkg pkg RUN go mod download +RUN make protobuf RUN go mod tidy -RUN go build -ldflags='-extldflags=-static' -o mythic-server . -RUN strip -s mythic-server +RUN make GOFLAGS=-ldflags=-extldflags=-static server +RUN strip -s server -# Pull in the base image for the payload builder + +### Image for running the server FROM docker.io/library/debian:bookworm-slim -# Install required system packages +COPY --from=builder /usr/local/share/app/server /usr/local/bin/thanatos-server +RUN chmod +x /usr/local/bin/thanatos-server + RUN dpkg --add-architecture i386 && \ apt-get update -y && apt-get install -y \ make \ @@ -32,19 +49,6 @@ RUN dpkg --add-architecture i386 && \ WORKDIR /tmp -# Install sccache -ENV SCCACHE_VERSION v0.7.4 -RUN curl -L \ - "https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" \ - -o sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz -RUN tar xf sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz -RUN mv sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache /usr/bin/sccache -RUN chmod +x /usr/bin/sccache -RUN rm -rf sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl -RUN rm -f sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz -ENV SCCACHE_DIR /Mythic/.cache/sccache - -# Install Rust with the required toolchains RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh \ && sh rustup.sh -y \ --profile minimal \ @@ -56,20 +60,13 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh \ RUN rm -f rustup.sh -# Copy the cargo config.toml -COPY .docker/config.toml /root/.cargo/config.toml ENV PATH=$PATH:/root/.cargo/bin RUN mkdir /thanatos WORKDIR /thanatos COPY agent agent +COPY assets assets +COPY browserscripts browserscripts -RUN mkdir mythic -WORKDIR /thanatos/mythic -COPY mythic/assets assets -COPY mythic/browserscript browserscript - -COPY --from=mythic-builder /opt/mythic/mythic-server . -RUN chmod +x ./mythic-server -CMD ["./mythic-server"] +CMD ["thanatos-server"] diff --git a/Payload_Type/thanatos/cmd/genconfig/main.go b/Payload_Type/thanatos/cmd/genconfig/main.go index 1eb6dfa..55410bf 100644 --- a/Payload_Type/thanatos/cmd/genconfig/main.go +++ b/Payload_Type/thanatos/cmd/genconfig/main.go @@ -46,7 +46,7 @@ func main() { } if finfo.IsDir() { - return errors.New("Input path is a directory") + return errors.New("input path is a directory") } inputFile = filePath diff --git a/Payload_Type/thanatos/go.mod b/Payload_Type/thanatos/go.mod index 3d52340..a74a377 100644 --- a/Payload_Type/thanatos/go.mod +++ b/Payload_Type/thanatos/go.mod @@ -5,6 +5,7 @@ go 1.22 require ( github.com/MythicMeta/MythicContainer v1.3.6 github.com/google/uuid v1.6.0 + golang.org/x/exp v0.0.0-20240213143201-ec583247a57a google.golang.org/protobuf v1.32.0 ) @@ -30,7 +31,6 @@ require ( github.com/spf13/viper v1.18.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect golang.org/x/net v0.21.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect diff --git a/Payload_Type/thanatos/pkg/commands/exit/exit_test.go b/Payload_Type/thanatos/pkg/commands/exit/exit_test.go index 69b4a49..7739227 100644 --- a/Payload_Type/thanatos/pkg/commands/exit/exit_test.go +++ b/Payload_Type/thanatos/pkg/commands/exit/exit_test.go @@ -3,7 +3,7 @@ package exit import ( "testing" - cmdtesting "github.com/MythicAgents/thanatos/commands/testing" + cmdtesting "github.com/MythicAgents/thanatos/pkg/commands/testing" ) var testCases = []cmdtesting.TestCase{ diff --git a/Payload_Type/thanatos/pkg/commands/sleep/sleep_test.go b/Payload_Type/thanatos/pkg/commands/sleep/sleep_test.go index 7a51883..780f87c 100644 --- a/Payload_Type/thanatos/pkg/commands/sleep/sleep_test.go +++ b/Payload_Type/thanatos/pkg/commands/sleep/sleep_test.go @@ -5,7 +5,7 @@ import ( "math" "testing" - cmdtesting "github.com/MythicAgents/thanatos/commands/testing" + cmdtesting "github.com/MythicAgents/thanatos/pkg/commands/testing" ) var testCases = []cmdtesting.TestCase{ diff --git a/Payload_Type/thanatos/pkg/commands/testing/test_runner.go b/Payload_Type/thanatos/pkg/commands/testing/test_runner.go index f27dddc..4abfd20 100644 --- a/Payload_Type/thanatos/pkg/commands/testing/test_runner.go +++ b/Payload_Type/thanatos/pkg/commands/testing/test_runner.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - "github.com/MythicAgents/thanatos/commands/utils" + "github.com/MythicAgents/thanatos/pkg/commands/utils" agentstructs "github.com/MythicMeta/MythicContainer/agent_structs" )