# AWS - EC2 未認証での列挙 {{#include ../../../../banners/hacktricks-training.md}} ## EC2 と関連サービス このページで詳細情報を確認してください: {{#ref}} ../../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/ {{#endref}} ### 公開ポート 仮想マシンの**任意のポートをインターネットに公開すること**が可能です。公開されたポートで**何が動作しているか**によって、攻撃者がそれを悪用する可能性があります。 #### SSRF {{#ref}} https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html {{#endref}} ### 公開 AMIs & EBS Snapshots AWSは**誰でもAMIsとSnapshotsをダウンロードできるようにアクセスを付与する**ことを許可しています。これらのリソースは自分のアカウントから非常に簡単に一覧化できます: ```bash # Public AMIs aws ec2 describe-images --executable-users all ## Search AMI by ownerID aws ec2 describe-images --executable-users all --query 'Images[?contains(ImageLocation, `967541184254/`) == `true`]' ## Search AMI by substr ("shared" in the example) aws ec2 describe-images --executable-users all --query 'Images[?contains(ImageLocation, `shared`) == `true`]' # Public EBS snapshots (hard-drive copies) aws ec2 describe-snapshots --restorable-by-user-ids all aws ec2 describe-snapshots --restorable-by-user-ids all | jq '.Snapshots[] | select(.OwnerId == "099720109477")' ``` スナップショットが誰でも復元できる状態で見つかった場合は、スナップショットのダウンロードと looting に関する手順について、[AWS - EBS Snapshot Dump](https://cloud.hacktricks.wiki/en/pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/index.html#ebs-snapshot-dump) を必ず確認してください。 #### 公開 URL テンプレート ```bash # EC2 ec2-{ip-seperated}.compute-1.amazonaws.com # ELB http://{user_provided}-{random_id}.{region}.elb.amazonaws.com:80/443 https://{user_provided}-{random_id}.{region}.elb.amazonaws.com ``` ### パブリックIPを持つ EC2 インスタンスを列挙 ```bash aws ec2 describe-instances --query "Reservations[].Instances[?PublicIpAddress!=null].PublicIpAddress" --output text ``` {{#include ../../../../banners/hacktricks-training.md}}