#Capturer
# Toutes les interfaces, sans résolution, snapshot complet
sudo tcpdump -i any -nn -s0 -w capture.pcap
# Une interface et un hôte précis
sudo tcpdump -i eth0 host 10.10.10.10 -w host.pcap
# Rotation : 24 fichiers d'une heure
sudo tcpdump -i eth0 -w cap-%Y%m%d-%H%M.pcap -G 3600 -W 24
# Afficher le contenu ASCII (HTTP en clair)
sudo tcpdump -i any -nn -A 'tcp port 80'
| Filtre BPF | Effet |
|---|---|
host 10.0.0.5 |
Tout le trafic de/vers l'hôte |
net 10.0.0.0/24 |
Tout le sous-réseau |
port 443 |
Source ou destination 443 |
tcp[tcpflags] & tcp-syn != 0 |
Paquets SYN |
not port 22 |
Exclut SSH |
vlan and host 10.0.0.5 |
Trafic VLAN |
#Lire un pcap
# Résumé des conversations
tcpdump -nn -r capture.pcap | head -50
# Hex + ASCII pour un flux
tcpdump -nn -r capture.pcap -XX 'tcp port 21'
# Extraire les fichiers HTTP (avec tshark)
tshark -r capture.pcap --export-objects http,http-files/
#tshark : filtres d'affichage
# Requêtes HTTP
tshark -r capture.pcap -Y 'http.request' \
-T fields -e ip.src -e http.host -e http.request.uri
# DNS
tshark -r capture.pcap -Y 'dns' -T fields -e dns.qry.name | sort -u
# SNI TLS
tshark -r capture.pcap -Y 'tls.handshake.extensions_server_name' \
-T fields -e tls.handshake.extensions_server_name | sort -u
# Suivre un stream TCP (numéro affiché avec -z follow)
tshark -r capture.pcap -z follow,tcp,ascii,0 -q
#Wireshark : filtres à retenir
| Filtre | Usage |
|---|---|
ip.addr == 10.0.0.5 |
Source ou destination |
http.request.method == "POST" |
Requêtes POST |
http.response.code >= 400 |
Erreurs HTTP |
dns.qry.name contains "example" |
Requêtes DNS |
tls.handshake.extensions_server_name == "example.com" |
SNI |
tcp.flags.syn == 1 && tcp.flags.ack == 0 |
SYN scan |
frame contains "password" |
Recherche brute |
ftp / smb2 / kerberos |
Protocoles ciblés |
#Détection rapide
# Top talkers
tshark -r capture.pcap -q -z endpoints,ip
# Top conversations TCP
tshark -r capture.pcap -q -z conv,tcp
# Requêtes HTTP les plus fréquentes
tshark -r capture.pcap -Y 'http.request' -T fields -e http.request.full_uri \
| sort | uniq -c | sort -rn | head -20