Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
194d0ce
add break_condition to loop command
thorinaboenke Nov 29, 2024
fea1862
check break condition in loop executor
thorinaboenke Nov 29, 2024
7f09ac8
Merge remote-tracking branch 'origin/development' into 134_end_condit…
thorinaboenke Nov 29, 2024
ba78b10
substitute vars in break condition
thorinaboenke Nov 29, 2024
f920d41
refactor break condition and condition matching
thorinaboenke Dec 3, 2024
25b1521
Merge remote-tracking branch 'origin/development' into 134_end_condit…
thorinaboenke Dec 3, 2024
98167f9
move playbook and config parser to separate file
thorinaboenke Dec 3, 2024
d6cd92f
error message
thorinaboenke Dec 3, 2024
87e1caf
change error message
thorinaboenke Dec 3, 2024
74d3ea0
create jsonexecutor and command
thorinaboenke Dec 3, 2024
0ba2111
change unit parse playbook test
thorinaboenke Dec 3, 2024
200fe34
add json command for variable parsing
thorinaboenke Dec 3, 2024
6740e72
add unit tests for json executor
thorinaboenke Dec 4, 2024
1da1ac7
complete unit tests
thorinaboenke Dec 4, 2024
24911a1
remove comments
thorinaboenke Dec 4, 2024
2ec0ec9
add parsing from variable
thorinaboenke Dec 4, 2024
ded7f70
correct logging
thorinaboenke Dec 4, 2024
e5b9c6a
add docs for json command
thorinaboenke Dec 4, 2024
5213735
Merge pull request #140 from thorinaboenke/102_refactor_main
whotwagner Dec 4, 2024
8f86309
add option to append logs
thorinaboenke Dec 5, 2024
9bb92fc
unittest
thorinaboenke Dec 5, 2024
9a22641
typo
thorinaboenke Dec 5, 2024
9b133a6
add function to flatten json
thorinaboenke Dec 5, 2024
634e352
handle int variables in json
thorinaboenke Dec 5, 2024
c74df88
Update src/attackmate/__main__.py
thorinaboenke Dec 5, 2024
ea2ee1b
Merge pull request #142 from thorinaboenke/132_increasing_logs
whotwagner Dec 6, 2024
5004e99
update docs
thorinaboenke Dec 6, 2024
fb536fb
add examples
thorinaboenke Dec 6, 2024
4c17922
use local_path
thorinaboenke Dec 6, 2024
5d475fc
docs
thorinaboenke Dec 6, 2024
2d0c117
tests for local_path
thorinaboenke Dec 6, 2024
93235bc
Merge pull request #141 from thorinaboenke/121_json_command
whotwagner Dec 6, 2024
eb20dda
docs for until()
thorinaboenke Dec 7, 2024
d0f0c11
add loop until
thorinaboenke Dec 9, 2024
d859e5e
add flag to not substitute cmd vars for loop command
thorinaboenke Dec 10, 2024
219ac59
docs
thorinaboenke Dec 10, 2024
3196d2e
add test for loop_until()
thorinaboenke Dec 10, 2024
16f2dfa
rename break_condition to break_if
thorinaboenke Dec 10, 2024
d5cffee
rename break_condition to break_if
thorinaboenke Dec 10, 2024
03ef8d0
Update docs/source/playbook/commands/loop.rst
thorinaboenke Dec 11, 2024
342723e
Merge pull request #139 from thorinaboenke/134_end_condition_for_loop…
whotwagner Dec 11, 2024
f1d79e8
Implemented pause-key for debug command
whotwagner Jan 23, 2025
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
3 changes: 2 additions & 1 deletion docs/source/basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AttackMate ships with a executable stub called "attackmate" that can be called l
::

attackmate -h
usage: attackmate [-h] --config CONFIG [--debug] [--version]
usage: attackmate [-h] --config CONFIG [--debug] [--version] [--json] [--append_logs]

AttackMate is an attack orchestration tool that executes full attack-chains based on playbooks.

Expand All @@ -17,6 +17,7 @@ AttackMate ships with a executable stub called "attackmate" that can be called l
--debug Enable verbose output
--version show program's version number and exit
--json log commands to attackmate.json
--append_logs append logs to attackmate.log, output.log and attackmate.json instead of overwriting

(Austrian Institute of Technology) https://aecid.ait.ac.at Version: 0.2.0

Expand Down
10 changes: 9 additions & 1 deletion docs/source/playbook/commands/debug.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@ purposes only.
that this is an exceptional break.

:type: bool
:default: ``True``
:default: ``False``

.. confval:: wait_for_key

This setting causes the programm to pause until the user
hits the enter key.

:type: bool
:default: ``False``
1 change: 1 addition & 0 deletions docs/source/playbook/commands/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ The next pages will describe all possible commands in detail.
father
httpclient
include
json
loop
mktemp
msf-module
Expand Down
118 changes: 118 additions & 0 deletions docs/source/playbook/commands/json.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
====
json
====

Parse variables from a JSON file or from a variable (for example, ``RESULT_STDOUT``) that contains a valid JSON string.
If the "local_path" option is used, the JSON is read directly from the specified file. The "cmd" option is optional. If "local_path" is defined, the "cmd" option will be ignored.
If no "local_path" is set, the JSON is read from the "cmd" option. The variables are recursively parsed from the JSON input and saved in the variable store.
The variables are recursively parsed from the json input and are saved as single variables in the variable store.
Variable names are generated by concatenating keys at each level using an underscore (_) as a separator.
If the lowest-level value is a list of primitives (e.g., strings, integers), the list is preserved as-is without further flattening.

Example
-------

Given the following JSON input:

.. code-block:: json

{
"first_list": [1, 2, 3],
"user": {
"name": "John Doe",
"age": 30,
"address": {
"street": "123 Main St",
"city": "New York",
"postal_codes": [10001, 10002]
},
"friends": [
{
"name": "Jane Smith",
"age": 28,
"address": {
"street": "456 Oak Rd",
"city": "Los Angeles",
"postal_codes": [90001, 90002]
}
},
{
"name": "Emily Davis",
"age": 35,
"address": {
"street": "789 Pine Ln",
"city": "Chicago",
"postal_codes": [60007, 60008]
}
}
]
}
}

The variables would be saved in the variable store as follows:

.. code-block:: yaml

first_list: [1, 2, 3]
user_name: "John Doe"
user_age: 30
user_address_street: "123 Main St"
user_address_city: "New York"
user_address_postal_codes: [10001, 10002, 10003]
user_friends_0_name: "Jane Smith"
user_friends_0_age: 28
user_friends_0_address_street: "456 Oak Rd"
user_friends_0_address_city: "Los Angeles"
user_friends_0_address_postal_codes: [90001, 90002]
user_friends_1_name: "Emily Davis"
user_friends_1_age: 35
user_friends_1_address_street: "789 Pine Ln"
user_friends_1_address_city: "Chicago"
user_friends_1_address_postal_codes: [60007, 60008]

Configuration
-------------

.. confval:: local_path

The JSON input to parse from. Valid input is a path to a JSON file. If "local_path" is set, the "cmd" option will be ignored.

:type: str
:required: False

.. confval:: cmd

The JSON input to parse from. Valid input is a variable name from the variable store (without the leading ``$``) that contains a valid JSON string.

:type: str
:required: False

Either ``local_path`` OR ``cmd`` is required.

.. confval:: varstore

If set to ``True``, logs the variable store before and after adding variables using the JSON command.

:type: bool
:required: False

Examples
--------

.. code-block:: yaml

commands:
- type: json
local_path: "/path/to/samplefile.json"
varstore: True
- type: shell
cmd: |
cat <<EOF
{
"name": "Whiskers",
"favorite_toys": ["ball", "feather", "laser pointer"]
}
EOF
- type: json
cmd: RESULT_STDOUT
use_var: True
20 changes: 19 additions & 1 deletion docs/source/playbook/commands/loop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,40 @@ The current item is accessible as the `$LOOP_ITEM` variable.
**Loop with range**:
This mode iterates over a range of integers. The current index is accessible as the `$LOOP_INDEX` variable.

**Loop until condition is fulfilled**
This mode iterates indefinitely until the condition is fulfilled. (Checked before every command within the loop)
Variables in cmd settings of an until loop command until($VAR1 == $VAR2) will be substituted from the variable store on every iteration of the loop.
The current index/iteration of the loop is also accessible as the `$LOOP_INDEX` variable for the until() condition.

.. confval:: cmd

The loop condition. This defines how the loop should iterate, either over a list or a range of values.
The loop condition. This defines how the loop should iterate, either over a list or a range of values, or idefinitely until the
condition defined in until() is rached.

:type: str
:required: ``True``

Examples:

- **items(LISTA)**: Iterate over the elements of a list named `LISTA`.
- **range(0, 10)**: Iterate over a range from 0 to 9.
- **until($PORT == 7)

.. confval:: break_if

If defined, this condition is checked before every command in the loop.
If the condition evaluates to `True`, break out of the loop.
Supports the same operators as :confval:`only_if`.

:type: str
:required: ``False``

.. confval:: commands

The list of commands to execute during each iteration of the loop. These commands are executed once per iteration, with loop-specific variables (`$LOOP_ITEM` or `$LOOP_INDEX`) available for substitution.

:type: list[Command]
:required: ``True``

.. code-block:: yaml

Expand Down
5 changes: 2 additions & 3 deletions docs/source/playbook/session/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Sessions, Interactive
=====================

Many commands of AttackMate support the setting "session" or "interactive.
This chapter is about these important concepts of AttackMate.
Many commands of AttackMate support the setting "session" or "interactive.
This chapter is about these important concepts of AttackMate.

Session
-------
Expand Down Expand Up @@ -65,4 +65,3 @@ Many commands work in such a way that they first execute something and then coll
.. warning::

Please note that you **MUST** send a newline when you execute interactive commands!

5 changes: 5 additions & 0 deletions docs/source/playbook/vars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ $ATTACKMATE_FOO.

For more information about using the variables see `string.Template <https://docs.python.org/3/library/string.html#string.Template>`_


.. note::

variables in cmd settings of a loop command will be substituted on every iteration of the loop, see :ref:`loop`

Builtin Variables
=================

Expand Down
1 change: 0 additions & 1 deletion examples/includes/gather_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ commands:
cmd: post/linux/gather/enum_protections
options:
SESSION: $GATHER_SESSION

Loading
Loading