-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d2cf1a
commit 617f4ef
Showing
17 changed files
with
1,218 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# -*-yaml-*- | ||
--- | ||
# .ansible-lint | ||
|
||
profile: shared # min, basic, moderate,safety, shared, production | ||
|
||
# Allows dumping of results in SARIF format | ||
# sarif_file: result.sarif | ||
|
||
# exclude_paths included in this file are parsed relative to this file's location | ||
# and not relative to the CWD of execution. CLI arguments passed to the --exclude | ||
# option are parsed relative to the CWD of execution. | ||
exclude_paths: | ||
- test*.yml | ||
# - .cache/ # implicit unless exclude_paths is defined in config | ||
# - test/fixtures/formatting-before/ | ||
# - test/fixtures/formatting-prettier/ | ||
parseable: true | ||
# quiet: true | ||
# strict: true | ||
# verbosity: 1 | ||
|
||
# Mock modules or roles in order to pass ansible-playbook --syntax-check | ||
# mock_modules: | ||
# - zuul_return | ||
# # note the foo.bar is invalid as being neither a module or a collection | ||
# - fake_namespace.fake_collection.fake_module | ||
# - fake_namespace.fake_collection.fake_module.fake_submodule | ||
# mock_roles: | ||
# - mocked_role | ||
# - author.role_name # old standalone galaxy role | ||
# - fake_namespace.fake_collection.fake_role # role within a collection | ||
|
||
# Enable checking of loop variable prefixes in roles | ||
# loop_var_prefix: "^(__|{role}_)" | ||
|
||
# Enforce variable names to follow pattern below, in addition to Ansible own | ||
# requirements, like avoiding python identifiers. To disable add `var-naming` | ||
# to skip_list. | ||
var_naming_pattern: "^[a-z_][a-z0-9_]*$" | ||
|
||
use_default_rules: true | ||
# Load custom rules from this specific folder | ||
# rulesdir: | ||
# - ./rule/directory/ | ||
|
||
# Ansible-lint is able to recognize and load skip rules stored inside | ||
# `.ansible-lint-ignore` (or `.config/ansible-lint-ignore.txt`) files. | ||
# To skip a rule just enter filename and tag, like "playbook.yml package-latest" | ||
# on a new line. | ||
# Optionally you can add comments after the tag, prefixed by "#". We discourage | ||
# the use of skip_list below because that will hide violations from the output. | ||
# When putting ignores inside the ignore file, they are marked as ignored, but | ||
# still visible, making it easier to address later. | ||
skip_list: [] | ||
# - skip_this_tag | ||
|
||
# Ansible-lint does not automatically load rules that have the 'opt-in' tag. | ||
# You must enable opt-in rules by listing each rule 'id' below. | ||
enable_list: | ||
- args | ||
- empty-string-compare # opt-in | ||
- no-log-password # opt-in | ||
- no-same-owner # opt-in | ||
# - name[prefix] # opt-in | ||
# add yaml here if you want to avoid ignoring yaml checks when yamllint | ||
# library is missing. Normally its absence just skips using that rule. | ||
- yaml | ||
# Report only a subset of tags and fully ignore any others | ||
# tags: | ||
# - jinja[spacing] | ||
|
||
# Ansible-lint does not fail on warnings from the rules or tags listed below | ||
warn_list: | ||
- no-changed-when | ||
- no-handler | ||
- yaml[line-length] | ||
- yaml[truthy] | ||
- experimental # experimental is included in the implicit list | ||
# - role-name | ||
# - yaml[document-start] # you can also use sub-rule matches | ||
|
||
# Some rules can transform files to fix (or make it easier to fix) identified | ||
# errors. `ansible-lint --write` will reformat YAML files and run these transforms. | ||
# By default it will run all transforms (effectively `write_list: ["all"]`). | ||
# You can disable running transforms by setting `write_list: ["none"]`. | ||
# Or only enable a subset of rule transforms by listing rules/tags here. | ||
# write_list: | ||
# - all | ||
|
||
# Offline mode disables installation of requirements.yml and schema refreshing | ||
offline: true | ||
|
||
# Return success if number of violations compared with previous git | ||
# commit has not increased. This feature works only in git | ||
# repositories. | ||
progressive: false | ||
|
||
# Define required Ansible's variables to satisfy syntax check | ||
# extra_vars: | ||
# foo: bar | ||
# multiline_string_variable: | | ||
# line1 | ||
# line2 | ||
# complex_variable: ":{;\t$()" | ||
|
||
# Uncomment to enforce action validation with tasks, usually is not | ||
# needed as Ansible syntax check also covers it. | ||
# skip_action_validation: false | ||
|
||
# List of additional kind:pattern to be added at the top of the default | ||
# match list, first match determines the file kind. | ||
kinds: [] | ||
# - playbook: "**/examples/*.{yml,yaml}" | ||
# - galaxy: "**/folder/galaxy.yml" | ||
# - tasks: "**/tasks/*.yml" | ||
# - vars: "**/vars/*.yml" | ||
# - meta: "**/meta/main.yml" | ||
# - yaml: "**/*.yaml-too" | ||
|
||
# List of additional collections to allow in only-builtins rule. | ||
# only_builtins_allow_collections: | ||
# - example_ns.example_collection | ||
|
||
# List of additions modules to allow in only-builtins rule. | ||
# only_builtins_allow_modules: | ||
# - example_module | ||
|
||
# Allow setting custom prefix for name[prefix] rule | ||
# task_name_prefix: "{stem} | " |
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,4 @@ | ||
;;; Directory Local Variables -*- no-byte-compile: t -*- | ||
;;; For more information see (info "(emacs) Directory Variables") | ||
|
||
((yaml-mode . ((eval . (ansible))))) |
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,20 @@ | ||
name: ansible-lint | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
name: Ansible Lint # Naming the build is important to use it as a status check | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Important: This sets up your GITHUB_WORKSPACE environment variable | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # needed for progressive mode to work | ||
|
||
- name: Run ansible-lint | ||
# replace `main` with any valid ref, or tags like `v6` | ||
uses: ansible/ansible-lint-action@main | ||
# optional: | ||
# with: | ||
# path: "playbooks/" # <-- only one value is allowed |
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,46 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at research at redcanary.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
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,22 @@ | ||
|
||
The MIT License | ||
|
||
Copyright (c) 2023 Red Canary, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,111 @@ | ||
ansible_atomic_red_team | ||
========= | ||
|
||
A role to execute atomic red team tests. | ||
|
||
This role facilitates executing Atomic Red Team tests via PowerShell and | ||
Invoke-AtomicRedTeam, on Windows and Linux hosts. It runs powershell core if | ||
necessary, installs Invoke-AtomicRedTeam and adds it to the powershell profile, | ||
and then runs tests against target hosts in the ansible-inventory. | ||
|
||
This role can be included in a playbook using `include_role` along with | ||
variables with a list of Atomic Red Team tests to execute. | ||
|
||
Tests are specified by Technique ID and optionally also by TestNumber or | ||
TestGuid to pick specific ART tests. | ||
|
||
The default variables contain a list of "banned" TIDs, which contain behavior | ||
that is not condusive to automated or repeated testing (eg [T1070.004-8 Delete | ||
Filesystem | ||
Linux](https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1070.004/T1070.004.md#atomic-test-8---delete-filesystem---linux), | ||
or involve extended dependencies or resources beyond a single VM (eg cloud | ||
tests). These tests are filtered out at the TID level (eg, matching | ||
`T[0-9]{4}(\.?[0-9]{3})?`), but can still be specified by TID+GUID if desired. | ||
|
||
## Why another way to execute ART Tests? | ||
|
||
There are several exellent execution frameworks for Atomic Red Team, but we desired easy | ||
integreation between our test framework and other devops tools that create VMs, | ||
configure sensors and prerequisites, and run other non-AtomicRedTeam tests. | ||
|
||
Ansible and Terraform allow us to meet these goals for fully automated | ||
testing. Terraform creates VMs provisioned by Ansible. Ansible playbooks run | ||
test scenarios so that we can repeatably generate live telemetry for testing | ||
using different combinations of sensors or configurations. This playbook | ||
integrates Atomic Red Team into this automation-focused testing model. | ||
|
||
## Notes | ||
|
||
Each TID should to 'evaluated' manually prior to being permanently added to the | ||
defaults, as some tests are 'unsafe.' This is why this role doesn't execute | ||
all the TIDs. | ||
|
||
`tasks/gather-art-tids.yml` runs locally from the ansible host, to directly | ||
query the Atomic Red Team test inventory CSV files on github and create/update | ||
`{{ playbook_dir }}/art-tids.yml`. This file is used by the playbook when running | ||
all execpt "banned" TIDs. | ||
|
||
If you want to disable this fetch from github on the machine running the | ||
playbook, set `disable_fetch_art_index: true`. This will cause | ||
`tasks/main.yml` to fall back to `vars/art-tids.yml` which can be manually | ||
updates with `vars/update-art-tids.sh` | ||
|
||
|
||
Role Variables | ||
-------------- | ||
|
||
in `defaults/main.yml`: | ||
- `banned_tids_linux`: annotated list of TIDs to *NOT* run | ||
- `art_tids_linux`: list of the linux TIDs available in ART | ||
- `art_tids_mac`: list of the mac TIDs available in ART | ||
- `art_tids_windows`: list of the windows TIDs available in ART | ||
- `art_repository_owner: redcanaryco` - override with the github repo owner for the atomic_red_team repo to use. | ||
- `art_branch: master` - override with the branch to use | ||
|
||
|
||
Example Playbook | ||
---------------- | ||
|
||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: | ||
|
||
```yaml | ||
--- | ||
- hosts: all | ||
gather_facts: True | ||
become: True | ||
tasks: | ||
|
||
- include_role: | ||
name: ansible_atomic_red_team | ||
# you cannot use become directly on include_role, but can control elevation using apply | ||
apply: | ||
become: True | ||
when: ansible_system == 'Linux' | ||
vars: | ||
art_tids_linux: | ||
- T1136.001 | ||
- T1053.003 | ||
- T1003.008-1,2,3 | ||
- T1003.008 f5aa6543-6cb2-4fae-b9c2-b96e14721713 | ||
- T1070.003 47966a1d-df4f-4078-af65-db6d9aa20739,7e6721df-5f08-4370-9255-f06d8a77af4c | ||
# separators MUST be - for TID and testnumbers | ||
# separator MAY be ' ' or ':' for TID and GUIDs | ||
# TID.SUBTID MUST be specified and match GUIDs, as required by Invoke-AtomicTest | ||
|
||
- include_role: | ||
name: ansible_atomic_red_team | ||
apply: | ||
become: False | ||
when: ansible_system == 'Win32NT' | ||
vars: | ||
art_tids_windows: | ||
- T1027 | ||
- T1053.005 | ||
- T1547.001-1,2 | ||
- T1547.001:eb44f842-0457-4ddc-9b92-c4caa144ac42 | ||
- T1547.001:2cb98256-625e-4da9-9d44-f2e5f90b8bd5,dade9447-791e-4c8f-b04b-3a35855dfa06 | ||
|
||
# this runs all available tests against all target systems | ||
# - include_role: | ||
# name: ansible_atomic_red_team | ||
``` |
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,41 @@ | ||
--- | ||
disable_fetch_art_index: false | ||
|
||
art_repository_owner: redcanaryco | ||
art_branch: master | ||
|
||
banned_tids_linux: | ||
- T1018 # slow ping scan | ||
- T1046 # nmap | ||
- T1070.004 # delete filesystem | ||
- T1078.004 # cloud | ||
- T1082 # Azure | ||
- T1098 # cloud | ||
- T1098.001 # cloud | ||
- T1110.003 # cloud | ||
- T1136.003 # AWS | ||
- T1176 # requires Firefox | ||
- T1217 # requires Firefox | ||
- T1484.002 # Azure | ||
- T1526 # Azure | ||
- T1529 # reboot/shutdown | ||
- T1530 # cloud | ||
- T1562.006 # auditd changes (may break some telemetry collection) | ||
- T1562.008 # cloud logging changes | ||
- T1574.006 # Dynamic Linker Hijacking (requires manual cleanup / testing - might break subsequent tests) | ||
- T1611 # container-based, needs prereqs, and hangs/timeout | ||
|
||
banned_tids_macos: | ||
- T1485 # impact - data destruction | ||
- T1529 # reboot/shutdown | ||
|
||
banned_tids_windows: | ||
- T1485 # impact - data destruction | ||
- T1529 # reboot/shutdown | ||
|
||
# these are updated by tasks/gather-art-tids.yml which polls github to write | ||
# playbook_dir/art-tids.yml as a fallback, the tasks/main.yml will load | ||
# vars/art-tids.yml, which can be manually updated with vars/update-art-tids.sh | ||
art_tids_linux: [] | ||
art_tids_macos: [] | ||
art_tids_windows: [] |
Oops, something went wrong.