Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic Red Team support #1

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
207233d
Add PoC ART code
l50 Aug 25, 2023
e83486c
Added Mitre field to TTP struct
inesusvet Oct 22, 2024
4d956b6
added dockerfile to build ttpforge binary for windows
inesusvet Oct 22, 2024
fa858cc
Allow loose Mitre tags
inesusvet Oct 22, 2024
5a2fca6
Adjust struct names and yaml tags to ensure valid serialization
inesusvet Oct 22, 2024
0938230
Produce many resulting TTPForge files from one Atomic YAML
inesusvet Oct 23, 2024
f054c5f
Take care of arguments in clean up instructions; Properly serialize Args
inesusvet Oct 23, 2024
3c29a97
Convert argument placeholders to TTPForge format
inesusvet Oct 23, 2024
4791fa7
Added a map of Mitre Techniques to Tactics
inesusvet Oct 23, 2024
0a23699
Read Mitre map JSON to enrich Mitre tags, properly build list of resu…
inesusvet Oct 23, 2024
c643a5e
Update the mitre map JSON, populate Mitre tags
inesusvet Oct 23, 2024
c539ba4
Populate Mitre tags properly, extract GUID per atomic test
inesusvet Oct 23, 2024
df45242
Use UUID as safe target filename
inesusvet Oct 23, 2024
d956ca4
Always define API version
inesusvet Oct 23, 2024
1a9d336
Added todos and Executor to clean up step
inesusvet Oct 23, 2024
96fce19
Comma
inesusvet Oct 23, 2024
5bfd931
Populate Mitre Subtechnique when present
inesusvet Oct 23, 2024
0b0f233
Supported Platforms translates to Requirements
inesusvet Oct 23, 2024
c5bf9f2
Added translation of platform names and argument types
inesusvet Oct 24, 2024
fd71360
Process dependencies as Steps
inesusvet Oct 24, 2024
3d4713c
Add expected super-user flag, ReplaceAll in dependency step formatting
inesusvet Oct 24, 2024
3fd9174
Added Description field to Argument Specification
inesusvet Oct 24, 2024
890f09f
update magefiles reference to [email protected]
inesusvet Oct 25, 2024
6acf7e4
Replace argument placeholders in dependency steps; prevent double cur…
inesusvet Nov 3, 2024
f9fcc73
Make all argument types lowercased
inesusvet Nov 3, 2024
a58114e
Do not translate empty clean up instructions
inesusvet Nov 3, 2024
5f7a6ab
Properly escape default values
inesusvet Nov 3, 2024
9037d30
Translate executor names to executables
inesusvet Nov 3, 2024
1f8b7d4
Translate arg placeholders in pre-requisites instructions
inesusvet Nov 12, 2024
ed2dd78
Actual translation of argument types
inesusvet Nov 14, 2024
df6b136
Keep arguments sorted by name
inesusvet Nov 14, 2024
e727269
Added manual for YAML translation process
inesusvet Nov 26, 2024
f2fcf50
go mod tidy
inesusvet Nov 30, 2024
f50fbe2
Moved translation guide to docs
inesusvet Nov 30, 2024
13d2ef8
Drop pkg/art as outdated
inesusvet Nov 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.22-cbl-mariner2.0

ADD . /src
WORKDIR /src
RUN go build -o /ttpforge main.go
WORKDIR /

ENTRYPOINT [ "/ttpforge" ]
44 changes: 44 additions & 0 deletions docs/TranslationGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Atomic Red Team tests consumption by TTPForge

This doc provides step-by-step guide to migrate ART tests to TTPForge format and run them.

Check failure on line 3 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Line length

docs/TranslationGuide.md:3:81 MD013/line-length Line length [Expected: 80; Actual: 90] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md


Check failure on line 5 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Multiple consecutive blank lines

docs/TranslationGuide.md:5 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md012.md
## Conventions of the source

Located in the [redcanaryco/atomic-red-team](https://github.com/redcanaryco/atomic-red-team) repo on github. The `atomics` directory contains a library of YAML files categorized by MITRE TTP ids as sub-directory names.

Check failure on line 8 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Line length

docs/TranslationGuide.md:8:81 MD013/line-length Line length [Expected: 80; Actual: 218] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
Each YAML file contains several _Atomic tests_ (or implementations) of the unique TTP. Those tests differ by targeted platform, toolchain, and the actual way of acheiving the goal.

Check failure on line 9 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Line length

docs/TranslationGuide.md:9:81 MD013/line-length Line length [Expected: 80; Actual: 181] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
Each test might have unique parameters to be passed via command line, prerequisites and instructions to funlfill those prerequisites.

Check failure on line 10 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Line length

docs/TranslationGuide.md:10:81 MD013/line-length Line length [Expected: 80; Actual: 133] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
Executor is the program which is used to perform required actions to excersise the test.

Check failure on line 11 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Line length

docs/TranslationGuide.md:11:81 MD013/line-length Line length [Expected: 80; Actual: 88] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md


Check failure on line 13 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Multiple consecutive blank lines

docs/TranslationGuide.md:13 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md012.md
## Steps required for translation

The TTPForge engine supports only one implementation of a TTP per file. This is why you should expect several new files to appear in the target directory. By default the resulting YAML files have unique UUID as its name. This UUID is taken from the corresponding test.

Check failure on line 16 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Line length

docs/TranslationGuide.md:16:81 MD013/line-length Line length [Expected: 80; Actual: 271] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md
Each resulting file has MITRE TTP id tags as well as platform requirements.
Resulting YAML file has all arguments defined in the corresponding Atomic test.

Please note that the Prerequisites concept is not supported by TTPForge engine. This is why check for such prerequisites and their acquisition is kept as a separate step in the resulting YAML file.

Check failure on line 20 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Line length

docs/TranslationGuide.md:20:81 MD013/line-length Line length [Expected: 80; Actual: 198] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md013.md


Check failure on line 22 in docs/TranslationGuide.md

View workflow job for this annotation

GitHub Actions / run markdownlint against this codebase

Multiple consecutive blank lines

docs/TranslationGuide.md:22 MD012/no-multiple-blanks Multiple consecutive blank lines [Expected: 1; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.31.1/doc/md012.md
## The guidance

0. Checkout the branch containing the translation script (see [the PR](https://github.com/inesusvet/TTPForge/pull/1) in my fork of TTPForge).
0. Install [the Mage](https://magefile.org/) build tool for Go in order to run the translation script.
0. Select a YAML file from the ART library to traslate to TTPForge format.
0. Run the translation script passing diretory containing the ART YAML file.
For example `mage convertYAMLSchema ~/atomic-red-team/atomics/T1003.002`
0. Test the translated YAML file with TTPForge.


## Testing

As the majority of Atomic tests are Windows specific, let's describe the testing approach using this platform.

0. Enable Windows Sandbox following [the official guide](https://learn.microsoft.com/en-us/windows/security/application-security/application-isolation/windows-sandbox/windows-sandbox-overview) to evade EDR noise.
0. Download latest TTPForge binary [release](https://github.com/facebookincubator/TTPForge/releases) from github.
0. Run TTPForge on transalted YAML file using `--dry-run` mode
0. Run TTPForge for real life.


## Feedback
Please send your questions to the [original issue](https://github.com/facebookincubator/TTPForge/issues/83) on github.
16 changes: 16 additions & 0 deletions magefiles/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module magefile

go 1.23

toolchain go1.23.1

require (
github.com/facebookincubator/ttpforge v1.2.1
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
25 changes: 25 additions & 0 deletions magefiles/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/facebookincubator/ttpforge v1.2.1 h1:eLi26wnnJC/sCsUd5WZfXTj9r55Vzf4tTzFfZvKPbJ4=
github.com/facebookincubator/ttpforge v1.2.1/go.mod h1:7GXbcsYR0HsPPZoAMC9J99fkkDsQ5UhpixJf42DFDXk=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading
Loading