Ask Your Question
0

TShark Command Script to Read/Output all Good UDP Packets

asked 2023-07-03 22:53:14 +0000

DailyDose gravatar image

I've recently gotten into the world of using TShark to acquire PCAPs. I once upon a time strictly used Wireshark and did it all manually. But I had created a parser that could dig through Wireshark PCAPs and output all the data. But now I'm seeing that my parser is insufficient to read TShark PCAPs due to some confusing stuff regarding the header. Then I saw that TShark has a -R/-r command that I guess can read back the file. But seemingly only the #of packets and their packet size.

What would be the appropriate command line combination to dump all (and ONLY) the good UDP raw data? Either into a file or into the command prompt (probably preferably a file). I was trying to read up on this and unfortunately, my dyslexia kicks in (My reading comprehension scores were garbage growing up).

Please and thank you!

edit retag flag offensive close merge delete

Comments

dump all (and ONLY) the good UDP raw data

Can you clarify what "good UDP" is?

Chuckc gravatar imageChuckc ( 2023-07-04 01:20:14 +0000 )edit

I guess I mean that I occasionally see DNS "Format errors" throughout a UDP PCAP. So how do I also ignore those in my data dump?

DailyDose gravatar imageDailyDose ( 2023-07-05 14:39:46 +0000 )edit

You want to exclude DNS response with a response code (2.3 RCODE Assignment) of 1 Format error - The name server was unable to interpret the query.?

Chuckc gravatar imageChuckc ( 2023-07-05 15:02:53 +0000 )edit

I think the more I think about this - the more I'm not entirely sure I know what I want. Cuz dumping all the raw UDP to a file would leave me with questions on when packets start and stop.

DailyDose gravatar imageDailyDose ( 2023-07-05 15:52:02 +0000 )edit

Maybe a better question would be - when using TShark, is it possible to only capture UDP and that's it? I'm seeing TCP due to my telnet session intermixed in there.

DailyDose gravatar imageDailyDose ( 2023-07-05 15:53:05 +0000 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2023-07-07 20:33:48 +0000

André gravatar image

When reading a file using tshark -r, you can use a display filter to limit the output. Just like in Wireshark. For example, to show only UDP:

tshark -r file.pcap -Y udp

And only UDP except DNS:

tshark -r file.pcap -Y "udp and not dns"

See wireshark-filter page for more options.

The output of tsharkcan also controlled by command line options. See the manual page https://www.wireshark.org/docs/man-pa... .
Or watch a video about tshark (command line options), for example https://youtu.be/1TxAq1xIj1M?t=1401 (from the SharkFest channel).

To filter when capturing, use a capture filter, see https://www.wireshark.org/docs/man-pa... (udp to capture only UDP).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-07-03 22:53:14 +0000

Seen: 1,630 times

Last updated: Jul 07 '23