skillfed

pydivert

Python binding to windivert driver

pydivert v3.1.3 291.3K downloads/30d#7,971 on PyPI244
Copyleft license LGPL-3.0-or-later OR GPL-2.0-or-later Active released

What it is and what it does

PyDivert wraps the WinDivert driver to give Python code direct access to the Windows network stack at the user-mode level. You can intercept packets matching a filter expression, inspect or modify their headers and payloads, drop them, or re-inject them. The package includes bundled WinDivert 2.2+ binaries so you don't have to install the driver separately.

It supports both synchronous and asynchronous workflows via asyncio, modern Python pattern matching (PEP 634), and advanced WinDivert features like FLOW, SOCKET, and REFLECT layers. Common use cases include building firewalls, monitoring or modifying network traffic, redacting sensitive payloads, and analyzing TCP/IP behavior. Requires Windows 11 64-bit, Python 3.10+, and administrator privileges.

Use it for:

  • Build a local firewall that blocks traffic from specific IP addresses or ports by dropping packets before they reach their destination.
  • Monitor and log HTTP/HTTPS traffic on a machine for debugging or security auditing purposes.
  • Redact or modify sensitive data (tokens, credentials) in network payloads before they leave the system.
  • Analyze TCP/IP behavior and test network stack interactions by capturing and inspecting real packets.
  • Implement packet-level rate limiting or traffic shaping by intercepting and selectively dropping or delaying packets.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

PyDivert is a Python binding for the WinDivert Windows driver that lets you capture, modify, drop, and re-inject network packets from user-mode code.

Yes, if you are on Windows 11 64-bit and need low-level network packet control from Python. The package is actively maintained, has no runtime dependencies, includes bundled binaries for easy setup, and supports modern Python versions. The copyleft license (LGPL/GPL) is a hard blocker for proprietary closed-source applications unless you can relicense. No known security vulnerabilities.

Install

pydivert on PyPI

pip

pip install pydivert

uv

uv add pydivert

poetry

poetry add pydivert

Installing pydivert

Before you install

Installation is straightforward with no runtime dependencies and low friction. The package is actively maintained with a recent release and includes bundled WinDivert binaries, eliminating manual driver setup. However, it requires Windows 11 64-bit and administrator privileges to function.

License in practice

PyDivert is dual-licensed under LGPL-3.0-or-later and GPL-2.0-or-later (copyleft). Any derivative work must comply with both licenses; proprietary applications using this package must either adopt a compatible copyleft license or obtain a separate commercial license.

Quickstart

pip install pydivert

import pydivert

with pydivert.WinDivert("tcp.DstPort == 80") as w:
    for packet in w:
        print(f"Captured: {packet}")
        w.send(packet)

Requires Windows 11 64-bit, Python 3.10+, and administrator privileges to run; WinDivert driver must be loaded by the OS.

Verify before relying

  • Whether Windows Server actually works despite being untested in the documentation.
  • Performance characteristics under high packet volume or complex filter rules.
  • Compatibility with Windows Defender or other security software that may interfere with driver access.

Package facts

License LGPL-3.0-or-later OR GPL-2.0-or-later (copyleft)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 91 days since the last release
Last repo commit
First released
Downloads 291,298/month — #7,971 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pydivert-3.1.3-py3-none-any.whl

Keywords: network, tcp/ip, windivert

Development Status :: 5 - Production/StableEnvironment :: Win32 (MS Windows)Intended Audience :: DevelopersIntended Audience :: System AdministratorsIntended Audience :: Telecommunications IndustryLicense :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)Operating System :: Microsoft :: Windows :: Windows 11Programming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python ModulesTopic :: System :: Networking :: FirewallsTopic :: System :: Networking :: MonitoringTopic :: Utilities

Tags

network packet capture windowspacket interception modificationwindivert python bindingfirewall packet filteringnetwork traffic inspectiontcp ip packet manipulationwindows network driver
windows-onlynetwork-interceptioncopyleft-license

More Python Modules packages