Skip to content

Instantly share code, notes, and snippets.

@reu
Created June 5, 2013 17:28
Show Gist options
  • Save reu/4afae4d610d98cab899e to your computer and use it in GitHub Desktop.
Save reu/4afae4d610d98cab899e to your computer and use it in GitHub Desktop.
Simple sniffer in Ruby using pcap
require 'rubygems'
require 'pcaprub'
capture = PCAPRUB::Pcap.open_live('lo0', 65535, true, 0)
capture.setfilter('icmp')
while 1==1
puts(capture.stats())
pkt = capture.next()
if pkt
puts "captured packet"
end
sleep(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment