packetz

Packet capturing library built with LibPcap libpcap packet-sniffer packet-capture packet-analyzer opensource pcap
HEAD Latest release released
picatz/packetz
24 2
Kent 'picat' Gruber

🦈 Packetz

Packet capturing library built with LibPcap.

Installation

Add this to your application's shard.yml:

dependencies:
  packetz:
    github: picatz/packetz

Basic Usage

require "packetz"

# start packet capture on default interface
Packetz.capture do |packet|
  puts packet.hexdump
end

Craft your Capture

# create capture handler
cap = Packetz.capture

# stop the capture with ctl+C
Signal::INT.trap do
  puts "Stopping!"
  cap.stop!
  exit
end

# setup the handler
cap.snapshot_length  = 33333
cap.promiscuous_mode = true
cap.monitor_mode     = true

# start capturing
cap.start!

# do something with each packet and its pcap header
cap.each do |packet, pcap_header|
  # something
end

Network Interfaces

# get default interface to capture on
Packetz.interfaces.default
# get all possible interfaces
Packetz.interfaces.all do |interface|
  puts interface
end

Contributors

  • picat Kent 'picat' Gruber - creator, maintainer
  • maiha maiha - pcap.cr
  • puppetpies Brian Hood - libpcap.cr
packetz:
  github: picatz/packetz
  
License MIT
Crystal 0.23.1

Authors

Dependencies 0

Development Dependencies 0

Dependents 0

Last synced .
search fire star recently