GCP - Storage Post Exploitation

Tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks

Cloud Storage

Per maggiori informazioni su Cloud Storage consulta questa pagina:

GCP - Storage Enum

Concedere l’accesso pubblico

È possibile concedere agli utenti esterni (autenticati in GCP o no) l’accesso al contenuto dei bucket. Tuttavia, per impostazione predefinita i bucket avranno disabilitata l’opzione per esporre pubblicamente un bucket:

# Disable public prevention
gcloud storage buckets update gs://BUCKET_NAME --no-public-access-prevention

# Make all objects in a bucket public
gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME --member=allUsers --role=roles/storage.objectViewer
## I don't think you can make specific objects public just with IAM

# Make a bucket or object public (via ACL)
gcloud storage buckets update gs://BUCKET_NAME --add-acl-grant=entity=AllUsers,role=READER
gcloud storage objects update gs://BUCKET_NAME/OBJECT_NAME --add-acl-grant=entity=AllUsers,role=READER

Se provi ad assegnare ACLs a un bucket con ACLs disabilitate troverai questo errore: ERROR: HTTPError 400: Cannot use ACL API to update bucket policy when uniform bucket-level access is enabled. Read more at https://cloud.google.com/storage/docs/uniform-bucket-level-access

Per accedere ai bucket aperti tramite browser, usa l’URL https://<bucket_name>.storage.googleapis.com/ o https://<bucket_name>.storage.googleapis.com/<object_name>

storage.objects.delete (storage.objects.get)

Per eliminare un oggetto:

gcloud storage rm gs://<BUCKET_NAME>/<OBJECT_NAME> --project=<PROJECT_ID>

storage.buckets.delete, storage.objects.delete & storage.objects.list

Per eliminare un bucket:

gcloud storage rm -r gs://<BUCKET_NAME>

Disattivare le chiavi HMAC

Il permesso storage.hmacKeys.update consente di disabilitare le chiavi HMAC, e il permesso storage.hmacKeys.delete consente a un’identità di eliminare le chiavi HMAC associate agli account di servizio in Cloud Storage.

# Deactivate
gcloud storage hmac update <ACCESS_ID> --deactivate

# Delete
gcloud storage hmac delete <ACCESS_ID>

storage.buckets.setIpFilter & storage.buckets.update

La storage.buckets.setIpFilter permission, insieme alla storage.buckets.update permission, consente a un’identità di configurare filtri di indirizzi IP su un bucket Cloud Storage, specificando quali intervalli o indirizzi IP sono autorizzati ad accedere alle risorse del bucket.

Per cancellare completamente il filtro IP, è possibile usare il comando seguente:

gcloud storage buckets update gs://<BUCKET_NAME> --project=<PROJECT_ID>

Per cambiare gli IP filtrati, è possibile usare il seguente comando:

gcloud storage buckets update gs://<BUCKET_NAME> \
--ip-filter-file=ip-filter.json \
--project=<PROJECT_ID>

Il file JSON rappresenta il filtro stesso, qualcosa del tipo:

{
"mode": "Enabled",
"publicNetworkSource": {
"allowedIpCidrRanges": ["<IP>/<MASK>"]
},
"allowCrossOrgVpcs": false,
"allowAllServiceAgentAccess": false
}

storage.buckets.restore

Ripristina un bucket usando:

gcloud storage restore gs://<BUCKET_NAME>#<GENERATION> \
--project=<PROJECT_ID>

Tip

Impara e pratica il hacking AWS:HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP: HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure: HackTricks Training Azure Red Team Expert (AzRTE)

Supporta HackTricks