This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Automate Wireshark using perl

1
1

How can i automate Wireshark using perl script. I need to launch the software, capture for a specified duration and save the packet dissections into a text file using perl script. Is it possible to do so?

asked 26 Mar '14, 23:56

zoikelle's gravatar image

zoikelle
16122
accept rate: 0%


3 Answers:

1

There is a command line "version" of Wireshark called tshark, usually installed with the Wireshark suite, that is suitable for use with scripts.

As to how to use it, well it's exactly the same as calling any other external command from perl.

answered 27 Mar '14, 02:28

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

1

How can i automate Wireshark using perl script.

Take a look at Net::Sharktools.

http://search.cpan.org/dist/Net-Sharktools/

Regards
Kurt

answered 27 Mar '14, 11:43

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
24.8k1039237
accept rate: 15%

0

For automated captures, I highly recommend using dumpcap rather than wireshark or tshark. The reason is that dumpcap doesn't keep the packets in memory as it writes, so it's far more resource-efficient for automated capture processes. If you want tshark-level intelligence (eg: with Wireshark display filters), I'd still recommend saving first with dumpcap, then running tshark against the file saved by dumpcap.

If your objective is as simple as you say, a script could be written with just a few lines of code. What I usually do for this is grab the current date/time from Perl's localtime(), use the time as part of a file name, and schedule a dumpcap trace for a duration equal to the frequency that cron reruns the script. Do a 'man dumpcap' (installed with Wireshark) to see the options there for a system call from perl, no modules required.

answered 30 Mar '14, 19:16

Quadratic's gravatar image

Quadratic
1.9k6928
accept rate: 13%