Skip to content

Commit

Permalink
Release commit for 'v0.1.8'
Browse files Browse the repository at this point in the history
commit 9473c8c
Author: Matt Ehrnschwender <[email protected]>
Date:   Tue Feb 6 16:15:17 2024 -0500

    Update changelog

commit f2734e8
Author: Matt Ehrnschwender <[email protected]>
Date:   Tue Feb 6 16:15:07 2024 -0500

    Add path triggers for release workflow

commit 4abaa6c
Author: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Tue Feb 6 20:42:50 2024 +0000

    Bump version number to match release '0.1.8'

commit 8f311b0
Author: Matt Ehrnschwender <[email protected]>
Date:   Tue Feb 6 15:14:36 2024 -0500

    Bump Fedora version and refactor Dockerfile

commit c69eb25
Author: Matt Ehrnschwender <[email protected]>
Date:   Tue Feb 6 15:14:07 2024 -0500

    Remove libssp from Windows link arg

commit f367c7a
Author: Matt Ehrnschwender <[email protected]>
Date:   Tue Feb 6 15:13:21 2024 -0500

    CI formatting

commit b0d1686
Author: Matt Ehrnschwender <[email protected]>
Date:   Tue Feb 6 15:12:36 2024 -0500

    Modify CI linting for Mythic code

commit 33b936d
Author: Matt Ehrnschwender <[email protected]>
Date:   Tue Feb 6 15:11:38 2024 -0500

    Add sync.sh ignore
  • Loading branch information
MEhrn00 committed Feb 6, 2024
1 parent a3cc2d7 commit fda8c57
Show file tree
Hide file tree
Showing 24 changed files with 283 additions and 81 deletions.
130 changes: 130 additions & 0 deletions .github/scripts/lint-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash

THANATOS_PATH=""
MYTHIC_CODE="thanatos/mythic/agent_functions"
AGENT_CODE="thanatos/agent_code"

CARGO_VARS=$(cat <<EOF
RUSTFLAGS='--cfg http'
UUID=''
AESPSK=''
callback_host=''
callback_interval=''
callback_jitter=''
callback_port=''
connection_retries=''
encrypted_exchange_check=''
get_uri=''
headers=''
post_uri=''
working_hours=''
EOF
)

# Populates the 'THANATOS_PATH' variable with the path to the thanatos payload base directory
populate_thanatos_path() {
# Get the path to the directory containing this script
local _script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

# Traverse up to the base of the git repository
local _repo_base=${_script_dir}/../..

# Ensure that the repo base contains the '.git' directory
if [ ! -d "${_repo_base}/.git" ]; then
echo "Could not find git repository base"
exit 1
fi

# Set the THANATOS_PATH variable to the base of the payload
THANATOS_PATH="$(realpath ${_repo_base}/Payload_Type/thanatos)"
}

# Check that python3, python3-pylint, python3-black, cargo, cargo-fmt, and cargo-clippy exist
check_requirements() {
# Ensure python3 exists
python3 --version &> /dev/null

# Ensure python3-pylint exists
python3 -m pylint --version &> /dev/null

# Ensure python3-black exists
python3 -m black --version &> /dev/null

# Ensure cargo exists
cargo -V &> /dev/null

# Ensure cargo fmt exists
cargo fmt --version &> /dev/null

# Ensure cargo clippy exists
cargo fmt --version &> /dev/null
}

# Run syntax checking
syntax_check() {
echo "[*] Running syntax checks"

local _cmd="python3 -m pylint --rcfile pylintrc -f colorized --errors-only main.py ${MYTHIC_CODE}/*.py"
echo "[*] current directory: $PWD"
echo "[*] command: $_cmd"
eval $_cmd

pushd $AGENT_CODE &> /dev/null
local _cmd="env ${CARGO_VARS} cargo check --color always --all-targets --all-features"
echo "[*] current directory: $PWD"
echo "[*] command: $(echo $_cmd | tr '\n' ' ')"
eval $_cmd
popd &> /dev/null
}

# Run code format checking
format_check() {
echo "[*] Running code format checks"

local _cmd="python3 -m black --color --diff --check main.py ${MYTHIC_CODE}/*.py"
echo "[*] current directory: $PWD"
echo "[*] command: $_cmd"
eval $_cmd

pushd $AGENT_CODE &> /dev/null
local _cmd="env ${CARGO_VARS} cargo fmt -- --color always --check"
echo "[*] current directory: $PWD"
echo "[*] command: $(echo $_cmd | tr '\n' ' ')"
eval $_cmd
popd &> /dev/null
}

# Run lint checks
lint_check() {
echo "[*] Running lint checks"

local _cmd="python3 -m pylint --rcfile pylintrc -f colorized main.py ${MYTHIC_CODE}/*.py"
echo "[*] current directory: $PWD"
echo "[*] command: $_cmd"
eval $_cmd

pushd $AGENT_CODE &> /dev/null

local _cmd="env ${CARGO_VARS} cargo clippy --color always --all-targets --all-features -- -D warnings"
echo "[*] current directory: $PWD"
echo "[*] command: $(echo $_cmd | tr '\n' ' ')"
eval $_cmd
popd &> /dev/null
}

set -e

populate_thanatos_path
check_requirements

pushd $THANATOS_PATH &> /dev/null
syntax_check
echo ""

format_check
echo ""

lint_check
echo ""

popd &> /dev/null
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
branches:
- 'release/v[0-9]+.[0-9]+.*'

paths:
- Payload_Type/thanatos/**
- config.json
- agent_capabilities.json

env:
IMAGE_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Mac OS metadata file
.DS_Store

/sync.sh
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ Changes to the Thanatos project.

This changelog file adheres to [keepachangelog](https://keepachangelog.com/en/1.1.0/).

## [0.1.8] - 2024-02-06

### Added

- Scripts for running CI lint tests locally
- Path triggers for release workflow

### Changed

- Removed `libssp-0.dll` runtime dependency for Windows agents
- Set line length for Mythic code CI checks to 90 columns
- Bumped docker container Fedora version to Fedora 39

## [0.1.7] - 2024-02-02

### Changed
Expand Down Expand Up @@ -93,6 +106,7 @@ This changelog file adheres to [keepachangelog](https://keepachangelog.com/en/1.
Initial public release


[0.1.8]: https://github.com/MythicAgents/thanatos/compare/v0.1.7...v0.1.8
[0.1.7]: https://github.com/MythicAgents/thanatos/compare/v0.1.6...v0.1.7
[0.1.6]: https://github.com/MythicAgents/thanatos/compare/v0.1.5...v0.1.6
[0.1.5]: https://github.com/MythicAgents/thanatos/compare/v0.1.4...v0.1.5
Expand Down
51 changes: 23 additions & 28 deletions Payload_Type/thanatos/.docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
### Real Dockerfile for the thanatos payload
# Note: Invoke this Dockerfile from the `Payload_Type/thanatos` directory using the command
# `docker build -t docker.io/mehrn00/thanatos:v0.1.3 -f .docker/Dockerfile .`
FROM docker.io/library/fedora:35
FROM docker.io/library/fedora:39

# Version of sccache to install
ENV SCCACHE_VERSION v0.7.6

# Install packages
RUN dnf install -y \
Expand All @@ -15,10 +18,11 @@ RUN dnf install -y \
mingw64-winpthreads-static.noarch \
mingw32-winpthreads-static.noarch \
libgcc.i686 \
libatomic-static.i686 \
libatomic.i686 \
glibc-devel.i686 \
openssl-devel \
openssl-devel.i686 \
openssl-static.i686 \
perl-FindBin \
perl-File-Compare \
perl-IPC-Cmd \
Expand Down Expand Up @@ -46,45 +50,36 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup.sh \
&& sh rustup.sh -y \
--profile minimal \
--default-toolchain stable \
-t x86_64-unknown-linux-gnu \
-t i686-unknown-linux-gnu \
-t x86_64-unknown-linux-musl \
-t i686-unknown-linux-musl \
-t x86_64-pc-windows-gnu \
-t i686-pc-windows-gnu

RUN rm -f rustup.sh

ENV PATH=$PATH:/root/.cargo/bin

# Fetch all the dependencies for each toolchain
RUN mkdir /tmp/thanatos
WORKDIR /tmp/thanatos
# Install sccache
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

COPY thanatos/agent_code/ .
WORKDIR /Mythic
COPY main.py main.py
COPY thanatos thanatos

RUN cargo fetch --target x86_64-unknown-linux-gnu
RUN cargo fetch --target x86_64-unknown-linux-musl
RUN cargo fetch --target x86_64-pc-windows-gnu
RUN cargo fetch --target i686-unknown-linux-gnu
RUN cargo fetch --target i686-unknown-linux-musl
RUN cargo fetch --target i686-pc-windows-gnu
# Fetch dependencies
WORKDIR /Mythic/thanatos/agent_code
RUN cargo fetch

WORKDIR /
RUN rm -rf /tmp/thanatos

WORKDIR /tmp
RUN curl -L 'https://github.com/mozilla/sccache/releases/download/v0.4.0/sccache-v0.4.0-x86_64-unknown-linux-musl.tar.gz' -o sccache.tar.gz
RUN tar xf sccache.tar.gz
RUN mv sccache-v0.4.0-x86_64-unknown-linux-musl/sccache /usr/bin/sccache
RUN chmod +x /usr/bin/sccache
RUN rm -rf sccache-v0.4.0-x86_64-unknown-linux-musl
RUN rm -f sccache.tar.gz
WORKDIR /Mythic

COPY .docker/config.toml /root/.cargo/config.toml

WORKDIR /Mythic/

COPY main.py main.py
COPY thanatos thanatos
ENV SCCACHE_DIR /Mythic/.cache/sccache
CMD ["python3.11", "main.py"]
2 changes: 1 addition & 1 deletion Payload_Type/thanatos/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
agent_code/target
thanatos/agent_code/target
2 changes: 1 addition & 1 deletion Payload_Type/thanatos/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Pull in the thanatos docker image
FROM ghcr.io/mythicagents/thanatos:v0.1.7
FROM ghcr.io/mythicagents/thanatos:v0.1.8
2 changes: 1 addition & 1 deletion Payload_Type/thanatos/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ indent-after-paren=4
indent-string=' '

# Maximum number of characters on a single line.
max-line-length=100
max-line-length=90

# Maximum number of lines in a module.
max-module-lines=1000
Expand Down
5 changes: 1 addition & 4 deletions Payload_Type/thanatos/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[project]
name = "thanatos"

[tool.black]
line-length = 100
line-length = 90
target-version = ['py311']
2 changes: 2 additions & 0 deletions Payload_Type/thanatos/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pycodestyle]
max-line-length = 90
2 changes: 1 addition & 1 deletion Payload_Type/thanatos/thanatos/agent_code/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thanatos"
version = "0.1.7"
version = "0.1.8"
authors = ["Matt Ehrnschwender", "Max Harley"]
edition = "2021"

Expand Down
Loading

0 comments on commit fda8c57

Please sign in to comment.