|
| 1 | +.. _remote_api_intro: |
| 2 | + |
| 3 | +========== |
| 4 | +Remote API |
| 5 | +========== |
| 6 | + |
| 7 | +AttackMate can execute commands and playbooks on a remote AttackMate |
| 8 | +instance. This is useful when the tools required by a playbook, such as |
| 9 | +Metasploit, Sliver, browsers, or network access to a target environment, are |
| 10 | +available on another host. |
| 11 | + |
| 12 | +The remote setup uses two components: |
| 13 | + |
| 14 | +* `attackmate-api-server <https://github.com/ait-testbed/attackmate-api-server>`__: |
| 15 | + runs on the remote AttackMate host and exposes an HTTPS API. |
| 16 | +* `attackmate-client <https://github.com/ait-testbed/attackmate-client>`__: |
| 17 | + runs on the local/client host and sends commands or playbooks to the API |
| 18 | + server. |
| 19 | + |
| 20 | +`attackmate-client` offers a CLI and a python library to execute commands and playbooks on a |
| 21 | +remote AttackMate server. It is only required on the client when you want to use the Remote API |
| 22 | +on an attackmate-api-server. |
| 23 | + |
| 24 | +The `attackmate-ansible <https://github.com/ait-testbed/attackmate-ansible>`__ |
| 25 | +role can install and configure both sides. |
| 26 | + |
| 27 | +Requirements |
| 28 | +============ |
| 29 | + |
| 30 | +A working remote setup needs at least: |
| 31 | + |
| 32 | +* AttackMate installed on the server. |
| 33 | +* attackmate-api-server installed and running on the server. |
| 34 | +* attackmate-client installed on the client, to access the remote API. |
| 35 | +* The server TLS certificate copied to the client. |
| 36 | +* A valid ``remote_config`` entry on the client, or provided as cli argument to ``attackmate-client``. |
| 37 | +* Any tools used by the remote playbook installed on the server, for example |
| 38 | + ``msfrpcd`` for Metasploit commands. |
| 39 | + |
| 40 | +If you installed ``Attackmate`` on the client, it is not recommended to install ``attackmate-client``, as it will |
| 41 | +already have pulled that in as a dependency. |
| 42 | + |
| 43 | +You can install just the ``attackmate-client``, if all you want to do on the client is to send remote commands |
| 44 | +and playbooks to the attackmate-api-server via CLI or the python library. |
| 45 | + |
| 46 | +Architecture |
| 47 | +============ |
| 48 | + |
| 49 | +When a remote playbook uses ``cmd: execute_playbook``, the referenced |
| 50 | +``playbook_path`` is read on the client machine. The client then sends the |
| 51 | +playbook YAML content to the API server. |
| 52 | + |
| 53 | +The commands inside that submitted playbook run on the server. Therefore paths |
| 54 | +inside the submitted playbook, such as payload paths, temporary files, local |
| 55 | +uploads, or tool configuration, are resolved on the server. |
| 56 | + |
| 57 | +Sample Config |
| 58 | +============= |
| 59 | + |
| 60 | +Save this as ``/etc/attackmate.yml`` on the client: |
| 61 | + |
| 62 | +.. code-block:: yaml |
| 63 | +
|
| 64 | + msf_config: |
| 65 | + server: localhost |
| 66 | + password: hackerman |
| 67 | +
|
| 68 | + cmd_config: |
| 69 | + command_delay: 2 |
| 70 | +
|
| 71 | + remote_config: |
| 72 | + attackmate-server: |
| 73 | + url: "https://10.0.0.5:8445" |
| 74 | + username: admin |
| 75 | + password: securepassword |
| 76 | + cafile: "/etc/ssl/certs/attackmate.pem" |
| 77 | +
|
| 78 | +The ``cafile`` must point to the certificate used by the API server. If the |
| 79 | +certificate is missing or does not match the server, HTTPS verification will |
| 80 | +fail. |
| 81 | + |
| 82 | +First Run |
| 83 | +========= |
| 84 | + |
| 85 | +Create a small local wrapper playbook on the client: |
| 86 | + |
| 87 | +.. code-block:: yaml |
| 88 | +
|
| 89 | + commands: |
| 90 | + - type: remote |
| 91 | + cmd: execute_playbook |
| 92 | + connection: attackmate-server |
| 93 | + playbook_path: examples/remote_put.yml |
| 94 | +
|
| 95 | +Run it with: |
| 96 | + |
| 97 | +.. code-block:: console |
| 98 | +
|
| 99 | + uv run attackm8 --debug remote_wrapper.yml |
| 100 | +
|
| 101 | +The local attackmate should log in to the remote API server, send the referenced playbook, and |
| 102 | +print the remote execution result. |
| 103 | + |
| 104 | +Testing The API Server |
| 105 | +====================== |
| 106 | + |
| 107 | +Check that the API service is reachable: |
| 108 | + |
| 109 | +.. code-block:: console |
| 110 | +
|
| 111 | + curl -k https://10.0.0.5:8445/ |
| 112 | +
|
| 113 | +Metasploit |
| 114 | +========== |
| 115 | + |
| 116 | +If a playbook uses Metasploit commands, ``msfrpcd`` must be running on the |
| 117 | +server and the AttackMate server configuration must match it. |
| 118 | + |
| 119 | +Example: |
| 120 | + |
| 121 | +.. code-block:: yaml |
| 122 | +
|
| 123 | + msf_config: |
| 124 | + server: localhost |
| 125 | + port: 55553 |
| 126 | + password: hackerman |
| 127 | + ssl: true |
| 128 | +
|
| 129 | +A common symptom of a wrong Metasploit configuration, or msfrpcd not running, is: |
| 130 | + |
| 131 | +.. code-block:: text |
| 132 | +
|
| 133 | + 2026-05-20 11:01:37 INFO | Login successful for 'admin' at https://192.168.0.30:8445. Token stored. |
| 134 | + 2026-05-20 11:02:37 ERROR | Request Error (POST https://192.168.0.30:8445/playbooks/execute/yaml): The read operation timed out |
| 135 | +
|
| 136 | +
|
| 137 | +Troubleshooting |
| 138 | +=============== |
| 139 | + |
| 140 | +``The read operation timed out`` |
| 141 | + |
| 142 | +The client waited longer than its configured HTTP timeout. This can happen when |
| 143 | +the remote playbook is still running, waiting for a session, or stuck in a tool |
| 144 | +such as Metasploit. Check the server logs and any AttackMate playbook logs. |
| 145 | + |
| 146 | +You can also increase the timeout period of attackmate-client by changing DEFAULT_TIMEOUT in ``/usr/local/share/attackmate/.venv/lib/python3.12/site-packages/attackmate_client/attackmate_client.py`` |
| 147 | + |
| 148 | +Server Logs |
| 149 | +=========== |
| 150 | + |
| 151 | +If file logging is enabled for API playbook runs, inspect the configured log |
| 152 | +directory, for example: |
| 153 | + |
| 154 | +.. code-block:: console |
| 155 | +
|
| 156 | + tail -f /var/log/attackmate-api/*_output.log |
0 commit comments