Packet capturing library built with LibPcap.
Add this to your application's shard.yml
:
dependencies:
packetz:
github: picatz/packetz
require "packetz"
# start packet capture on default interface
Packetz.capture do |packet|
puts packet.hexdump
end
# 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
# get default interface to capture on
Packetz.interfaces.default
# get all possible interfaces
Packetz.interfaces.all do |interface|
puts interface
end
- picat Kent 'picat' Gruber - creator, maintainer
- maiha maiha -
pcap.cr
- puppetpies Brian Hood -
libpcap.cr