Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

From PCAP to Pivot: Threat Hunting with Wireshark

Wisconsin Cyber Response Team
Team Annual Training Conference
October 25-26, 2025
David Zampino

Course Introduction

Objectives

  • Learn about Wireshark and some of its many uses
  • Describe install options and customize Wireshark for our needs and preferences
  • Learn about packet captures (pcaps), utilize different methods of capturing traffic, and identify ideal tap locations
  • Filter traffic using capture and display filters
  • Identify the structure of packet headers and relevant fields
  • Hands-on analysis of malicious traffic

Wireshark

A Brief History

  • Project started in 1998
  • Originally named Ethereal
  • De-facto standard network protocol analyzer
  • Free and open source
  • Licensed under GPL v2 or later
  • Runs on Windows, Linux, macOS, BSD, and more
  • https://www.wireshark.org/

Wireshark Capabilities

  • Troubleshoot networks
  • Detect intrusions
  • Generate statistics
  • Reverse engineer proprietary protocols
  • Identify malicious traffic
  • Carve files

Included Programs

  • Tshark
  • Capinfos
  • Dumpcap
  • Editcap
  • Mergecap
  • Text2pcap

Packet Captures

Packet Capture (PCAP)

  • Refers to both packet captures and a specific file format
  • IETF draft of successor: PCAP Next Generation (pcapng)
  • File signature
    • D4 C3 B2 A1 (little-endian) = Ôò¡
    • A1 B2 C3 D4 (big-endian) = ¡²ÃÔ
    • 4D 3C B2 A1/A1 B2 3C 4D = nanosecond-resolution
    • 0A 0D 0D 0A = LFCRCRLF = pcapng
  • Snapshot length
  • TZ always* = 0 = UTC

libpcap

  • tcpdump
  • libpcap
  • WinPcap
  • Win10Pcap
  • Npcap

extcap

  • Plugin interface that allows external binaries to act as capture interfaces
  • Etwdump
  • Androiddump
  • Randpktdump
  • Sshdump, Ciscodump, and Wifidump
  • UDPdump

Packet Capture on Windows

  • Native options
    • netsh trace
      • Windows 7/Server 2008 R2 – Current
    • pktmon
      • Windows 10 v1809/Server 2019 – Current
  • With a Wireshark install
    • WinPcap
      • Windows NT 4.0 – Windows 10*
    • Npcap (Wireshark 3.0.0+)
      • Windows 7 - Current

netsh trace

  • netsh trace start capture=yes [persistent=]yes|no [traceFile=]path\filename.etl [maxSize=]filemaxsize [fileMode=]single|circular|append [overwrite=]yes|no [capturefilters]
  • netsh trace stop
  • netsh trace show capturefilterhelp
  • Capture filters:
    • Ethernet.Address=<Mac address>
    • Ethernet.Type=IPv4
    • Protocol=(TCP,UPD)
    • Pv4.Address=<IPv4 address>
    • Supports multiple with ()
    • Support negation with NOT or ! i.e. Ethernet.Type=NOT(IPv6)

netsh trace Notes and Limitations

Packet Monitor (Pktmon)

  • pktmon filter add <filters>
  • pktmon filter add help
  • Capture filters:
    • -m <MAC address>
    • -v <VLAN>
    • -d <data link protocol { IPv4 | IPv6 | ARP | ## }
    • -t <transport layer protocol { TCP | UDP |ICMP | ICMPv6 | ## }
    • -i <IP address>
    • -p <port>
  • pktmon start --capture [--pkt-size <bytes>] [--file-name <name>] [--file-size <size>] [--log-mode <mode>]
  • Defaults:
    • Packet size of 128 bytes
    • File name of PktMon.etl
    • File size of 512 MB
    • Log mode is circular

Pktmon Notes and Limitations

  • Requires administrative rights
  • Actively under development; focus on virtualized networking
  • Generates ETL file but can convert its file to pcapng
    • pktmon etl2pcap <file.etl> --out <file.pcapng>
  • No option to persist through a reboot
  • No option to negate filters
  • No loopback traffic
  • Syntax has changed

Advantages of ETW-based Packet Captures

  • Ability to select multiple providers
  • Ability to filter by keywords
  • Ability to filter by logging level

Npcap

  • Developed by Nmap Project
  • Proprietary with usage/redistribution restrictions
    • No silent install without license
  • Can be installed during Wireshark install
  • Option to restrict to Administrators
  • Supports raw 802.11 frames in monitor mode and supported adapters
  • Loopback traffic

Linux/macOS/Unix/Unix-like Packet Capture

  • Does it support libpcap?
  • tcpdump
  • tcpdump -w <file> -i <interface> -n <no DNS> -s <snapshot length> -C <max file size MB> -W <max number of files> <BPF>
  • Example:
    • sudo tcpdump -n -s 0 -i eth0 -w file.pcap <BPF>

Other Packet Capture Options

  • Network device based packet capture, like Cisco EPC
  • Port mirroring/SPAN
  • Hub
  • Network tap

Packet Capture Location

  • Location, location, location
  • Unicast, broadcast, or multicast
  • What spot do I need to be in to see the traffic I’m looking for?
  • Is the traffic in transit or terminated?
  • What hardware is at my disposal?
  • What software is at my disposal?
  • Can I install software?
  • Be aware of dropped packets and storage requirements
  • Promiscuous/monitor mode

Installing Wireshark

Downloading Wireshark

Default Install

  • Wireshark
  • Tshark
  • Etwdump
  • Npcap
    • Not default:
      • Restrict Npcap driver’s access to Administrators only
      • Support raw 802.11 (and monitor mode) for wireless adapters

Setting Up Wireshark

  • Columns
    • Time
    • Custom
  • Layout
  • Name resolution
  • Geolocation
  • Profiles

First Capture

  • Let’s start capturing
  • Capture options
  • Packet list
  • Details
  • Bytes view
  • Minimap
  • Time format
  • Packet colorization
  • Stopping a capture
  • Closing a capture and not Wireshark

Capture Filters Versus Display Filters

  • Capture filters = tcpdump = Berkeley (BSD) Packet Filter (BPF)
    • Defines what gets captured
    • Fast and efficient
    • Limited
  • Display filters
    • Filters the captured packets
    • Used for colorization rules
    • Used to create smaller PCAPs
    • Much more in-depth syntax
      • 3000+ protocols and 328,000+ fields

Capture Filter Syntax

Capture Filter Examples

BPF filter example Description
udp dst port not 53 UDP not bound for port 53.
host 10.0.0.1 and host 10.0.0.2 Traffic between these hosts.
tcp dst port 80 or 8080 Packets to either of the specified TCP ports.
ether host 11:22:33:44:55:66 Matches a specific host with that Mac address.

Display Filter Syntax

  • <protocol>[.<field name>][.<fieldname>]…
  • Comparisons
    • ==, ===, <, >, <=, >=, !=, !==
    • eq/any_eq, all_eq, lt, gt, le, ge, ne/all_ne, any_ne
  • Sets
    • in { x y z }
  • Logic
    • &&, ||, !()
    • and, or, not ()
  • Substring matching
    • contains, matches
    • Case-sensitive; use lower()
  • ! gotcha aka. implicit ‘any’ and ‘all’
    • ip.addr!=10.43.54.65 is the same as ip.src!=10.43.54.65 or ip.dst!=10.43.54.65
    • Use !(ip.addr==10.43.54.6) instead
  • https://www.wireshark.org/docs/dfref/

Second Capture

  • Capture filters in action
  • Display filters in action
  • Statistics
    • Resolved addresses
    • Protocol hierarchy
    • Conversations
    • Endpoints
  • Follow stream
  • Decode As
  • Export Object

Profiles

  • Create new
  • Import
  • Export
  • Switch to

Now what?

  • Play around
  • Practice
  • Learn or validate what you know about network protocols
  • Generate and capture malicious traffic
  • Analyze captured malicious traffic

Additional Materials

PCAPs for Practice

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors