---
title: "Wireshark — Analyse de Trafic Réseau"
domain: network
subdomain: analysis
type: snippet
tags: [wireshark, tshark, packet-analysis, forensics, network, pcap]
difficulty: intermediate
status: stable
updated: "Sat May 30 2026 00:00:00 GMT+0000 (Coordinated Universal Time)"
---
## Capture

### Interface graphique
```
Capture > Interfaces > Sélectionner eth0/wlan0 > Start
Arrêt : bouton rouge ou Ctrl+E
Sauvegarde : File > Save As > .pcap / .pcapng
```

### tshark (CLI)
```bash
# Capture sur interface
tshark -i eth0

# Durée limitée (60s)
tshark -i eth0 -a duration:60 -w capture.pcap

# Taille limitée (100MB)
tshark -i eth0 -b filesize:102400 -w capture.pcap

# Capture avec filtre BPF
tshark -i eth0 -f "tcp port 80 or tcp port 443" -w web.pcap

# Lire un pcap
tshark -r capture.pcap
```

---

## Filtres de capture (BPF)

```bash
# Par hôte
host 192.168.1.10
src host 10.0.0.50
dst host 8.8.8.8

# Par port
port 443
portrange 8080-8090
not port 22

# Par protocole
tcp
udp
icmp
arp

# Combinaisons
tcp and host 192.168.1.10 and port 443
not arp and not broadcast
tcp[tcpflags] & tcp-syn != 0   # Paquets SYN uniquement
```

---

## Filtres d'affichage (Display Filters)

### Réseau
```
ip.src == 192.168.1.10
ip.dst == 10.0.0.0/8
ip.addr == 192.168.1.0/24
not ip.addr == 10.0.0.0/8
```

### Transport
```
tcp.port == 443
tcp.flags.syn == 1 and tcp.flags.ack == 0   # SYN scan
tcp.flags.reset == 1                          # RST
udp.port == 53
tcp.analysis.retransmission                   # Retransmissions
```

### Application
```
http.request.method == "POST"
http.response.code == 200
http.request.uri contains "login"
dns.qry.name contains "evil"
tls.handshake.type == 1    # Client Hello
smtp.req.command == "AUTH"
ftp.request.command == "PASS"
```

### Forensique
```
# Credentials en clair
http.authbasic
ftp.request.command == "PASS"
telnet

# Anomalies
tcp.analysis.duplicate_ack
icmp.type == 8 and icmp.code == 0   # Ping sweep
arp.duplicate-address-detected

# Grand volume
frame.len > 1400
```

---

## Analyse protocolaire

### HTTP — Reconstituer une session
```
1. Edit > Find Packet > "HTTP/1.1 200 OK"
2. Clic droit sur un paquet HTTP > Follow > TCP Stream
3. Voir la requête ET la réponse complètes

# Export objets HTTP (fichiers téléchargés)
File > Export Objects > HTTP
```

### DNS — Détecter l'exfiltration
```
# Filtrer requêtes DNS longues
dns and frame.len > 100

# Visualiser :  Statistics > DNS
# Chercher : sous-domaines encodés en base64 (exfil DNS)
dns.qry.name matches "[A-Za-z0-9+/]{20,}\\."
```

### TLS — Déchiffrement (si clé dispo)
```
Edit > Preferences > Protocols > TLS
> (Pre)-Master-Secret log filename : sslkeylog.log

# Générer avec Firefox/Chrome
export SSLKEYLOGFILE=~/sslkeylog.log
firefox &
```

### ARP — Détection empoisonnement
```
# Deux MACs différentes pour la même IP
arp.duplicate-address-detected

# Flood ARP
arp and eth.src == XX:XX:XX:XX:XX:XX
```

---

## Statistiques utiles

```
Statistics > Protocol Hierarchy      # Répartition des protocoles
Statistics > Conversations           # Flux TCP/UDP par paire d'hôtes
Statistics > Endpoints               # Hôtes actifs avec volumes
Statistics > IO Graph                # Débit dans le temps
Statistics > Flow Graph              # Séquence de paquets
Analyze > Expert Information         # Anomalies détectées auto
```

---

## tshark — Extraction en ligne de commande

```bash
# Extraire champs spécifiques
tshark -r capture.pcap -T fields \
  -e ip.src -e ip.dst -e tcp.dstport -e http.request.uri \
  -Y "http.request"

# Compter par IP source
tshark -r capture.pcap -T fields -e ip.src -Y "tcp" | sort | uniq -c | sort -rn

# Extraire URLs visitées
tshark -r capture.pcap -Y http.request -T fields \
  -e http.host -e http.request.uri | sort -u

# Extraire credentials FTP
tshark -r capture.pcap -Y "ftp.request.command == PASS" \
  -T fields -e ftp.request.arg

# Extraire fichiers HTTP
tshark -r capture.pcap --export-objects http,./extracted/

# Statistiques DNS
tshark -r capture.pcap -Y dns -T fields \
  -e dns.qry.name | sort | uniq -c | sort -rn | head -20
```

---

## Scénarios d'investigation

### Scan de ports
```
tcp.flags.syn == 1 and tcp.flags.ack == 0
# Observer : même source, ports dst variés
# SYN seuls sans réponse SYN-ACK → port fermé
```

### Exécution de malware (C2)
```
# Beaconing régulier vers une IP externe
ip.dst == [IP_SUSPECTE]
# Vérifier intervalles réguliers dans Time colonne
```

### Mouvement latéral SMB
```
smb or smb2
smb2.cmd == 5    # CREATE (accès fichier)
```

### Credential harvesting (HTTP)
```
http.request.method == POST and http.request.uri contains "login"
# Follow TCP Stream pour voir les credentials
```
