Skip to main content

A framework for distributed network packet sniffing and processing.

Project description

A framework for distributed network packet sniffing and processing.

See the documentation for more details, and the netmomo and packscape sample Web applications (dumpling eaters) which use netdumplings as their back-end. Python 3.7 or higher is required. It has been tested with Python 3.8 on OS X 10.15 and Windows 10.

Installation

pip install netdumplings

This should be enough for Linux and OS X. On Windows you may also need to install Npcap.

Distributed packet sniffing?

netdumplings allows you to run multiple packet sniffers on any number of hosts. Those sniffers – called dumpling kitchens – pass any sniffed network packets to your Python code for processing. Your Python code is implemented as classes called dumpling chefs which use the network packets to generate dumplings. Dumpling contents are entirely up to you but they’ll usually describe the information contained in the sniffed network packets.

The dumplings created by the dumpling chefs are sent from the dumpling kitchens to a single dumpling hub, which forwards them on to any connected dumpling eaters for display or for any other sort of processing or visualization.

The kitchens, chefs, dumplings, hub, and eaters, are shown below. You write the bits in green (the chefs and eaters) and netdumplings does the rest:

docs/_static/overview.svg

Dumplings are sent between the kitchens, hub, and eaters, over WebSockets.

What does a dumpling look like?

Dumplings are just JSON data. The following dumpling was created by a chef which makes a dumpling for every DNS lookup.

{
    "metadata": {
        "chef": "DNSLookupChef",
        "creation_time": 1515990765.925951,
        "driver": "packet",
        "kitchen": "default_kitchen"

    },
    "payload": {
        "lookup": {
            "hostname": "myspace.com",
            "when": 1515990721.147
        }
    }
}

The "payload" section is generated by the dumpling chef and the "metadata" section is created automatically when the dumpling is sent to the hub by the kitchen.

Example dumpling chef

The following dumpling chef creates a dumpling for every DNS lookup (see the example dumpling above).

import time
import netdumplings

class DNSLookupChef(netdumplings.DumplingChef):
    def packet_handler(self, packet):
        # The incoming packet is a scapy packet object.
        # https://scapy.readthedocs.io

        # Ignore packets that we don't care about.
        if not packet.haslayer('DNS'):
            return

        # Determine the name of the host that was looked up.
        dns_query = packet.getlayer('DNS')
        query = dns_query.fields['qd']
        hostname = query.qname.decode('utf-8')

        # Generate a dumpling payload from the DNS lookup.
        dumpling_payload = {
            'lookup': {
                'hostname': hostname,
                'when': time.time(),
            }
        }

        # The handler is returning a dict, which will be automatically
        # converted into a dumpling and sent to nd-hub, which will then
        # forward it on to all the eaters.
        return dumpling_payload

Example dumpling eater

The following eater prints the payload of every dumpling sent from nd-hub.

import json
import netdumplings

class PrinterEater(netdumplings.DumplingEater):
    async def on_connect(self, hub_uri, websocket):
        print(f'Connected to nd-hub at {hub_uri}')
        print('Waiting for dumplings...\n')

    async def on_dumpling(self, dumpling):
        # The given dumpling is a netdumplings.Dumpling instance.
        dumpling_printable = json.dumps(dumpling.payload, indent=4)
        print(f'{dumpling_printable}\n')


def dumpling_printer():
    eater = PrinterEater()
    eater.run()


if __name__ == '__main__':
    dumpling_printer()

More information

See the documentation for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netdumplings-0.5.1.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

netdumplings-0.5.1-py2-none-any.whl (32.9 kB view details)

Uploaded Python 2

File details

Details for the file netdumplings-0.5.1.tar.gz.

File metadata

  • Download URL: netdumplings-0.5.1.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for netdumplings-0.5.1.tar.gz
Algorithm Hash digest
SHA256 b2adbe7f5bf99cd7a45118b33819023e01f9f7a2de55b46c8b4f22058093867e
MD5 9b5b2e3d539a5a68953dc59eed2c9146
BLAKE2b-256 b831083bb00a74afb6ef2e7220f0fd8c6fe5f8a1d786e9a596514d4304c58af0

See more details on using hashes here.

File details

Details for the file netdumplings-0.5.1-py2-none-any.whl.

File metadata

  • Download URL: netdumplings-0.5.1-py2-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for netdumplings-0.5.1-py2-none-any.whl
Algorithm Hash digest
SHA256 057f57dcac3aab31a0105195660c9e03d85a7cf035b3ef581084a36e5d9f1e98
MD5 7880a71a21be79cf3a02e8e0f34543d7
BLAKE2b-256 2baaaebb66a22386f989e17a239ae190b24996b669641752b170d6af31643fff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page