# AWS - EC2 Neautentifikovana Enumeracija

{{#include ../../../banners/hacktricks-training.md}}

## EC2 i Povezane Usluge

Proverite na ovoj stranici više informacija o ovome:

{{#ref}}
../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/
{{#endref}}

### Javne Portove

Moguće je izložiti **bilo koji port virtuelnih mašina internetu**. U zavisnosti od **onoga što se pokreće** na izloženom portu, napadač bi mogao da ga zloupotrebi.

#### SSRF

{{#ref}}
https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html
{{#endref}}

### Javne AMI i EBS Snimci

AWS omogućava **da se svakome da pristup za preuzimanje AMI i Snimaka**. Možete lako da navedete ove resurse iz svog naloga:
```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")'
```
Ako pronađete snimak koji može da se vrati od strane bilo koga, obavezno proverite [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) za uputstva o preuzimanju i pljačkanju snimka.

#### Javni URL šablon
```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
```
### Enumerisanje EC2 instanci sa javnim IP-om
```bash
aws ec2 describe-instances --query "Reservations[].Instances[?PublicIpAddress!=null].PublicIpAddress" --output text
```
{{#include ../../../banners/hacktricks-training.md}}
