Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pynetwork/pypcap
pypcap - python libpcap module, forked from code.google.com/p/pypcap
https://github.com/pynetwork/pypcap
networking packet-capture pcap
Last synced: 6 days ago
JSON representation
pypcap - python libpcap module, forked from code.google.com/p/pypcap
- Host: GitHub
- URL: https://github.com/pynetwork/pypcap
- Owner: pynetwork
- License: other
- Created: 2012-11-28T18:57:46.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-03-29T05:36:08.000Z (over 1 year ago)
- Last Synced: 2024-10-01T21:48:12.496Z (about 1 month ago)
- Topics: networking, packet-capture, pcap
- Language: Cython
- Homepage:
- Size: 1000 KB
- Stars: 299
- Watchers: 21
- Forks: 75
- Open Issues: 39
-
Metadata Files:
- Readme: README.rst
- Changelog: Changelog.md
- Contributing: docs/contributing.rst
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
- awesome-network-stuff - **213**星
README
Python PCAP module
------------------**Attention** this project is currently unmaintained. If you would like to help with maitaining it please reach out (see: https://github.com/pynetwork/pypcap/issues/106)!
|travis| `Read the Docs `__
This is a simplified object-oriented Python wrapper for libpcap -
the current tcpdump.org version, and the WinPcap port for Windows.Example use #1::
>>> import pcap
>>> sniffer = pcap.pcap(name=None, promisc=True, immediate=True, timeout_ms=50)
>>> addr = lambda pkt, offset: '.'.join(str(ord(pkt[i])) for i in range(offset, offset + 4))
>>> for ts, pkt in sniffer:
... print('%d\tSRC %-16s\tDST %-16s' % (ts, addr(pkt, sniffer.dloff + 12), addr(pkt, sniffer.dloff + 16)))
...Example use #2::
Listing Interfaces
>>> import pcap
>>> print ("Interfaces:\n" + '\n'.join(pcap.findalldevs()))Windows notes
-------------WinPcap has compatibility issues with Windows 10, therefore
it's recommended to use `Npcap `_
(Nmap's packet sniffing library for Windows, based on the WinPcap/Libpcap libraries, but with improved speed, portability, security, and efficiency). Please enable WinPcap API-compatible mode during the library installation.Installation
------------This package requires:
* libpcap-dev
* python-dev
To install run::
pip install pypcap
Installation from sources
~~~~~~~~~~~~~~~~~~~~~~~~~Please clone the sources and run::
python setup.py install
Note for Windows users: Please download the `Npcap SDK `_, unpack the archive and put it into the sibling directory as ``wpdpack`` (``setup.py`` will discover it).
Sample procedure in PowerShell::
cd ..
wget -usebasicparsing -outfile npcap-sdk-0.1.zip https://nmap.org/npcap/dist/npcap-sdk-0.1.zip
Expand-Archive -LiteralPath npcap-sdk-0.1.zip
mv npcap-sdk-0.1\npcap-sdk-0.1 wpdpack
cd pypcap
python setup.py installSupport
-------Visit https://github.com/pynetwork/pypcap for help!
.. |travis| image:: https://img.shields.io/travis/pynetwork/pypcap.svg
:target: https://travis-ci.org/pynetwork/pypcapDevelopment notes
-----------------Regenerating C code
~~~~~~~~~~~~~~~~~~~The project uses Cython to generate the C code, it's recommended to install it from sources: https://github.com/cython/cython
To regenerate code please use::
cython pcap.pyx
Building docs
~~~~~~~~~~~~~To build docs you need the following additional dependencies::
pip install sphinx mock sphinxcontrib.napoleon
Please use `build_sphinx` task to regenerate the docs::
python setup.py build_sphinx