pydivert
Python binding to windivert driver
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 pydivertuv
uv add pydivertpoetry
poetry add pydivertInstalling 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
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
mitmproxy-windowsProvides Windows-specific traffic redirection…
copyleft · top 15,000 on PyPI
scapyScapy is a Python library for forging,…
copyleft · top 5,000 on PyPI
pypcapPython wrapper around libpcap that lets you…
unclear · top 15,000 on PyPI
dpktdpkt parses and creates TCP/IP protocol packets…
permissive · top 5,000 on PyPI
pysharkPyshark wraps tshark (Wireshark's command-line…
permissive · top 5,000 on PyPI
impacketImpacket provides low-level Python classes for…
permissive · top 15,000 on PyPI
pmd-net-protoParses, assembles, and validates network…
copyleft · top 15,000 on PyPI
python-pcapngParses and writes pcap-ng packet capture files,…
permissive · top 15,000 on PyPI
pyradpyrad implements RADIUS client and server…
permissive · top 15,000 on PyPI
mitmproxy-wireguardImplements a user-space WireGuard server that…
permissive · top 5,000 on PyPI