Captura de trànsit de xarxa: tcpdump a Linux + Wireshark a Windows

Traducció de l’original en anglès. Llegeix-lo en: CastellanoEnglish

Des de la màquina Windows fent servir la consola CLI (cmd):

ssh USER@HOST "tcpdump -s 0 -U -n -w - -i NETIF FILTER" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -

# USER - remote user of the linux box
# HOST - host address of the remote linux box
# NETIF - network interface to snif in the remote linux box
# FILTER - (optional) rules for filtering traffic to capture

Cas d'ús:

C:\Windows\System32\OpenSSH>ssh root@192.168.4.74 "tcpdump -s 0 -U -n -w - -i eno2 udp and not port 53" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -

Deixa'm presentar un cas d'ús poc habitual d'aquest truc tan útil. Faig servir un QNAP NAS com a passarel·la a la meva xarxa de casa, on tinc 5 NICs. Així doncs, és molt útil capturar trànsit de manera remota, però no tinc cap paquet de tcpdump al sistema. El que vaig fer va ser fer servir tcpdump com a contenidor de Docker i finalment l'ordre queda així.

# sniffing SIP traffic (port 5060) on interface eth0
# remote linux host (QNAP NAS) use SSH port 55222
# docker container is created and when work is done is removed
C:\Windows\System32\OpenSSH>ssh -p 55222 admin@10.2.0.1 "cd /share/Container/tcpdump && docker run --rm --net=host corfr/tcpdump -s 0 -U -n -w - -i eth0 not port 22 and port 5060" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -

Nota personal:

ssh -p 55222 admin@10.2.0.1 "docker run --rm --net=host corfr/tcpdump -s 0 -U -n -w - -i qvs0 host 10.2.0.177" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -