-
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-645: change request with no subject merged in GitBook
- Loading branch information
1 parent
5898b2a
commit 124b867
Showing
4 changed files
with
164 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# cloud-init Exploits | ||
|
||
## UserData section exploits | ||
|
||
### Enumeration | ||
|
||
#### On current EC2 instance | ||
|
||
Read the following file. Requires sudo or root privileges | ||
|
||
``` | ||
sudo cat /var/lib/cloud/instance/scripts/part-001 | ||
``` | ||
|
||
Query IMDS | ||
|
||
``` | ||
IMDS_TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") | ||
ec2_instance_id=$( curl -H "X-aws-ec2-metadata-token: $IMDS_TOKEN" -s http://169.254.169.254/latest/meta-data/instance-id ) | ||
ec2_region=$(curl -s -H "X-aws-ec2-metadata-token: $IMDS_TOKEN" http://169.254.169.254/latest/meta-data/placement/region) | ||
aws ec2 describe-instance-attribute --attribute userData --instance-id $ec2_instance_id--region $ec2_region --query UserData --output text | base64 -d | ||
``` | ||
|
||
#### Cloudshell | ||
|
||
``` | ||
aws ec2 describe-instance-attribute --attribute userData --instance-id <instance id> --region <region> --query UserData --output text | ||
``` | ||
|
||
### Sensitive data | ||
|
||
pass | ||
|
||
### Code Execution Persistence | ||
|
||
pass | ||
|
||
|
||
|
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 @@ | ||
# Unencrypted EBS | ||
|
||
## Cloudshell snapshot enumeration | ||
|
||
``` | ||
aws ec2 describe-snapshots #All | ||
aws ec2 describe-snapshots --snapshot-ids <id> #by snap id | ||
aws ec2 describe-snapshots --filters "Name=volume-id,Values=<volume id>" #by volume id | ||
``` | ||
|
||
Find unencrypted snapshots | ||
|
||
``` | ||
aws ec2 describe-snapshots --filters "Name=encrypted,Values=false" | ||
``` | ||
|
||
## Mount EBS in instance and access data | ||
|
||
To access the snapshot we need to mount it in a controlled EC2 instance. After logging in execute the following steps. | ||
|
||
Enumerate the current EC2 instance id, region and availability zone. See[ IMDS section](./#imds) for documentation. | ||
|
||
Create a new volume from the target EBS. Save the volume id because we'll need it in the next step | ||
|
||
``` | ||
aws ec2 create-volume --snapshot-id <target snapshot id> --volume-type gp3 --region <ec2 region> --availability-zone <ec2 az id> | ||
``` | ||
|
||
Attach the volume to the EC2 instance | ||
|
||
``` | ||
aws ec2 attach-volume --region us-east-1 --device /dev/sdh --instance-id <instance id> --volume-id <created volume id> | ||
``` | ||
|
||
Verify that the volume has been mounted successfully and create a mount point. Even if the command succeeds it takes a while to attach the volume to the instance. If you don't see the new disk wait a couple of minutes | ||
|
||
``` | ||
sudo fdisk -l #we expect to see a new disk | ||
sudo mkdir /snapshot-recovery | ||
sudo mount /dev/nvme1n1 /snapshot-recovery | ||
cd /snapshot-recovery | ||
``` |