|
4 | 4 | - debug: |
5 | 5 | var: technique |
6 | 6 |
|
7 | | -# - name: List available Atomic Red Team Techniques |
8 | | -# ansible.windows.win_find: |
9 | | -# paths: C:\AtomicRedTeam\atomics |
10 | | -# file_type: directory |
11 | | -# patterns: T* |
12 | | -# register: available_techniques |
13 | | - |
14 | | -# - set_fact: |
15 | | -# available_techniques: "{{ available_techniques | json_query('files[].filename') }}" |
16 | | -# main_technique: "{{ technique | regex_replace('(-.)','') }}" |
17 | | - |
18 | | -# - name: Check requested Technique is valid |
19 | | -# fail: |
20 | | -# msg: "The {{ main_technique }} selected technique has no atomic tests. Please ensure it it correct and that tests exist for it. See https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/Indexes/Indexes-CSV/windows-index.csv. {{ available_techniques }} " |
21 | | -# when: "main_technique not in available_techniques" |
22 | | - |
| 7 | +- name: Start threat capture with CAP Attack |
| 8 | + win_shell: | |
| 9 | + Import-Module "C:\Program Files\ansible\capattack\capattack-ps\capattack.psd1" -Force |
| 10 | + CapAttack-Start |
| 11 | + when: cap_attack == "1" |
| 12 | + ignore_errors: True |
| 13 | + |
23 | 14 | - name: Get requirements for Atomic Red Team Technique |
24 | 15 | win_shell: | |
25 | 16 | Import-Module "C:\AtomicRedTeam\invoke-atomicredteam\Invoke-AtomicRedTeam.psd1" -Force |
26 | 17 | Invoke-AtomicTest "{{ technique }}" -GetPrereqs |
27 | 18 | register: requirements |
28 | 19 | ignore_errors: True |
29 | 20 |
|
30 | | -# - debug: |
31 | | -# var: requirements |
32 | | - |
33 | 21 | - name: Run specified Atomic Red Team Technique |
34 | 22 | win_shell: | |
| 23 | + Set-ExecutionPolicy bypass |
35 | 24 | Import-Module "C:\AtomicRedTeam\invoke-atomicredteam\Invoke-AtomicRedTeam.psd1" -Force |
36 | 25 | Invoke-AtomicTest "{{ technique }}" -Confirm:$false -TimeoutSeconds 300 -ExecutionLogPath C:\AtomicRedTeam\atc_execution.csv |
37 | 26 | register: output_art |
38 | | - |
39 | | -# - name: Save output atomic red team |
40 | | -# set_fact: |
41 | | -# output_art: "{{ output_art }}" |
42 | | -# cacheable: yes |
| 27 | + ignore_errors: True |
43 | 28 |
|
44 | 29 | - debug: |
45 | 30 | var: output_art.stdout_lines |
46 | 31 |
|
| 32 | +- name: Stop threat capture with CAP Attack and upload |
| 33 | + win_shell: | |
| 34 | + Import-Module "C:\Program Files\ansible\capattack\capattack-ps\capattack.psd1" -Force |
| 35 | + CapAttack-Stop -Headless -Upload |
| 36 | + when: cap_attack == "1" and cap_attack_upload_threat_capture == "1" |
| 37 | + |
| 38 | +- name: Stop threat capture with CAP Attack |
| 39 | + win_shell: | |
| 40 | + Import-Module "C:\Program Files\ansible\capattack\capattack-ps\capattack.psd1" -Force |
| 41 | + CapAttack-Stop -Headless |
| 42 | + when: cap_attack == "1" and cap_attack_upload_threat_capture == "0" |
| 43 | + |
47 | 44 | - name: Cleanup after execution |
48 | 45 | win_shell: | |
49 | 46 | Import-Module "C:\AtomicRedTeam\invoke-atomicredteam\Invoke-AtomicRedTeam.psd1" -Force |
50 | 47 | Invoke-AtomicTest "{{ technique }}" -Cleanup |
51 | 48 | register: cleanup |
52 | 49 |
|
53 | | -# - debug: |
54 | | -# var: cleanup |
0 commit comments