pycapng 0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycapng-0.3/.github/workflows/build.yml +133 -0
- pycapng-0.3/.github/workflows/release.yml +90 -0
- pycapng-0.3/.gitignore +19 -0
- pycapng-0.3/CMakeLists.txt +77 -0
- pycapng-0.3/LICENSE +22 -0
- pycapng-0.3/PKG-INFO +79 -0
- pycapng-0.3/README.md +59 -0
- pycapng-0.3/Tutorial.md +975 -0
- pycapng-0.3/Tutorial2.md +478 -0
- pycapng-0.3/VERSION +1 -0
- pycapng-0.3/bin/CMakeLists.txt +39 -0
- pycapng-0.3/bin/linenoise/linenoise.c +655 -0
- pycapng-0.3/bin/linenoise/linenoise.h +47 -0
- pycapng-0.3/bin/pcapsh.c +50 -0
- pycapng-0.3/bin/pcapsh.h +305 -0
- pycapng-0.3/bin/pcapsh.md +1419 -0
- pycapng-0.3/bin/pcapsh_eval.c +1394 -0
- pycapng-0.3/bin/pcapsh_io.c +1035 -0
- pycapng-0.3/bin/pcapsh_layer.c +286 -0
- pycapng-0.3/bin/pcapsh_main.c +555 -0
- pycapng-0.3/bin/pcapsh_posa.c +607 -0
- pycapng-0.3/bin/protos/ah.posa +15 -0
- pycapng-0.3/bin/protos/amqp.posa +11 -0
- pycapng-0.3/bin/protos/bacnet.posa +19 -0
- pycapng-0.3/bin/protos/bfd.posa +27 -0
- pycapng-0.3/bin/protos/bgp.posa +12 -0
- pycapng-0.3/bin/protos/cdp.posa +8 -0
- pycapng-0.3/bin/protos/coap.posa +38 -0
- pycapng-0.3/bin/protos/dccp.posa +23 -0
- pycapng-0.3/bin/protos/dhcpv6.posa +23 -0
- pycapng-0.3/bin/protos/dnp3.posa +10 -0
- pycapng-0.3/bin/protos/dot1q.posa +13 -0
- pycapng-0.3/bin/protos/eap.posa +13 -0
- pycapng-0.3/bin/protos/eapol.posa +15 -0
- pycapng-0.3/bin/protos/eapol_key.posa +27 -0
- pycapng-0.3/bin/protos/eigrp.posa +20 -0
- pycapng-0.3/bin/protos/esp.posa +6 -0
- pycapng-0.3/bin/protos/hsrp.posa +23 -0
- pycapng-0.3/bin/protos/icmpv6.posa +23 -0
- pycapng-0.3/bin/protos/igmp.posa +12 -0
- pycapng-0.3/bin/protos/ikev2.posa +16 -0
- pycapng-0.3/bin/protos/ipv6.posa +23 -0
- pycapng-0.3/bin/protos/isakmp.posa +20 -0
- pycapng-0.3/bin/protos/kerberos.posa +107 -0
- pycapng-0.3/bin/protos/l2tp.posa +12 -0
- pycapng-0.3/bin/protos/lacp.posa +26 -0
- pycapng-0.3/bin/protos/llc.posa +13 -0
- pycapng-0.3/bin/protos/modbus_tcp.posa +26 -0
- pycapng-0.3/bin/protos/mpls.posa +5 -0
- pycapng-0.3/bin/protos/mqtt.posa +22 -0
- pycapng-0.3/bin/protos/nbns.posa +60 -0
- pycapng-0.3/bin/protos/netflow_v5.posa +15 -0
- pycapng-0.3/bin/protos/openflow.posa +33 -0
- pycapng-0.3/bin/protos/ospf.posa +20 -0
- pycapng-0.3/bin/protos/pim.posa +18 -0
- pycapng-0.3/bin/protos/ppp.posa +14 -0
- pycapng-0.3/bin/protos/pppoe.posa +14 -0
- pycapng-0.3/bin/protos/ptpv2.posa +28 -0
- pycapng-0.3/bin/protos/rdp.posa +50 -0
- pycapng-0.3/bin/protos/ripv2.posa +8 -0
- pycapng-0.3/bin/protos/rsvp.posa +21 -0
- pycapng-0.3/bin/protos/rtp.posa +19 -0
- pycapng-0.3/bin/protos/sctp.posa +8 -0
- pycapng-0.3/bin/protos/snap.posa +12 -0
- pycapng-0.3/bin/protos/socks5.posa +54 -0
- pycapng-0.3/bin/protos/stp.posa +22 -0
- pycapng-0.3/bin/protos/stun.posa +18 -0
- pycapng-0.3/bin/protos/vrrp.posa +14 -0
- pycapng-0.3/bin/protos/wol.posa +7 -0
- pycapng-0.3/bin/tests/run_tests.sh +598 -0
- pycapng-0.3/bin/tests/test_cstring_security.pcapsh +83 -0
- pycapng-0.3/bin/tests/test_dns.pcapsh +37 -0
- pycapng-0.3/bin/tests/test_forloop.pcapsh +37 -0
- pycapng-0.3/bin/tests/test_inline_protocol.pcapsh +68 -0
- pycapng-0.3/bin/tests/test_posa_custom.pcapsh +41 -0
- pycapng-0.3/bin/tests/test_protocols.pcapsh +72 -0
- pycapng-0.3/bin/tests/test_raw_inspect.pcapsh +33 -0
- pycapng-0.3/bin/tests/test_tcp_session.pcapsh +38 -0
- pycapng-0.3/bin/tests/test_tftp.pcapsh +52 -0
- pycapng-0.3/bin/tests/test_wireshark_samples.pcapsh +46 -0
- pycapng-0.3/bin/tests/tftp_protos.posa +42 -0
- pycapng-0.3/bindings/CMakeLists.txt +1 -0
- pycapng-0.3/bindings/python/CMakeLists.txt +61 -0
- pycapng-0.3/bindings/python/embed_protos.py +33 -0
- pycapng-0.3/bindings/python/examples/capture_tui.py +411 -0
- pycapng-0.3/bindings/python/examples/live_capture.py +128 -0
- pycapng-0.3/bindings/python/examples/pcapsh_callback.py +320 -0
- pycapng-0.3/bindings/python/examples/pcapsh_custom_protocol.py +197 -0
- pycapng-0.3/bindings/python/examples/pcapsh_inline.py +45 -0
- pycapng-0.3/bindings/python/examples/pcapsh_run_script.py +64 -0
- pycapng-0.3/bindings/python/examples/pcapsh_tls_https.py +187 -0
- pycapng-0.3/bindings/python/examples/read.py +23 -0
- pycapng-0.3/bindings/python/examples/write_rdp.py +131 -0
- pycapng-0.3/bindings/python/examples/write_tcp.py +10 -0
- pycapng-0.3/bindings/python/pycapng.cpp +1175 -0
- pycapng-0.3/bindings/python/pycapng.hpp +193 -0
- pycapng-0.3/bindings/python/pycapture.cpp +518 -0
- pycapng-0.3/bindings/python/pypcapsh.cpp +200 -0
- pycapng-0.3/bindings/python/tests/__init__.py +0 -0
- pycapng-0.3/bindings/python/tests/test_pcapsh.py +530 -0
- pycapng-0.3/lib/CMakeLists.txt +85 -0
- pycapng-0.3/lib/blocks.c +599 -0
- pycapng-0.3/lib/capture.c +1518 -0
- pycapng-0.3/lib/dissect.c +1341 -0
- pycapng-0.3/lib/easyapi.c +87 -0
- pycapng-0.3/lib/include/libpcapng/blocks.h +315 -0
- pycapng-0.3/lib/include/libpcapng/capture.h +260 -0
- pycapng-0.3/lib/include/libpcapng/dissect.h +92 -0
- pycapng-0.3/lib/include/libpcapng/easyapi.h +22 -0
- pycapng-0.3/lib/include/libpcapng/io.h +30 -0
- pycapng-0.3/lib/include/libpcapng/libpcapng.h +61 -0
- pycapng-0.3/lib/include/libpcapng/linktypes.h +239 -0
- pycapng-0.3/lib/include/libpcapng/objects.h +62 -0
- pycapng-0.3/lib/include/libpcapng/posa.h +121 -0
- pycapng-0.3/lib/include/libpcapng/protocols/asn1.h +39 -0
- pycapng-0.3/lib/include/libpcapng/protocols/bootp.h +36 -0
- pycapng-0.3/lib/include/libpcapng/protocols/dhcp.h +35 -0
- pycapng-0.3/lib/include/libpcapng/protocols/dns.h +32 -0
- pycapng-0.3/lib/include/libpcapng/protocols/ethernet.h +22 -0
- pycapng-0.3/lib/include/libpcapng/protocols/flow.h +50 -0
- pycapng-0.3/lib/include/libpcapng/protocols/http2.h +27 -0
- pycapng-0.3/lib/include/libpcapng/protocols/http2_hpack.h +34 -0
- pycapng-0.3/lib/include/libpcapng/protocols/http2_stream.h +36 -0
- pycapng-0.3/lib/include/libpcapng/protocols/icmp.h +26 -0
- pycapng-0.3/lib/include/libpcapng/protocols/ipv4.h +40 -0
- pycapng-0.3/lib/include/libpcapng/protocols/ntp.h +53 -0
- pycapng-0.3/lib/include/libpcapng/protocols/rdp.h +287 -0
- pycapng-0.3/lib/include/libpcapng/protocols/ssh.h +27 -0
- pycapng-0.3/lib/include/libpcapng/protocols/ssl.h +38 -0
- pycapng-0.3/lib/include/libpcapng/protocols/tcp.h +55 -0
- pycapng-0.3/lib/include/libpcapng/protocols/tcp_mss.h +30 -0
- pycapng-0.3/lib/include/libpcapng/protocols/tls_stream.h +29 -0
- pycapng-0.3/lib/include/libpcapng/protocols/udp.h +27 -0
- pycapng-0.3/lib/include/libpcapng/reassembly.h +68 -0
- pycapng-0.3/lib/include/libpcapng/reassembly_tcp.h +58 -0
- pycapng-0.3/lib/io.c +128 -0
- pycapng-0.3/lib/objects.c +629 -0
- pycapng-0.3/lib/posa.c +653 -0
- pycapng-0.3/lib/protocols/asn1.c +125 -0
- pycapng-0.3/lib/protocols/dhcp.c +144 -0
- pycapng-0.3/lib/protocols/dns.c +238 -0
- pycapng-0.3/lib/protocols/ethernet.c +12 -0
- pycapng-0.3/lib/protocols/flow.c +163 -0
- pycapng-0.3/lib/protocols/http2.c +68 -0
- pycapng-0.3/lib/protocols/http2_hpack.c +42 -0
- pycapng-0.3/lib/protocols/http2_stream.c +63 -0
- pycapng-0.3/lib/protocols/icmp.c +95 -0
- pycapng-0.3/lib/protocols/ipv4.c +77 -0
- pycapng-0.3/lib/protocols/ntp.c +80 -0
- pycapng-0.3/lib/protocols/rdp.c +1201 -0
- pycapng-0.3/lib/protocols/ssh.c +98 -0
- pycapng-0.3/lib/protocols/ssl.c +325 -0
- pycapng-0.3/lib/protocols/tcp.c +99 -0
- pycapng-0.3/lib/protocols/tcp_mss.c +29 -0
- pycapng-0.3/lib/protocols/tls_stream.c +27 -0
- pycapng-0.3/lib/protocols/udp.c +104 -0
- pycapng-0.3/lib/reassembly.c +172 -0
- pycapng-0.3/lib/reassembly_tcp.c +220 -0
- pycapng-0.3/lib/tests/CMakeLists.txt +60 -0
- pycapng-0.3/lib/tests/dhcp-write.c +75 -0
- pycapng-0.3/lib/tests/dns-write.c +170 -0
- pycapng-0.3/lib/tests/ntp-write.c +67 -0
- pycapng-0.3/lib/tests/pcapng-spec.c +1935 -0
- pycapng-0.3/lib/tests/rdp-write.c +188 -0
- pycapng-0.3/lib/tests/read.c +18 -0
- pycapng-0.3/lib/tests/reasm.c +238 -0
- pycapng-0.3/lib/tests/ssl-http2-write.c +201 -0
- pycapng-0.3/lib/tests/tcp-sequence.c +131 -0
- pycapng-0.3/lib/tests/writeall.c +57 -0
- pycapng-0.3/libpcapng.pc.cmake +8 -0
- pycapng-0.3/pyproject.toml +103 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
tag:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
outputs:
|
|
16
|
+
tag: ${{ steps.create.outputs.tag }}
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v5
|
|
19
|
+
|
|
20
|
+
- name: Create tag and release
|
|
21
|
+
id: create
|
|
22
|
+
env:
|
|
23
|
+
GH_TOKEN: ${{ github.token }}
|
|
24
|
+
run: |
|
|
25
|
+
VERSION=$(cat VERSION)
|
|
26
|
+
SHA=$(git rev-parse --short HEAD)
|
|
27
|
+
TAG="v${VERSION}-${SHA}"
|
|
28
|
+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
|
29
|
+
git tag "${TAG}" 2>/dev/null || echo "tag already exists"
|
|
30
|
+
git push origin "${TAG}" 2>/dev/null || echo "tag already pushed"
|
|
31
|
+
gh release create "${TAG}" \
|
|
32
|
+
--title "${TAG}" \
|
|
33
|
+
--notes "Automated build from commit ${GITHUB_SHA}" \
|
|
34
|
+
2>/dev/null || echo "release already exists"
|
|
35
|
+
|
|
36
|
+
build:
|
|
37
|
+
needs: tag
|
|
38
|
+
name: ${{ matrix.os }} / py${{ matrix.python-version }}
|
|
39
|
+
runs-on: ${{ matrix.os }}
|
|
40
|
+
strategy:
|
|
41
|
+
fail-fast: false
|
|
42
|
+
matrix:
|
|
43
|
+
os:
|
|
44
|
+
- ubuntu-latest # x86_64
|
|
45
|
+
- ubuntu-24.04-arm # aarch64
|
|
46
|
+
# - macos-13 # x86_64
|
|
47
|
+
- macos-14 # arm64
|
|
48
|
+
python-version: ['3.11', '3.12', '3.13', '3.14']
|
|
49
|
+
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v5
|
|
52
|
+
|
|
53
|
+
- uses: actions/setup-python@v6
|
|
54
|
+
with:
|
|
55
|
+
python-version: ${{ matrix.python-version }}
|
|
56
|
+
allow-prereleases: true
|
|
57
|
+
|
|
58
|
+
- name: Install pybind11
|
|
59
|
+
run: pip install pybind11
|
|
60
|
+
|
|
61
|
+
- name: Configure
|
|
62
|
+
run: |
|
|
63
|
+
cmake -S . -B build \
|
|
64
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
65
|
+
-Dpybind11_DIR=$(python3 -m pybind11 --cmakedir)
|
|
66
|
+
|
|
67
|
+
- name: Build
|
|
68
|
+
run: cmake --build build --target pycapng --parallel
|
|
69
|
+
|
|
70
|
+
- name: Stage artifact
|
|
71
|
+
shell: bash
|
|
72
|
+
run: |
|
|
73
|
+
SO=$(find build/bindings -name "pycapng*.so" -o -name "pycapng*.dylib" | head -1)
|
|
74
|
+
cp "$SO" .
|
|
75
|
+
echo "ARTIFACT=$(basename $SO)" >> $GITHUB_ENV
|
|
76
|
+
|
|
77
|
+
- uses: actions/upload-artifact@v7
|
|
78
|
+
with:
|
|
79
|
+
name: ${{ env.ARTIFACT }}
|
|
80
|
+
path: ${{ env.ARTIFACT }}
|
|
81
|
+
|
|
82
|
+
- name: Attach to release
|
|
83
|
+
env:
|
|
84
|
+
GH_TOKEN: ${{ github.token }}
|
|
85
|
+
run: gh release upload "${{ needs.tag.outputs.tag }}" "${{ env.ARTIFACT }}" --repo "${{ github.repository }}" --clobber
|
|
86
|
+
|
|
87
|
+
build-debian:
|
|
88
|
+
needs: tag
|
|
89
|
+
name: debian-bookworm-${{ matrix.arch }} / py3.14
|
|
90
|
+
runs-on: ${{ matrix.runner }}
|
|
91
|
+
container: ghcr.io/astral-sh/uv:python3.14-bookworm-slim
|
|
92
|
+
strategy:
|
|
93
|
+
fail-fast: false
|
|
94
|
+
matrix:
|
|
95
|
+
include:
|
|
96
|
+
- runner: ubuntu-latest # x86_64
|
|
97
|
+
arch: x86_64
|
|
98
|
+
- runner: ubuntu-24.04-arm # aarch64
|
|
99
|
+
arch: aarch64
|
|
100
|
+
|
|
101
|
+
steps:
|
|
102
|
+
- uses: actions/checkout@v5
|
|
103
|
+
|
|
104
|
+
- name: Install build dependencies
|
|
105
|
+
run: apt-get update -qq && apt-get install -y --no-install-recommends cmake build-essential gh
|
|
106
|
+
|
|
107
|
+
- name: Install pybind11
|
|
108
|
+
run: uv pip install --system pybind11
|
|
109
|
+
|
|
110
|
+
- name: Configure
|
|
111
|
+
run: |
|
|
112
|
+
cmake -S . -B build \
|
|
113
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
114
|
+
-Dpybind11_DIR=$(python3 -m pybind11 --cmakedir)
|
|
115
|
+
|
|
116
|
+
- name: Build
|
|
117
|
+
run: cmake --build build --target pycapng --parallel
|
|
118
|
+
|
|
119
|
+
- name: Stage artifact
|
|
120
|
+
run: |
|
|
121
|
+
SO=$(find build/bindings -name "pycapng*.so" | head -1)
|
|
122
|
+
cp "$SO" .
|
|
123
|
+
echo "ARTIFACT=$(basename $SO)" >> $GITHUB_ENV
|
|
124
|
+
|
|
125
|
+
- uses: actions/upload-artifact@v7
|
|
126
|
+
with:
|
|
127
|
+
name: ${{ env.ARTIFACT }}-debian-bookworm
|
|
128
|
+
path: ${{ env.ARTIFACT }}
|
|
129
|
+
|
|
130
|
+
- name: Attach to release
|
|
131
|
+
env:
|
|
132
|
+
GH_TOKEN: ${{ github.token }}
|
|
133
|
+
run: gh release upload "${{ needs.tag.outputs.tag }}" "${{ env.ARTIFACT }}" --repo "${{ github.repository }}" --clobber
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: Build & publish wheels
|
|
2
|
+
|
|
3
|
+
# Wheels are built on every push/PR to catch breakage early.
|
|
4
|
+
# They are *published* to PyPI only when a version tag like `v0.2.0` is pushed.
|
|
5
|
+
#
|
|
6
|
+
# To release:
|
|
7
|
+
# git tag v0.2.0
|
|
8
|
+
# git push origin v0.2.0
|
|
9
|
+
#
|
|
10
|
+
# PyPI publishing uses Trusted Publishing (OIDC) — no API token needed.
|
|
11
|
+
# Set it up once at https://pypi.org/manage/project/pycapng/settings/publishing/
|
|
12
|
+
# with environment name "pypi".
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
push:
|
|
16
|
+
branches: [main, dev]
|
|
17
|
+
tags: ["v*"]
|
|
18
|
+
pull_request:
|
|
19
|
+
workflow_dispatch:
|
|
20
|
+
|
|
21
|
+
concurrency:
|
|
22
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
23
|
+
cancel-in-progress: true
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
# ── Wheels ────────────────────────────────────────────────────────────────
|
|
27
|
+
build_wheels:
|
|
28
|
+
name: wheels · ${{ matrix.name }}
|
|
29
|
+
runs-on: ${{ matrix.runner }}
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
include:
|
|
34
|
+
- { name: linux-x86_64, runner: ubuntu-latest, archs: x86_64 }
|
|
35
|
+
- { name: linux-aarch64, runner: ubuntu-24.04-arm, archs: aarch64 }
|
|
36
|
+
- { name: macos-arm64, runner: macos-14, archs: arm64 }
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
with:
|
|
41
|
+
fetch-depth: 0 # setuptools-scm needs full history + tags
|
|
42
|
+
|
|
43
|
+
- name: Build wheels
|
|
44
|
+
uses: pypa/cibuildwheel@v2.23.3
|
|
45
|
+
env:
|
|
46
|
+
CIBW_ARCHS: ${{ matrix.archs }}
|
|
47
|
+
# All other config lives in [tool.cibuildwheel] in pyproject.toml.
|
|
48
|
+
|
|
49
|
+
- uses: actions/upload-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: wheels-${{ matrix.name }}
|
|
52
|
+
path: ./wheelhouse/*.whl
|
|
53
|
+
|
|
54
|
+
# ── Source distribution ───────────────────────────────────────────────────
|
|
55
|
+
build_sdist:
|
|
56
|
+
name: sdist
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/checkout@v4
|
|
60
|
+
with:
|
|
61
|
+
fetch-depth: 0
|
|
62
|
+
|
|
63
|
+
- name: Build sdist
|
|
64
|
+
run: pipx run build --sdist
|
|
65
|
+
|
|
66
|
+
- uses: actions/upload-artifact@v4
|
|
67
|
+
with:
|
|
68
|
+
name: sdist
|
|
69
|
+
path: ./dist/*.tar.gz
|
|
70
|
+
|
|
71
|
+
# ── Publish ───────────────────────────────────────────────────────────────
|
|
72
|
+
publish:
|
|
73
|
+
name: publish to PyPI
|
|
74
|
+
needs: [build_wheels, build_sdist]
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
# Only publish on a clean version tag (v0.2.0, not v0.1-abc1234).
|
|
77
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
78
|
+
environment:
|
|
79
|
+
name: pypi
|
|
80
|
+
url: https://pypi.org/p/pycapng
|
|
81
|
+
permissions:
|
|
82
|
+
id-token: write # required for OIDC Trusted Publishing
|
|
83
|
+
steps:
|
|
84
|
+
- uses: actions/download-artifact@v4
|
|
85
|
+
with:
|
|
86
|
+
path: dist
|
|
87
|
+
pattern: "*"
|
|
88
|
+
merge-multiple: true # collect all wheels + sdist into dist/
|
|
89
|
+
|
|
90
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
pycapng-0.3/.gitignore
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
cmake_minimum_required (VERSION 3.20)
|
|
2
|
+
project (libpcapng)
|
|
3
|
+
|
|
4
|
+
if(POLICY CMP0148)
|
|
5
|
+
cmake_policy(SET CMP0148 NEW)
|
|
6
|
+
endif()
|
|
7
|
+
|
|
8
|
+
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
|
9
|
+
message(FATAL_ERROR "CMake generation is not allowed within the source directory!
|
|
10
|
+
Remove the CMakeCache.txt file and try again from another folder, e.g.:
|
|
11
|
+
|
|
12
|
+
rm CMakeCache.txt
|
|
13
|
+
mkdir build
|
|
14
|
+
cd build
|
|
15
|
+
cmake ..
|
|
16
|
+
")
|
|
17
|
+
endif()
|
|
18
|
+
|
|
19
|
+
# add_definitions(-DDEBUG=1)
|
|
20
|
+
include(GNUInstallDirs)
|
|
21
|
+
enable_testing()
|
|
22
|
+
|
|
23
|
+
include(FindPkgConfig)
|
|
24
|
+
include(FindPackageHandleStandardArgs)
|
|
25
|
+
|
|
26
|
+
file(STRINGS VERSION VERSION)
|
|
27
|
+
set(LIBPCAPNG_VERSION ${VERSION})
|
|
28
|
+
file(STRINGS "VERSION" LIBPCAPNG_VERSION)
|
|
29
|
+
string(REGEX MATCH "^[0-9]+" LIBPCAPNG_VERSION_MAJOR ${LIBPCAPNG_VERSION})
|
|
30
|
+
string(REGEX MATCH "[0-9]+$" LIBPCAPNG_VERSION_MINOR ${LIBPCAPNG_VERSION})
|
|
31
|
+
message("Libpcapng Version: ${LIBPCAPNG_VERSION}")
|
|
32
|
+
message("Libpcapng Version Major: ${LIBPCAPNG_VERSION_MAJOR}")
|
|
33
|
+
message("Libpcapng Version Minor: ${LIBPCAPNG_VERSION_MINOR}")
|
|
34
|
+
|
|
35
|
+
configure_file("${libpcapng_SOURCE_DIR}/libpcapng.pc.cmake" "${libpcapng_BINARY_DIR}/libpcapng.pc")
|
|
36
|
+
install(FILES "${libpcapng_BINARY_DIR}/libpcapng.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" COMPONENT Headers)
|
|
37
|
+
|
|
38
|
+
include_directories(AFTER ${libpcapng_SOURCE_DIR}/lib/include)
|
|
39
|
+
|
|
40
|
+
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
|
|
41
|
+
set(PYBIND11_FINDPYTHON ON)
|
|
42
|
+
find_package(pybind11 CONFIG REQUIRED)
|
|
43
|
+
|
|
44
|
+
# <pybind11>
|
|
45
|
+
# execute_process (
|
|
46
|
+
# COMMAND pybind11-config --cmakedir
|
|
47
|
+
# OUTPUT_VARIABLE PYBIND11_CMAKEDIR
|
|
48
|
+
# OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
49
|
+
# )
|
|
50
|
+
# set(pybind11_ROOT "${PYBIND11_CMAKEDIR}")
|
|
51
|
+
# set(PYBIND11_FINDPYTHON "off")
|
|
52
|
+
# find_package(pybind11 CONFIG REQUIRED)
|
|
53
|
+
# message("Using Python libraries: ${Python_LIBRARIES}")
|
|
54
|
+
# </pybind11>
|
|
55
|
+
|
|
56
|
+
# find_path(WANDIO_INCLUDE_DIR NAMES wandio.h)
|
|
57
|
+
# find_library(WANDIO_LIBRARY NAMES wandio REQUIRED)
|
|
58
|
+
# find_package_handle_standard_args(wandio "Could not find wandio library header and/or library ${DEFAULT_MSG}" WANDIO_INCLUDE_DIR WANDIO_LIBRARY)
|
|
59
|
+
# if(WANDIO_FOUND)
|
|
60
|
+
# message("-- Found wandio: ${WANDIO_INCLUDE_DIR}" )
|
|
61
|
+
# endif()
|
|
62
|
+
|
|
63
|
+
set(LIBPCAPNG_INCLUDE_DIRS "${libpcapng_SOURCE_DIR}/lib/include/")
|
|
64
|
+
if (LINUX)
|
|
65
|
+
set(LIBPCAPNG_LIBRARY "${libpcapng_BINARY_DIR}/lib/libpcapng.so")
|
|
66
|
+
endif()
|
|
67
|
+
if (APPLE)
|
|
68
|
+
set(CMAKE_MACOSX_RPATH ON)
|
|
69
|
+
set(LIBPCAPNG_LIBRARY "${libpcapng_BINARY_DIR}/lib/libpcapng.dylib")
|
|
70
|
+
endif()
|
|
71
|
+
|
|
72
|
+
add_definitions(-g)
|
|
73
|
+
|
|
74
|
+
add_subdirectory(lib)
|
|
75
|
+
add_subdirectory(bin)
|
|
76
|
+
add_subdirectory(bindings)
|
|
77
|
+
|
pycapng-0.3/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Devo Inc.
|
|
4
|
+
Copyright (c) 2022 Sebastien Tricaud
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
pycapng-0.3/PKG-INFO
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pycapng
|
|
3
|
+
Version: 0.3
|
|
4
|
+
Summary: Python bindings for libpcapng — read/write pcapng files and live packet capture
|
|
5
|
+
Keywords: pcapng,pcap,packet-capture,network,packet,wireshark
|
|
6
|
+
Author-Email: Seb Tricaud <sebastien.tricaud@proton.me>
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
11
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: C++
|
|
14
|
+
Classifier: Topic :: System :: Networking :: Monitoring
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Project-URL: Homepage, https://github.com/stricaud/libpcapng
|
|
17
|
+
Project-URL: Repository, https://github.com/stricaud/libpcapng
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# libpcapng
|
|
22
|
+
|
|
23
|
+
C library with Python bindings to read and write pcapng buffers. It follows the pcapng standard from https://github.com/pcapng/pcapng
|
|
24
|
+
|
|
25
|
+
## Writing your first packet
|
|
26
|
+
|
|
27
|
+
Let's write a TCP SYN using libdumbnet and push the buffer into a pcapng file:
|
|
28
|
+
|
|
29
|
+
```c
|
|
30
|
+
#include <stdio.h>
|
|
31
|
+
#include <stdlib.h>
|
|
32
|
+
#include <string.h>
|
|
33
|
+
|
|
34
|
+
#include <dumbnet.h>
|
|
35
|
+
#include <libpcapng/libpcapng.h>
|
|
36
|
+
|
|
37
|
+
int main(int argc, char **argv)
|
|
38
|
+
{
|
|
39
|
+
FILE *pcapout;
|
|
40
|
+
|
|
41
|
+
char *pkt;
|
|
42
|
+
size_t pktsize = 40;
|
|
43
|
+
|
|
44
|
+
pkt = (char *)malloc(pktsize);
|
|
45
|
+
if (!pkt) {
|
|
46
|
+
fprintf(stderr, "Cannot allocate pkt!\n");
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
pcapout = fopen("pkts.pcap", "wb");
|
|
51
|
+
|
|
52
|
+
libpcapng_write_header_to_file(pcapout);
|
|
53
|
+
|
|
54
|
+
uint32_t saddr = 0x0100a8c0;
|
|
55
|
+
uint32_t daddr = 0x561c1268;
|
|
56
|
+
|
|
57
|
+
ip_pack_hdr(pkt, 0, pktsize, 1, 0, 128, IP_PROTO_TCP, saddr, daddr);
|
|
58
|
+
tcp_pack_hdr(pkt + 20, 4096, 80, 1, 0, TH_SYN, 14, 0);
|
|
59
|
+
ip_checksum(pkt, pktsize);
|
|
60
|
+
|
|
61
|
+
libpcapng_write_enhanced_packet_to_file(pcapout, pkt, pktsize);
|
|
62
|
+
|
|
63
|
+
fflush(pcapout);
|
|
64
|
+
fclose(pcapout);
|
|
65
|
+
|
|
66
|
+
free(pkt);
|
|
67
|
+
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Compile using:
|
|
73
|
+
```
|
|
74
|
+
gcc test.c -o test -ldumbnet $(pkg-config libpcapng --libs --cflags)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
And after running, open the created pcap with wireshark:
|
|
78
|
+
|
|
79
|
+
<p align="center"><img src="doc/firstpkt.png" size="30%"/></p>
|
pycapng-0.3/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# libpcapng
|
|
2
|
+
|
|
3
|
+
C library with Python bindings to read and write pcapng buffers. It follows the pcapng standard from https://github.com/pcapng/pcapng
|
|
4
|
+
|
|
5
|
+
## Writing your first packet
|
|
6
|
+
|
|
7
|
+
Let's write a TCP SYN using libdumbnet and push the buffer into a pcapng file:
|
|
8
|
+
|
|
9
|
+
```c
|
|
10
|
+
#include <stdio.h>
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
#include <string.h>
|
|
13
|
+
|
|
14
|
+
#include <dumbnet.h>
|
|
15
|
+
#include <libpcapng/libpcapng.h>
|
|
16
|
+
|
|
17
|
+
int main(int argc, char **argv)
|
|
18
|
+
{
|
|
19
|
+
FILE *pcapout;
|
|
20
|
+
|
|
21
|
+
char *pkt;
|
|
22
|
+
size_t pktsize = 40;
|
|
23
|
+
|
|
24
|
+
pkt = (char *)malloc(pktsize);
|
|
25
|
+
if (!pkt) {
|
|
26
|
+
fprintf(stderr, "Cannot allocate pkt!\n");
|
|
27
|
+
return -1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
pcapout = fopen("pkts.pcap", "wb");
|
|
31
|
+
|
|
32
|
+
libpcapng_write_header_to_file(pcapout);
|
|
33
|
+
|
|
34
|
+
uint32_t saddr = 0x0100a8c0;
|
|
35
|
+
uint32_t daddr = 0x561c1268;
|
|
36
|
+
|
|
37
|
+
ip_pack_hdr(pkt, 0, pktsize, 1, 0, 128, IP_PROTO_TCP, saddr, daddr);
|
|
38
|
+
tcp_pack_hdr(pkt + 20, 4096, 80, 1, 0, TH_SYN, 14, 0);
|
|
39
|
+
ip_checksum(pkt, pktsize);
|
|
40
|
+
|
|
41
|
+
libpcapng_write_enhanced_packet_to_file(pcapout, pkt, pktsize);
|
|
42
|
+
|
|
43
|
+
fflush(pcapout);
|
|
44
|
+
fclose(pcapout);
|
|
45
|
+
|
|
46
|
+
free(pkt);
|
|
47
|
+
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Compile using:
|
|
53
|
+
```
|
|
54
|
+
gcc test.c -o test -ldumbnet $(pkg-config libpcapng --libs --cflags)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
And after running, open the created pcap with wireshark:
|
|
58
|
+
|
|
59
|
+
<p align="center"><img src="doc/firstpkt.png" size="30%"/></p>
|