Networking/Computing Tips/Tricks

Let's say you deal with HUGE packet captures and you need to parse or carve out certain types of packets or conversations from the source.

This is particularly true for folks that use Ring Buffers, or folks who do huge captures over long time period with fast interfaces.  If you do this you start to learn very quickly about the Wireshark command line tools as well as other tools that apply to these needs.  Here is a list:

command line tools

Let's say we start with a bunch of capture files in a sub-directory.  Merging them is probably a bad idea since they are big to start with.  Also mergecap has a limit of 2,000 files.

The parsing or carving process is essentially a filtering exercise.  In other words, we need to create a display filter syntax that ends up creating a new set of files.

Tip #1 - Use Read Only

My first tip is that you should protect these captures so that you don't incidentally change the original captures.  To do this set the read only flag on those captures.  You do this by simply right clicking on the file (in Windows) and then selecting Properties.  On the properties screen you can select the "Read Only" tick box and click on OK.  Simple but very important.

Tip #2 - Create a Batch File

The second tip is to create an editable batch file that does two things: first it creates a subdirectory where the output of the parsing/carving process will create new .pcap files, second have the command line that will process the original file(s) with the appropriate filtering.

Example 1: Let's carve out all the DNS packets from multiple files.

Remember the first line below makes a new directory, and the second line triggers the parsing/filtering:

mkdir dns

for %%a in (*.pcapng) do tshark -r %%a -Y "dns" -w dns/%%a

What are the items above?

  • %%a is all the files in the directory we are working
  • -r is read the filename we are currectly working on
  • -Y is the  display filter
  • -w means write to the /dns subdirectory that we made in line 1, and use the filenames

Note: if you simply type these commands from the command line you only need one % sign.

Example 2: Let's carve out just the TCP essential packets.

Remember the first line below makes a new directory, and the second line triggers the parsing/filtering:

mkdir tcp

for %%a in (*.pcapng) do tshark -r %%a -Y "tcp.flags.syn==1 or tcp.flags.fin==1 or tcp.flags.reset==1" -w tcp/%%a

Note: if you simply type these commands from the command line you only need one % sign.

Example 3: Let's carve out packets by VLAN ID.

Remember the first line below makes a new directory, and the second line triggers the parsing/filtering:

mkdir vlan7

for %%a in (*.pcapng) do tshark -r %%a -Y "vlan.id==7" -w vlan7/%%a

Note: if you simply type these commands from the command line you only need one % sign.

 

We hope this helps those of you who deal with enormous or large numbers of captures.

If you have another example you think we should have here, please let me know: andyw@cellstream.com

Enjoy!

 

 

 

Comments powered by CComment

Find by Tag

4G Networks 5G Networks 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az Ad-Hoc Addressing Analysis Ansible Architecture ARP Assessment AToM Automation Baseline BGP Bloom's Taxonomy Cable cat CellStream Cellular Central Office Cheat Sheet Chrome Cisco Cloud CMD Company Policy Computer Consulting Data Center Data Networking Dependencies DHCPv6 DNS Docker Documentation Dublin-Traceroute dumpcap Earth Earthquakes ECMP Ethernet Ethics Etiquette Evaluation Field Operations Fragmentation G-MPLS Gauge GeoIP GNS3 Google GQUIC Hands-On History Home Network ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 India Internet IoT IPv4 IPv6 IRINN IS-IS L2VPN L3VPN LDP LifeNet Linux LLN LoL M-BGP MAC Macro Microsoft Milky Way mininet Monitoring MPLS mtr MTU Multicast Murphy Name Resolution Netcat NetMon netsh Networking nmap NSE Observations OLPC Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX OTT Paris-Traceroute Parrot PIM PMTU Policy POTS POTS to Pipes PPP Profile Project Management PW3E QoS QUIC Railroad Remote Desktop Requirements Resume Review RIP Routing RPL RSVP Rural SDN Security Service Provider Small Business SONET Speed SSL Status Storms Subnetting SYSCTL T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telephone Testing Tools Traceroute Traffic Engineering Training Travel Tunnel Ubuntu Utility Video Virtualbox Virtualization VoIP VRF VXLAN Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Windows Wireless Wireless 5G Wireshark WLAN Writing Zenmap ZigBee

Twitter Feed