First time here? Check out the FAQ!
THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

extracting UDP stream as ascii

I need to extract ascii from udp payload and use command

tshark  -r filename.pcap -z"follow,udp,ascii,0" > logfile

This command mostly works but not when pcap has multiple udp streams, in such case it exports only the first one, how can I extract all udp streams from pcap? including damaged ones?

zgrge's avatar
1
zgrge
asked 2021-02-25 07:54:00 +0000
edit flag offensive 0 remove flag close merge delete

Comments

Can you define " including damaged ones?" ?

Chuckc's avatar Chuckc (2021-02-27 15:55:36 +0000) edit
add a comment see more comments

1 Answer

0

In your-z option you have specified a range of "0", this limits the output to the first UDP "stream". Try removing the ,0 from your command.

See the tshark man page for more info on the -z option.

Edit: Another senior moment, please ignore this "answer" it's incorrect.

grahamb's avatar
23.8k
grahamb
answered 2021-02-25 09:25:40 +0000, updated 2021-02-28 09:11:39 +0000
edit flag offensive 0 remove flag delete link

Comments

removing 0 produces error, "tshark: follow - Invalid address." I couldn't find any way to specify all streams

zgrge's avatar zgrge (2021-02-27 15:09:19 +0000) edit

-z follow,prot,mode,filter[,range] - the filter (stream number) is required and doesn't support a wildcard.
You can specify multiple follow options (in reverse order for ascending output) and doesn't matter if a stream number is picked that doesn't exist.

C:\>"\Program Files\Wireshark\tshark.exe" -r ".\UFTP_v3_transfer (1).pcapng" -q -z follow,udp,ascii,10 -z follow,udp,ascii,9 -z follow,udp,ascii,8 -z follow,udp,ascii,7 -z follow,udp,ascii,6 -z follow,udp,ascii,5 -z follow,udp,ascii,4 -z follow,udp,ascii,3 -z follow,udp,ascii,2 -z follow,udp,ascii,1 -z follow,udp,ascii,0

If you're working with many UDP streams, it might be better to make a pass through to determine the maximum value and then a loop to extract them individually.

(Code for parsing options in tap-follow.c)

Chuckc's avatar Chuckc (2021-02-27 15:54:07 +0000) edit

I didn't actually try it, I misread the documentation and assumed that "filter" was a filter, not a stream selector and that the optional range was the stream selector.

As @Chuckc noted there have been a number of solutions posted that make a first pass to extract all the stream indexes and use that info to create a new filter for a second pass.

grahamb's avatar grahamb (2021-02-28 09:09:48 +0000) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer