
While working on the command line, you have access to all the other great command line tools that you might also rely on for parsing logs and other evidence sources. This is because command line tools are often a bit more flexible, and it just isn’t typically feasible to load really large PCAPs into graphical tools without exhausting the available memory on a system. Most PCAP whittling occurs on the command line.

This is ideal if you want to reduce a PCAP but still open it in a packet analysis tool like Wireshark. The beauty of this approach beyond grep is that it allows you to write the matching packets to a PCAP, rather than just doing simple text matching. This allows you to apply regular expressions to packets along with BPFs. Network grep (Ngrep) uses a similar approach as grep, but adds the flexibility to parse and read network data. If you’re familiar with unix command line tools then you’re certainly familiar with the power and flexibility of grep for performing regular expression-based searches. It uses the same set of dissectors as Wireshark.įigure 2: Reducing a PCAP with display filters in tshark If you’re working with a large capture file it might not be feasible to load it all into Wireshark to apply a display filter, but fortunately, you can also apply display filters with tshark. This provides flexibility beyond BPFs, particularly if you need to filter on layer 7 protocol fields. Wireshark display filters use a hierarchical structure () to allow for deep introspection using simple keywords. The detailed interpretation of the protocols means that each field is also available for filtering, which provides a great deal of flexibility.
Most popular wireshark filters code#
The Wireshark tool suite relies on blocks of code called dissectors to interpret packets and break protocols down into individual fields. See Practical Packet Analysis, Chapter 4.BPFs are also fast, so you won’t have to wait long to apply a filter and produce output.įigure 1: Reducing a PCAP with BPFs in tcpdump

While BPF syntax excels at simple filtering on lower layers, it lacks the ability to filter layer 7 protocol field data as easily. Interpreted by nearly every major packet capture and analysis tool (including tcpdump, Wireshark, and tshark), BPFs take a simple form that relies on keywords and values to build filtering expressions based on common layer 2 and 3 attributes of communication. The most widely used and universally available standard for filtering packets is the BPF syntax. What you use will depend on the tools you have available and level of granularity you need. There are several mechanisms available for filtering packet capture files down to something meaningful, including those that are built for that task and other tools that can be adapted for it.
Most popular wireshark filters series#
You can find the first three parts of this series here: This isn’t meant to be a complete guide on filtering, but if you’re looking for something like that then be sure to check out my Practical Packet Analysis book or online course where I have an entire section dedicated to filtering. In part four of this series, I’ll describe some different packet analysis tool filtering capabilities, some of the filters I use when whittling down PCAPs, and some tricks for applying them effectively. By using PCAP analysis tool filtering capabilities you can slowly tune out the things you don’t care about until you’re left with the important stuff, ultimately transforming the PCAP. While not quite as slow and painstaking a whittling, the process of slowly peeling back packets is also reductive. Yes, I know that’s a weird transition, but it’s true. I think about whittling often when I need to use a lot of filters to find the data I want in a packet capture. In either case, the transformation is quite impressive. It might wind up as a toy for a child or a game call for a hunting trip. A craftsman chooses a lifeless piece of scrap wood and slowly carves slivers off of it until it takes an impressive form. Whittling is a lost art, but it’s a beautiful process.
