GithubHelp home page GithubHelp logo

jhong3842 / pypcap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pynetwork/pypcap

0.0 1.0 0.0 703 KB

pypcap - python libpcap module, forked from code.google.com/p/pypcap, now actively maintained

License: Other

Makefile 2.81% Python 77.55% C 19.64%

pypcap's Introduction

Python PCAP module

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:

>>> 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)))
...

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 install

Support

Visit https://github.com/pynetwork/pypcap for help!

Development 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

pypcap's People

Contributors

aagbsn avatar alex-slesarev avatar bassosimone avatar brifordwylie avatar bxsx avatar graingert avatar guyharris avatar hellais avatar lambdalisue avatar ograff avatar tonytan4ever avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.