WireGuard (2024)

Table of contents:

Table of Contents

  • WireGuard (WG)
    • History
    • Protocol dependencies
    • Wireshark
    • Preference Settings
    • Example capture file
    • Display Filter
    • Capture Filter
    • Key Log Format
    • Live capture with decryption support
    • External links

WireGuard is a VPN protocol.

History

WireGuard was initially started by Jason A. Donenfield in 2015 as a Linux kernel module. As of January 2020, it has been accepted for Linux v5.6. Support for other platforms (macOS, Android, iOS, BSD, and Windows) is provided by a cross-platform wireguard-go implementation.

Protocol dependencies

  • UDP: WireGuard uses UDP as its transport protocol. There is no standard port and typically WireGuard is detected through heuristics.

Wireshark

WireGuard dissection and decryption support was added in Wireshark 3.0 (Bug 15011).

As of Wireshark 3.2, decryption secrets can be embedded in a pcapng file (Bug 15571).

Preference Settings

  • WireGuard static keys (wg.keys): A table of long-term static keys to enable WireGuard peer identification or partial decryption

  • Dissect transport data (wg.dissect_packet): Whether the IP dissector should dissect decrypted transport data.

  • Key log filename (wg.keylog_file): The path to the file which contains a list of secrets (see Key Log Format)

Example capture file

The test suite contains two capture samples:

Screenshot (with decryption keys configured): https://twitter.com/Lekensteyn/status/1027938328203669505

Display Filter

A complete list of WireGuard display filter fields can be found in the display filter reference.

The protocol name is wg.

Capture Filter

To filter WireGuard traffic while capturing, you can use:

udp[8:1] >= 1 and udp[8:1] <= 4 and udp[9:1] == 0 and udp[10:2] == 0

This filter works like the WireGuard heuristics. It tests the first byte for a valid message type (1, 2, 3, or 4) and checks that the next three reserved bytes are zero.

Alternatively if you know the UDP port number, you can filter it like this:

udpport51820

Key Log Format

Decryption can be enabled by supplying a key log file. This text file must follow the following format:

Every line consists of the key type, equals sign ('='), and the base64-encoded 32-byte key with optional spaces before and in between. The key type is one of LOCAL_STATIC_PRIVATE_KEY, REMOTE_STATIC_PUBLIC_KEY, LOCAL_EPHEMERAL_PRIVATE_KEY, or PRESHARED_KEY. This matches the output of extract-handshakes.sh

A PRESHARED_KEY line is linked to a session matched by a previous LOCAL_EPHEMERAL_PRIVATE_KEY line.

Warning: LOCAL_STATIC_PRIVATE_KEY and potentially PRESHARED_KEY are long-term secrets, users SHOULD only store non-production keys, or ensure proper protection of the pcapng file.

Live capture with decryption support

Wireshark can decrypt WireGuard traffic when appropriate keys are configured.

On Linux, one can use kprobes to tap into the WireGuard kernel module and extract keys for new sessions from memory.

Assuming that your WireGuard traffic goes over the wlan0 interface using port 51820:

sudo /path/to/extract-handshakes.sh > wg.keys &tshark -i wlan0 -owg.keylog_file:wg.keys -f 'udp port 51820'

Note that the extract-handshake.sh requires a special offsets file which is specific to a kernel configuration.

Step-by-step instructions for these are not yet available for the version merged in Linux v5.6. What you basically have to do is to build offset-finder.c with the headers from drivers/net/wireguard/ and kernel headers and config matching your current kernel.

External links

Imported from https://wiki.wireshark.org/WireGuard on 2020-08-11 23:27:32 UTC

I've been immersed in the realm of networking and security for quite some time, especially in VPN technologies. I've closely followed the development and integration of WireGuard into various operating systems, witnessing its evolution from its inception by Jason A. Donenfield in 2015 to its acceptance into the Linux kernel v5.6 in January 2020.

WireGuard, a VPN protocol known for its simplicity and efficiency, primarily utilizes UDP as its transport protocol. Unlike traditional VPNs, WireGuard doesn't have a standard port, making its detection reliant on heuristics rather than a predetermined port number. This characteristic often poses a challenge when trying to identify WireGuard traffic using conventional means.

The integration of WireGuard into Wireshark, starting from version 3.0 (with Bug 15011), has been a significant milestone. This update allowed for WireGuard dissection and decryption support within Wireshark. Additionally, Wireshark 3.2 introduced the capability to embed decryption secrets in a pcapng file, enhancing the ease of decryption.

For those diving into capturing WireGuard traffic, there are specific preference settings within Wireshark to consider. These settings include options to manage WireGuard static keys for peer identification and decryption, toggling the IP dissector to dissect decrypted transport data, and specifying the key log file's path.

WireGuard's display filters within Wireshark, designated under the protocol name 'wg,' offer a comprehensive list of filter fields. These filters enable users to precisely target WireGuard traffic for analysis, enhancing the efficiency of packet examination.

Moreover, the article provides insight into capture filters, key log formats necessary for decryption, and guidance for live capture with decryption support using Wireshark. This includes steps for configuration and usage, particularly for tapping into the WireGuard kernel module on Linux systems and extracting keys from memory.

The external links provided offer access to the official WireGuard website, serving as a valuable resource for additional information and updates regarding the protocol.

This amalgamation of information from the WireGuard integration into Wireshark, coupled with the protocol's characteristics and its practical application in live capture scenarios, forms a comprehensive guide for enthusiasts and professionals navigating WireGuard's implementation and analysis.

WireGuard (2024)
Top Articles
Latest Posts
Article information

Author: Greg Kuvalis

Last Updated:

Views: 5704

Rating: 4.4 / 5 (55 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Greg Kuvalis

Birthday: 1996-12-20

Address: 53157 Trantow Inlet, Townemouth, FL 92564-0267

Phone: +68218650356656

Job: IT Representative

Hobby: Knitting, Amateur radio, Skiing, Running, Mountain biking, Slacklining, Electronics

Introduction: My name is Greg Kuvalis, I am a witty, spotless, beautiful, charming, delightful, thankful, beautiful person who loves writing and wants to share my knowledge and understanding with you.