Skip to content

Instantly share code, notes, and snippets.

@byingyang
Created July 15, 2011 17:09
Show Gist options
  • Save byingyang/1085082 to your computer and use it in GitHub Desktop.
Save byingyang/1085082 to your computer and use it in GitHub Desktop.
A little script I whipped together to spit out all network traffic using libpcap
#!/usr/bin/env ruby
# this line imports the libpcap ruby bindings
require 'pcaplet'
# create packet sniffer on the wireless card
network = Pcaplet.new('-s 1500 -i en0')
# we only need to look at web packets
www_filter = Pcap::Filter.new('tcp and dst port 80', network.capture)
network.add_filter(www_filter)
network.each_packet { |pkt| puts pkt.tcp_data if !pkt.tcp_data.nil? }
network.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment