Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segevfiner/cypcap
A Cython based Python binding for modern libpcap
https://github.com/segevfiner/cypcap
cython libpcap pcap python python3
Last synced: 5 days ago
JSON representation
A Cython based Python binding for modern libpcap
- Host: GitHub
- URL: https://github.com/segevfiner/cypcap
- Owner: segevfiner
- License: bsd-3-clause
- Created: 2021-10-26T07:14:23.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-17T16:41:50.000Z (7 months ago)
- Last Synced: 2024-10-01T19:16:56.033Z (about 1 month ago)
- Topics: cython, libpcap, pcap, python, python3
- Language: Cython
- Homepage: https://pypi.org/project/cypcap/
- Size: 953 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
cypcap
======
.. image:: https://img.shields.io/pypi/v/cypcap.svg
:target: https://pypi.org/project/cypcap/
:alt: PyPI.. image:: https://github.com/segevfiner/cypcap/actions/workflows/docs.yml/badge.svg
:target: https://segevfiner.github.io/cypcap/
:alt: Docs.. image:: https://github.com/segevfiner/cypcap/actions/workflows/build-and-test.yml/badge.svg
:target: https://github.com/segevfiner/cypcap/actions/workflows/build-and-test.yml
:alt: Build & TestThis package is a Cython based binding for modern libpcap versions, for Python 3.6+, attempting to
be more complete than existing and poorly maintained packages.`Documentation `_
Installation
------------
::$ pip install cypcap
Python 3.6+ and libpcap 1.8+ is required (Older libpcap versions can be supported if needed).
Build From Source
^^^^^^^^^^^^^^^^^
On Windows, download and extract the `Npcap SDK`_ and set the enviromnet variable ``NPCAP_SDK`` to
its location (You will also need to install Npcap, Wireshark installs it as part of its
installation).On Linux, install the libpcap development package from your package manager. e.g. For Ubuntu::
$ sudo apt update && sudo apt install libpcap-dev
.. _`Npcap SDK`: https://nmap.org/npcap/
Quickstart
----------
.. code-block:: pythonimport cypcap
dev = cypcap.findalldevs()[0] # You should filter the list or let the user choose a device
with cypcap.create(dev) as pcap:
pcap.set_snaplen(65536)
pcap.set_promisc(True)
pcap.set_timeout(1000)
pcap.activate()for pkthdr, data in pcap:
if pkthdr is None:
continueprint(pkthdr, data)
License
-------
3-Clause BSD license (The same kind of license that libpcap uses).