Atomic Operator
AtomicOperator
Bases: Base
Main class used to run Atomic Red Team tests.
atomic-operator is used to run Atomic Red Team tests both locally and remotely. These tests (atomics) are predefined tests to mock or emulate a specific technique.
config_file definition
atomic-operator's run method can be supplied with a path to a configuration file (config_file) which defines specific tests and/or values for input parameters to facilitate automation of said tests. An example of this config_file can be seen below:
inventory:
linux1:
executor: ssh
authentication:
username: root
password: Somepassword!
#ssk_key_path:
port: 22
timeout: 5
hosts:
# - 192.168.1.1
- 10.32.100.199
# etc.
atomic_tests:
- guid: f7e6ec05-c19e-4a80-a7e7-241027992fdb
input_arguments:
output_file:
value: custom_output.txt
input_file:
value: custom_input.txt
- guid: 3ff64f0b-3af2-3866-339d-38d9791407c3
input_arguments:
second_arg:
value: SWAPPPED argument
- guid: 32f90516-4bc9-43bd-b18d-2cbe0b7ca9b2
inventories:
- linux1
Raises:
Type | Description |
---|---|
ValueError
|
If a provided technique is unknown we raise an error. |
Source code in atomic_operator/atomic_operator.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
get_atomics(desintation=os.getcwd(), **kwargs)
Downloads the RedCanary atomic-red-team repository to your local system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
desintation |
str
|
A folder path to download the repositorty data to. Defaults to os.getcwd(). |
os.getcwd()
|
kwargs |
dict
|
This kwargs will be passed along to Python requests library during download. Defaults to None. |
required |
Returns:
Name | Type | Description |
---|---|---|
str | The path the data can be found at. |
Source code in atomic_operator/atomic_operator.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
run(techniques=['all'], test_guids=[], select_tests=False, atomics_path=os.getcwd(), check_prereqs=False, get_prereqs=False, cleanup=False, copy_source_files=True, command_timeout=20, debug=False, prompt_for_input_args=False, return_atomics=False, config_file=None, config_file_only=False, hosts=[], username=None, password=None, ssh_key_path=None, private_key_string=None, verify_ssl=False, ssh_port=22, ssh_timeout=5, *args, **kwargs)
The main method in which we run Atomic Red Team tests.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
techniques |
list
|
One or more defined techniques by attack_technique ID. Defaults to 'all'. |
['all']
|
test_guids |
list
|
One or more Atomic test GUIDs. Defaults to None. |
[]
|
select_tests |
bool
|
Select one or more tests from provided techniques. Defaults to False. |
False
|
atomics_path |
str
|
The path of Atomic tests. Defaults to os.getcwd(). |
os.getcwd()
|
check_prereqs |
bool
|
Whether or not to check for prereq dependencies (prereq_comand). Defaults to False. |
False
|
get_prereqs |
bool
|
Whether or not you want to retrieve prerequisites. Defaults to False. |
False
|
cleanup |
bool
|
Whether or not you want to run cleanup command(s). Defaults to False. |
False
|
copy_source_files |
bool
|
Whether or not you want to copy any related source (src, bin, etc.) files to a remote host. Defaults to True. |
True
|
command_timeout |
int
|
Timeout duration for each command. Defaults to 20. |
20
|
debug |
bool
|
Whether or not you want to output details about tests being ran. Defaults to False. |
False
|
prompt_for_input_args |
bool
|
Whether you want to prompt for input arguments for each test. Defaults to False. |
False
|
return_atomics |
bool
|
Whether or not you want to return atomics instead of running them. Defaults to False. |
False
|
config_file |
str
|
A path to a conifg_file which is used to automate atomic-operator in environments. Default to None. |
None
|
config_file_only |
bool
|
Whether or not you want to run tests based on the provided config_file only. Defaults to False. |
False
|
hosts |
list
|
A list of one or more remote hosts to run a test on. Defaults to []. |
[]
|
username |
str
|
Username for authentication of remote connections. Defaults to None. |
None
|
password |
str
|
Password for authentication of remote connections. Defaults to None. |
None
|
ssh_key_path |
str
|
Path to a SSH Key for authentication of remote connections. Defaults to None. |
None
|
private_key_string |
str
|
A private SSH Key string used for authentication of remote connections. Defaults to None. |
None
|
verify_ssl |
bool
|
Whether or not to verify ssl when connecting over RDP (windows). Defaults to False. |
False
|
ssh_port |
int
|
SSH port for authentication of remote connections. Defaults to 22. |
22
|
ssh_timeout |
int
|
SSH timeout for authentication of remote connections. Defaults to 5. |
5
|
kwargs |
dict
|
If provided, keys matching inputs for a test will be replaced. Default is None. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If a provided technique is unknown we raise an error. |
Source code in atomic_operator/atomic_operator.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
Base
Source code in atomic_operator/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
download_atomic_red_team_repo(save_path, **kwargs)
Downloads the Atomic Red Team repository from github
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_path |
str
|
The path to save the downloaded and extracted ZIP contents |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string of the location the data was saved to. |
Source code in atomic_operator/base.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
get_abs_path(value)
Formats and returns the absolute path for a path value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
A path string in many different accepted formats |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The absolute path of the provided string |
Source code in atomic_operator/base.py
73 74 75 76 77 78 79 80 81 82 |
|
get_local_system_platform()
Identifies the local systems operating system platform
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The current/local systems operating system platform |
Source code in atomic_operator/base.py
62 63 64 65 66 67 68 69 70 71 |
|
prompt_user_for_input(title, input_object)
Prompts user for input values based on the provided values.
Source code in atomic_operator/base.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
ConfigParser
Bases: Base
Source code in atomic_operator/configparser.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
__init__(config_file=None, techniques=None, test_guids=None, host_list=None, username=None, password=None, ssh_key_path=None, private_key_string=None, verify_ssl=False, ssh_port=22, ssh_timeout=5, select_tests=False)
Parses a provided config file as well as parameters to build a run list
This list combines Atomics and potentially filters
tests defined within that Atomic object based on passed
in parameters and config_file.
Additionally, a list of Host objects are added to their
defined techniques or test_guids based on config and/or
passed in parameters.
Example: Example structure returned from provided values
[
Atomic(
attack_technique='T1016',
display_name='System Network Configuration Discovery',
path='/Users/josh.rickard/_Swimlane2/atomic-operator/redcanaryco-atomic-red-team-22dd2fb/atomics/T1016',
atomic_tests=[
AtomicTest(
name='System Network Configuration Discovery',
description='Identify network configuration information.
Upon successful execution, ...', supported_platforms=['macos', 'linux'], auto_generated_guid='c141bbdb-7fca-4254-9fd6-f47e79447e17', executor=AtomicExecutor( name='sh', command='if [ -x "$(command -v arp)" ]; then arp -a; else echo "arp is missing from ....', cleanup_command=None, elevation_required=False, steps=None ), input_arguments=None, dependency_executor_name=None, dependencies=[] ) ], hosts=[ Host( hostname='192.168.1.1', username='username', password='some_passowrd!', verify_ssl=False, ssh_key_path=None, private_key_string=None, port=22, timeout=5 ) ], supporting_files=[ 'redcanaryco-atomic-red-team-22dd2fb/atomics/T1016/src/top-128.txt', 'redcanaryco-atomic-red-team-22dd2fb/atomics/T1016/src/qakbot.bat' ] ) ]
Source code in atomic_operator/configparser.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
config()
property
Returns raw converted config_file passed into class
Returns:
Type | Description |
---|---|
[dict]: Returns the converted config_file as dictionary. |
Source code in atomic_operator/configparser.py
265 266 267 268 269 270 271 272 273 274 275 |
|
get_inputs(guid)
Retrieves any defined inputs for a given atomic test GUID
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guid |
str
|
An Atomic test GUID |
required |
Returns:
Name | Type | Description |
---|---|---|
dict | A dictionary of defined input arguments or empty |
Source code in atomic_operator/configparser.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
is_defined(guid)
Checks to see if a GUID is defined within a config file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guid |
str
|
The GUID defined within a parsed config file |
required |
Returns:
Type | Description |
---|---|
[bool]: Returns True if GUID is defined within parsed config_file |
Source code in atomic_operator/configparser.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
run_list()
property
Returns a list of Atomic objects that will be ran.
This list combines Atomics and potentially filters
tests defined within that Atomic object based on passed
in parameters and config_file.
Additionally, a list of Host objects are added to their
defined techniques or test_guids based on config and/or
passed in parameters.
[
Atomic(
attack_technique='T1016',
display_name='System Network Configuration Discovery',
path='/Users/josh.rickard/_Swimlane2/atomic-operator/redcanaryco-atomic-red-team-22dd2fb/atomics/T1016',
atomic_tests=[
AtomicTest(
name='System Network Configuration Discovery',
description='Identify network configuration information.
Upon successful execution, ...', supported_platforms=['macos', 'linux'], auto_generated_guid='c141bbdb-7fca-4254-9fd6-f47e79447e17', executor=AtomicExecutor( name='sh', command='if [ -x "$(command -v arp)" ]; then arp -a; else echo "arp is missing from ....', cleanup_command=None, elevation_required=False, steps=None ), input_arguments=None, dependency_executor_name=None, dependencies=[] ) ], hosts=[ Host( hostname='192.168.1.1', username='username', password='some_passowrd!', verify_ssl=False, ssh_key_path=None, private_key_string=None, port=22, timeout=5 ) ], supporting_files=[ 'redcanaryco-atomic-red-team-22dd2fb/atomics/T1016/src/top-128.txt', 'redcanaryco-atomic-red-team-22dd2fb/atomics/T1016/src/qakbot.bat' ] ) ]
Returns:
[list]: A list of modified Atomic objects that will be used to run
either remotely or locally.
Source code in atomic_operator/configparser.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
Config
The main configuration class used across atomic-operator
Raises:
Type | Description |
---|---|
AtomicsFolderNotFound
|
Raised when unable to find the provided atomics_path value |
Source code in atomic_operator/models.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
Atomic
A single Atomic data structure. Each Atomic (technique) will contain a list of one or more AtomicTest objects.
Source code in atomic_operator/atomic/atomic.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
AtomicTest
A single Atomic test object structure
Returns:
Name | Type | Description |
---|---|---|
AtomicTest | A single Atomic test object |
Source code in atomic_operator/atomic/atomictest.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
Loader
Bases: Base
Source code in atomic_operator/atomic/loader.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
find_atomics(atomics_path, pattern='**/T*/T*.yaml')
Attempts to find the atomics folder within the provided atomics_path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atomics_path |
str
|
A path to the atomic-red-team directory |
required |
pattern |
str
|
Pattern used to find atomics and their required yaml files. Defaults to '/T/T.yaml'. |
'**/T*/T*.yaml'
|
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
A list of paths of all identified atomics found in the given directory |
Source code in atomic_operator/atomic/loader.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
load_technique(path_to_dir)
Loads a provided yaml file which is typically an Atomic defintiion or configuration file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_to_dir |
str
|
A string path to a yaml formatted file |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Returns the loaded yaml file in a dictionary format |
Source code in atomic_operator/atomic/loader.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
load_techniques()
The main entrypoint when loading techniques from disk.
Raises:
Type | Description |
---|---|
AtomicsFolderNotFound
|
Thrown when unable to find the folder containing Atomic tests |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dict with the key(s) as the Atomic technique ID and the val is a list of Atomic objects. |
Source code in atomic_operator/atomic/loader.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|