Skip to main content

Python bindings for libpcapng — read/write pcapng files and live packet capture

Project description

libpcapng

C library with Python bindings to read and write pcapng buffers. It follows the pcapng standard from https://github.com/pcapng/pcapng

Writing your first packet

Let's write a TCP SYN using libdumbnet and push the buffer into a pcapng file:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <dumbnet.h>
#include <libpcapng/libpcapng.h>

int main(int argc, char **argv)
{
	FILE *pcapout;

	char *pkt;
	size_t pktsize = 40;

	pkt = (char *)malloc(pktsize);
	if (!pkt) {
	   fprintf(stderr, "Cannot allocate pkt!\n");
	   return -1;
	}

	pcapout = fopen("pkts.pcap", "wb");

	libpcapng_write_header_to_file(pcapout);

	uint32_t saddr = 0x0100a8c0;
	uint32_t daddr = 0x561c1268;

	ip_pack_hdr(pkt, 0, pktsize, 1, 0, 128, IP_PROTO_TCP, saddr, daddr);
	tcp_pack_hdr(pkt + 20, 4096, 80, 1, 0, TH_SYN, 14, 0);
	ip_checksum(pkt, pktsize);

	libpcapng_write_enhanced_packet_to_file(pcapout, pkt, pktsize);

	fflush(pcapout);
	fclose(pcapout);

	free(pkt);

	return 0;
}

Compile using:

gcc test.c -o test -ldumbnet $(pkg-config libpcapng --libs --cflags)

And after running, open the created pcap with wireshark:

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

pycapng-0.3.tar.gz (262.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pycapng-0.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (296.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pycapng-0.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (276.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pycapng-0.3-cp313-cp313-macosx_11_0_arm64.whl (242.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pycapng-0.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (296.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pycapng-0.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (276.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pycapng-0.3-cp312-cp312-macosx_11_0_arm64.whl (242.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pycapng-0.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (294.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pycapng-0.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (276.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pycapng-0.3-cp311-cp311-macosx_11_0_arm64.whl (240.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pycapng-0.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (291.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pycapng-0.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (274.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pycapng-0.3-cp310-cp310-macosx_11_0_arm64.whl (239.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pycapng-0.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (291.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pycapng-0.3-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (274.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pycapng-0.3-cp39-cp39-macosx_11_0_arm64.whl (239.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file pycapng-0.3.tar.gz.

File metadata

  • Download URL: pycapng-0.3.tar.gz
  • Upload date:
  • Size: 262.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycapng-0.3.tar.gz
Algorithm Hash digest
SHA256 0575cc53fd368381ca976ae18a1ffd0d51cc7dd24ed8a610932342b0016840f8
MD5 64b53a2c3a2e127838a8add9c8d7e2cc
BLAKE2b-256 a23500af9dc5f894c4626de8295b547cdbba0a4d42149a6c01219903099f2fda

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3.tar.gz:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a6b5a578cce6ca2326b6a5381b058e84fde335ccfe5e39594606d7e25b0c2a73
MD5 b7bb93a83bf6cd54f1933e305a85122c
BLAKE2b-256 ad281d7afe1d3b860208e937f30dba652b20b0d9771761df0213e0c5472e5d02

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 473219f17081ab1ad019d478b8455981558eb8c67409c5b9fa37d35b9c29d1ff
MD5 9be73aebb77d702c09e67a6ef5466551
BLAKE2b-256 00c94342c2bb5feb2625248beb7d45b7ca22f941a42804bf57f4409d94125315

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 02e51ac1124a9ef3ad187f03334ace6a11e04dd71e4df5eecc6fbc87592a4397
MD5 a63a4af9908cc6950c577556cc45c69b
BLAKE2b-256 375d550fdb6848a70f88358943a0cb625c7a56b3c66ac88b045133a4abe04324

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 026d294bdb928082b6ac1eac26497dc50a86035ebb47100afba223a2ea103781
MD5 c756a7265e4134ba455b1b14c98322ee
BLAKE2b-256 af7564327446b9d64597a2ddadd84116af88f55ebfd8688f66a9f58610c59912

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 71045e2fa516bf2921b30709a41a0e0cdaa36cd819ea8d566019ff34d641a084
MD5 ef777169fbcf29d0c48f5bece7bdd475
BLAKE2b-256 39e71eb35b5533fa7a8422d7b6da03e7e2912db37eaf7a42d49edb69e918aeeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27fa911a2020347473402115aee4ae52ec83427f3db4cf74e72b3b3067226328
MD5 7af537db6b2c098d430b054431747295
BLAKE2b-256 61e6801a68e27837f1e146e8d1407ec87183c32b3155b41354045fd5a40814ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4fe668e15a7acd60ae208ddb86cdd73d137f3974257019fd5eb66731866cb449
MD5 fe6b2161992205ed288849c49e69edfe
BLAKE2b-256 c604588bde22a1224049b7ac825841940fb909fe475243c7fb59024ce7d978fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2065f170a229a09344cf9b3a6036ecb5b08de897c7690124a259e0e1fe287217
MD5 523361c69a0d77b6b8398c7ed702e235
BLAKE2b-256 8d9eede109d72592b28ef1138b4fa503cd9fec05bf30590eb44a56102a28904d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 133d208a8c95563c616e2382cbfca7dd2c1fceb35591e33cedcc08401d965c1d
MD5 723c727e5711b739a57242c7dd155b3d
BLAKE2b-256 aedda19ea652a18a7716c0ea0a425847084ed5a8a1930ff97b0e206f2e139a58

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e9d5cebace78a69a822f849a4c38e42dea2e0f168fe97bac870ce45c1691ec79
MD5 6262ad85e710dced0a94f9795436a839
BLAKE2b-256 aa35c396ad08231930ef284da0b16a693beedccf739084898133965a2543c815

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 50919b91970ab8d5c6390f71a050bf5f6b80c2f41ccf373682b20d9665830fd5
MD5 f6181a7668949844e25756cd461fffa8
BLAKE2b-256 043a4ac20798153e84498ebcd6f4245389ecf02846b3759242dfa107c1e9529c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 908db144ff829361ad9c1da26aafcbc3f8a9c23b1eb26661acbc94278d3ed0c4
MD5 ca3339d015f7e14af6a80cebb09ef3b7
BLAKE2b-256 2cbf0ca66cfe298e8080c4cad7fa09ed174f15c36316dc39c070f548b0b14b25

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 924026b2192f237230788ae772bd54754bb69788cf4961cf521df76c5ec17438
MD5 9450927f6b94c7d887875c23421f0f58
BLAKE2b-256 ba85d4eb3ab114b6f92b403946cbc8274f8d0347fefbfbafa74b1a97f0578be3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pycapng-0.3-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d5953c7f90797df024e2df3fe07107ed66c912b4f324c5e3fd4c43bce3be672f
MD5 4d7b00a7525924a3d4665fd061d500f1
BLAKE2b-256 5da9bccd5ea38bbe40a59163f2b208ccdd415e4dec8f25911d6304fdaa5f7045

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycapng-0.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: pycapng-0.3-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 239.8 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycapng-0.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ce1372a9ddf6047c9e950f36f6c00360daca8cd4d63f2d821a50d1df220340b
MD5 99b14172ae539316281457b662b65551
BLAKE2b-256 1570a0a4b0136defb9fc18f2f470c4de5c89c348638ad27ce9563705df6bba9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycapng-0.3-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on stricaud/libpcapng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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