Skip to content

Commit 99431b6

Browse files
author
vishnuraju
committed
adding create-association for persistence
1 parent e83e262 commit 99431b6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# AWS - SSM Perssitence
22

3+
{{#include ../../../banners/hacktricks-training.md}}
4+
5+
## SSM
6+
7+
For more information check:
8+
9+
{{#ref}}
10+
../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/README.md
11+
{{#endref}}
12+
13+
### Using ssm:CreateAssociation for persistence
14+
15+
An attacker with the permission ssm:CreateAssociation can create a State Manager Association to automatically execute commands on EC2 instances managed by SSM. These associations can be configured to run at a fixed interval, making them suitable for backdoor-like persistence without interactive sessions.
16+
17+
18+
```bash
19+
aws ssm create-association \
20+
--name SSM-Document-Name \
21+
--targets Key=InstanceIds,Values=target-instance-id \
22+
--parameters commands=["malicious-command"] \
23+
--schedule-expression "rate(30 minutes)" \
24+
--association-name association-name
25+
```
26+
27+
> [!NOTE]
28+
> This persistence method works as long as the EC2 instance is managed by Systems Manager, the SSM agent is running, and the attacker has permission to create associations. It does not require interactive sessions or explicit ssm:SendCommand permissions. **Important:** The `--schedule-expression` parameter (e.g., `rate(30 minutes)`) must respect AWS's minimum interval of 30 minutes. For immediate or one-time execution, omit `--schedule-expression` entirely — the association will execute once after creation.
29+
30+
{{#include ../../../banners/hacktricks-training.md}}
331

432

533

0 commit comments

Comments
 (0)