Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple filter in tshark

The filters -Y, -2 and -R in tshark confusing in Wireshark version 2.XX.

In version 1.8, we were able to apply multiple filters and save the filtered packets in csv file using command below:

tshark.exe -r src.pcap -T fields -e frame.number -e frame.time -e frame.len -e ip.src -e ip.dst -e udp.srcport -e udp.dstport -E header=y -E separator=, -E quote=d -E occurrence=f -R (ip.src==x.x.x.x)&&(ip.dst==y.y.y.y) > filtered.csv

But this command does not work in versions 2.x. Please help if someone applied multi-filter in new Wireshark versions.

like image 511
Gaurav Avatar asked Dec 31 '25 00:12

Gaurav


2 Answers

You should be able to achieve what you want by replacing -R (ip.src==x.x.x.x)&&(ip.dst==y.y.y.y) with -Y "(ip.src==x.x.x.x)&&(ip.dst==y.y.y.y)".

like image 147
Christopher Maynard Avatar answered Jan 05 '26 10:01

Christopher Maynard


On windows 7, I had this working with wireshark 2.2.1, adding -2 and quoting the string that follow -R option, like this:

tshark.exe -r mypcap.pcapng -T fields -2 -e frame.number -e frame.time -e frame.len -E header=y -E separator=, -E quote=d -E occurrence=f -R "(ip.src==192.168.1.20)&&(ip.dst==20.1.168.192)"

Not quoting the expression after "-R" results in printing fields and evaluate expression. If the expression results TRUE, the filter is recognized and the result is given. Otherwise the filter (e.g. ip.src) will be evalued as a command by the system, resulting in "command not recognized"

like image 36
cinv3 Avatar answered Jan 05 '26 08:01

cinv3



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!