pcap-cli

module
v1.0.0-rc150 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2025 License: Apache-2.0

README

PCAP CLI

High performance packet capturing translator leveraged by gopacket.

Currently offering JSON packet translation into files and stdout.

Amazing to be used alongside jq


How to build

Dependencies

  • libpcap-dev: install from distro repos
  • stringer: go install golang.org/x/tools/cmd/stringer@latest

Using go

go generate ./...
go build -o bin/pcap cmd/pcap.go

NOTE: apply gofumpt before commit; i/e: gofumpt -l -w .

Using Taskfile

Quick build
task -v build
Verbose build
task -v dist
Docker build
task -v docker-build

How to use

Using goacket engine

Generating JSON
sudo pcap -eng=google -promisc -i ${IFACE} -s ${SNAPLEN} -fmt=json -stdout -filter='tcp'
Generating ordered JSON
sudo pcap -eng=google -promisc -i ${IFACE} -s ${SNAPLEN} -fmt=json -stdout -filter='tcp' -ordered
Generating console output and JSON files
sudo pcap -eng=google -promisc -i ${IFACE} -s ${SNAPLEN} -w part_%Y%m%d_%H%M%S -ext=json -fmt=json -stdout -filter='tcp'
Terminate execution after defined seconds
sudo pcap -eng=google -promisc \
  -i ${IFACE} -s ${SNAPLEN} \
  -w part_%Y%m%d_%H%M%S -ext=json \
  -fmt=json -stdout \
  -timeout=60 -filter='tcp'
Terminate execution after defined seconds and rotate every defined seconds
sudo pcap -eng=google -promisc \
  -i ${IFACE} -s ${SNAPLEN} \
  -w part_%Y%m%d_%H%M%S -ext=json \
  -fmt=json -stdout \
  -timeout=60 -interval=10 -filter='tcp'

Projects using PCAP CLI


Roadmap

Translators

Integrations

  • gRPC packet capture streaming

Directories

Path Synopsis
internal
pb
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL