I want to dump in a one-liner all TCP traffic of a stream after a specific condition. In other words, I want to do something like: tshark -i wlan0 -s 0 -z follow,tcp,raw,x x= How can I do that? asked 16 Jan '16, 17:41 gregoireg |
One Answer:
You can do that with scripting, see my answer to a very similar question:
HOWEVER you can do that only for a pcap file, and not on-the-fly while capturing on an interface (wlan0), for obvious reasons. So, if you need/want on-the-fly TCP stream extraction, you can't use tshark. ngrep is probably the better tool then. ngrep Example:
Regards answered 19 Jan '16, 07:21 Kurt Knochner ♦ |
Thanks for the answer. I'm already doing that:
But I would like to do the same on-the-fly. How could I do that? I start to lose confidence that I can do it in a bash command. I can do 1. and 2. at the same time, as well as 3. and 4. but linking 2. and 3. doesn't seem possible. Am I right? Would my only hope be to have an app using libpcap to achieve my goal?
It depends on your definition of on-the-fly.
If that is: Extract TCP streams while tshark is capturing on an interface, then you can't! As you said yourself, you need two passes, which is impossible while tshark is capturing!
If it means only one bash command line, then the solution is in the answer I posted first.