-
Notifications
You must be signed in to change notification settings - Fork 25
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
Example updates #82
Merged
Merged
Example updates #82
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0104f08
Add mitre and targets examples
l50 74972bc
Refined TTP example READMEs for clarity and consistency
l50 76f8417
Add ignore-errors examples
l50 e9a709b
Consistent naming
l50 cb068b3
Add fetchuri example; fixed typos
l50 46968e5
Add cleanup-step example and README
l50 2760837
Remove targets and ignore_errors to land PR
l50 7fdb88e
Fixed edit example - backup path needs to be explicitly specified
l50 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
# TTPs | ||
# Defining Arguments for TTPs | ||
|
||
These TTPs illustrate how to use the CLI argument features of TTPForge. | ||
Delve into the process of specifying arguments for a TTP. Proper argument | ||
definition ensures flexible and dynamic Tactics, Techniques, and Procedures. | ||
|
||
## define-args.yaml | ||
--- | ||
|
||
Run this TTP as follows: | ||
## Running `define-args.yaml` Demonstration | ||
|
||
To witness the definition and usage of arguments within a TTP, execute: | ||
|
||
```bash | ||
ttpforge run examples/args/define-args.yaml \ | ||
ttpforge run forgearmory//examples/args/define-args.yaml \ | ||
--arg a_message=foo \ | ||
--arg a_number=1337 | ||
``` | ||
|
||
Expected output: | ||
--- | ||
|
||
## Expected Output | ||
|
||
```text | ||
INFO [*] Validating Steps | ||
INFO [+] Finished validating steps | ||
INFO [+] Running current TTP: define_args | ||
INFO [+] Running current step: print_args | ||
INFO ========= Executing ========== | ||
hi! You passed the message: foo | ||
You passed the number: 1337 | ||
has_a_default has the value: 'this is the default value' | ||
INFO ========= Done ========== | ||
INFO [+] Finished running step: print_args | ||
INFO [*] Completed TTP | ||
INFO [*] No Cleanup Steps Found | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Using the FetchURI Step in TTPs | ||
|
||
Discover how to effectively employ the `FetchURI` step in TTPs to fetch content | ||
from a specific URI and store it in a file. | ||
|
||
--- | ||
|
||
## Running `fetchuri-example.yaml` Demonstration | ||
|
||
To observe the functionality of the `FetchURI` step in action, execute: | ||
|
||
```bash | ||
ttpforge run forgearmory//examples/fetchuri/fetchuri.yaml | ||
``` | ||
|
||
--- | ||
|
||
## Expected Output | ||
|
||
```text | ||
INFO [*] Validating Steps | ||
INFO [+] Finished validating steps | ||
INFO [+] Running current TTP: fetchuri_step_example | ||
INFO [+] Running current step: fetch-google-and-store-in-file | ||
INFO ========= Executing ========== | ||
INFO ========= Result ========== | ||
INFO [+] Finished running step: fetch-google-and-store-in-file | ||
INFO [*] Completed TTP | ||
INFO [*] Beginning Cleanup | ||
INFO ========= Executing ========== | ||
INFO ========= Result ========== | ||
INFO [*] Finished Cleanup | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
name: fetchuri_step_example | ||
description: Illustrates how to employ the FetchURI step. | ||
|
||
steps: | ||
- name: fetch-google-and-store-in-file | ||
fetch_uri: https://google.com | ||
location: ./google.txt | ||
overwrite: true | ||
cleanup: | ||
inline: rm google.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# MITRE ATT&CK Mapping for TTPs | ||
|
||
Understand the process of mapping a TTP to the MITRE ATT&CK framework, | ||
a globally recognized cybersecurity matrix. | ||
|
||
--- | ||
|
||
## Running `mitre.yaml` Demonstration | ||
|
||
To see the TTP mapping in action with the MITRE ATT&CK framework, execute: | ||
|
||
```bash | ||
ttpforge run forgearmory//examples/mitre/mitre.yaml | ||
``` | ||
|
||
--- | ||
|
||
## Expected Output | ||
|
||
```text | ||
INFO [*] Validating Steps | ||
INFO [+] Finished validating steps | ||
INFO [+] Running current TTP: mitre-target | ||
INFO [+] Running current step: friendly-message | ||
INFO ========= Executing ========== | ||
You are running a TTP that is mapped to MITRE ATT&CK | ||
INFO ========= Done ========== | ||
INFO [+] Finished running step: friendly-message | ||
INFO [*] Completed TTP | ||
INFO [*] No Cleanup Steps Found | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: mitre-target | ||
description: | | ||
Example to map a TTP to MITRE ATT&CK through tactics, techniques, and | ||
subtechniques. | ||
mitre: | ||
tactics: | ||
- TA0003 Persistence | ||
techniques: | ||
- T1547 Boot or Logon Autostart Execution | ||
subtechniques: | ||
- "T1547.007 Boot or Logon Autostart Execution: Re-opened Applications" | ||
|
||
steps: | ||
- name: friendly-message | ||
inline: | | ||
set -e | ||
|
||
echo "You are running a TTP that is mapped to MITRE ATT&CK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
# TTPs | ||
# Passing Outputs Between TTP Steps | ||
|
||
These TTPs illustrate how to pass outputs between different steps. | ||
Discover the methodology to efficiently pass outputs from one TTP step | ||
to the subsequent steps, ensuring seamless data flow within a procedure. | ||
|
||
## step-outputs.yaml | ||
--- | ||
|
||
Run this TTP as follows: | ||
## Running `outputs.yaml` Demonstration | ||
|
||
To observe the interplay of outputs between different TTP steps, execute: | ||
|
||
```bash | ||
ttpforge run examples/outputs/step-outputs.yaml | ||
ttpforge run forgearmory//examples/outputs/outputs.yaml | ||
``` | ||
|
||
Expected output: | ||
--- | ||
|
||
## Expected Output | ||
|
||
```text | ||
INFO [*] Validating Steps | ||
INFO [+] Finished validating steps | ||
INFO [+] Running current TTP: step_outputs_example | ||
INFO [+] Running current step: raw_output | ||
INFO ========= Executing ========== | ||
this will be accessible in stdout | ||
INFO ========= Result ========== | ||
INFO [+] Finished running step: raw_output | ||
INFO [+] Running current step: access_raw_output | ||
INFO ========= Executing ========== | ||
previous step output is this will be accessible in stdout | ||
|
||
INFO ========= Result ========== | ||
INFO [+] Finished running step: access_raw_output | ||
INFO [+] Running current step: with_json_output | ||
INFO ========= Executing ========== | ||
{"foo":"bar"} | ||
INFO ========= Result ========== | ||
INFO [+] Finished running step: with_json_output | ||
INFO [+] Running current step: print_json | ||
INFO ========= Executing ========== | ||
bar | ||
INFO ========= Result ========== | ||
INFO [+] Finished running step: print_json | ||
INFO [*] Completed TTP | ||
INFO [*] No Cleanup Steps Found | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# File Creation and Cleanup using `test-cleanup` Step | ||
|
||
Discover how to create and subsequently clean up files leveraging the | ||
`test-cleanup` step. This example showcases the capability to create a | ||
directory and remove it in the cleanup step. | ||
|
||
--- | ||
|
||
## Running `cleanup-step.yaml` Demonstration | ||
|
||
Execute the following command to illustrate the functionality of | ||
the `test-cleanup` step: | ||
|
||
```bash | ||
ttpforge run forgearmory//examples/steps/cleanup-step/cleanup-step.yaml | ||
``` | ||
|
||
--- | ||
|
||
## Expected Output | ||
|
||
```text | ||
INFO [*] Validating Steps | ||
INFO [+] Finished validating steps | ||
INFO [+] Running current TTP: test-cleanup | ||
INFO [+] Running current step: step_one | ||
INFO ========= Executing ========== | ||
# Directory "testDir" is created here | ||
INFO ========= Done ========== | ||
INFO [+] Finished running step: step_one | ||
INFO [*] Completed TTP | ||
INFO [*] Starting Cleanup | ||
INFO ========= Executing ========== | ||
# Directory "testDir" is removed here | ||
INFO ========= Done ========== | ||
INFO [*] Cleanup Complete | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
name: test-cleanup | ||
steps: | ||
- name: step_one | ||
inline: mkdir testDir | ||
cleanup: | ||
inline: rm -rf testDir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# File Modification using `edit_file` Step | ||
|
||
Discover how to make amendments to files leveraging the `edit_file` step, | ||
a versatile tool for editing files through string matching or regular expressions. | ||
|
||
--- | ||
|
||
## Running `edit-step.yaml` Demonstration | ||
|
||
Execute the following command to illustrate the power of the `edit_file` step: | ||
|
||
```bash | ||
ttpforge run forgearmory//examples/steps/edit-step/edit-step.yaml | ||
``` | ||
|
||
--- | ||
|
||
## Expected Output | ||
|
||
```text | ||
INFO [*] Validating Steps | ||
INFO [+] Finished validating steps | ||
INFO [+] Running current TTP: edit_step_example | ||
INFO [+] Running current step: target-file-pre-edit | ||
INFO ========= Executing ========== | ||
This is an example file. | ||
|
||
The TTP will replace the string below: | ||
|
||
REPLACE_ME | ||
|
||
It will also delete the multi-line string below and replace | ||
it with a comment: | ||
|
||
result = await myclass.multi_line_function_call( | ||
param1, | ||
param2, | ||
) | ||
|
||
Lastly, it will comment out the subsequent lines using a C-Style /* ... */ comment. | ||
|
||
another_multline_function_call( | ||
param1, | ||
param2, | ||
) | ||
INFO ========= Done ========== | ||
INFO [+] Finished running step: target-file-pre-edit | ||
INFO [+] Running current step: edit-target-file | ||
INFO [+] Finished running step: edit-target-file | ||
INFO [+] Running current step: target-file-post-edit | ||
INFO ========= Executing ========== | ||
This is an example file. | ||
|
||
The TTP has replaced the string below with: | ||
|
||
REPLACED_BY_EDIT | ||
|
||
The multi-line string was deleted and replaced with a comment: | ||
|
||
# replaced with comment | ||
|
||
The following lines have been commented using a C-Style /* ... */ comment: | ||
|
||
/*another_multline_function_call( | ||
param1, | ||
param2, | ||
)*/ | ||
INFO ========= Done ========== | ||
INFO [+] Finished running step: target-file-post-edit | ||
INFO [*] Completed TTP | ||
INFO [*] Starting Cleanup | ||
INFO ========= Executing ========== | ||
INFO ========= Done ========== | ||
INFO [*] Cleanup Complete | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
name: edit_step_example | ||
description: edits a file in various ways | ||
steps: | ||
- name: target-file-pre-edit | ||
inline: | | ||
set -e | ||
|
||
echo -e "Target file pre-edit:" | ||
cat file-to-edit.txt | ||
- name: edit-target-file | ||
edit_file: "file-to-edit.txt" | ||
backup_file: "/tmp/my-backup.txt" | ||
edits: | ||
- old: REPLACE_ME | ||
new: REPLACED_BY_EDIT | ||
- old: (?ms:^result = await myclass\.multi_line_function_call\(.*?\)$) | ||
new: "# replaced with comment" | ||
regexp: true | ||
- old: (?P<fn_call>(?ms:^another_multline_function_call\(.*?\)$)) | ||
new: "/*${fn_call}*/" | ||
regexp: true | ||
- name: target-file-post-edit | ||
inline: | | ||
set -e | ||
|
||
echo -e "Target file post-edit:" | ||
cat $HOME/.ttpforge/repos/forgearmory/ttps/examples/steps/edit-step/file-to-edit.txt | ||
cleanup: | ||
inline: | | ||
set -e | ||
|
||
mv /tmp/my-backup.txt $HOME/.ttpforge/repos/forgearmory/ttps/examples/steps/edit-step/file-to-edit.txt |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix this first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Yeah, basically it drops the backup in the CWD, which is different from where Forge expects it to be in relation to the original file. Hence the absolute path.