Hi,
Can someone please help me out here? I’m trying to use Ruby/Libpcap
extension to write a rudimentary packet sniffer.
I downloaded ruby/libpcap 0.6 from
http://www.goto.info.waseda.ac.jp/~fukusima/ruby/pcap-e.html.
The following code breaks when calling it from the command-line with a
parameter, such as:
$>ruby dumptraffic.rb en1
/usr/local/lib/ruby/site_ruby/1.8/universal-darwin8.0/pcap.bundle:
warning: do not use Fixnums as Symbols
/usr/local/lib/ruby/site_ruby/1.8/universal-darwin8.0/pcap.bundle:
warning: do not use Fixnums as Symbols
/usr/local/lib/ruby/site_ruby/1.8/universal-darwin8.0/pcap.bundle:
warning: do not use Fixnums as Symbols
setfilter: parse error
$>
The code:
------- start of code
require ‘pcaplet’
include Pcap
class Sniffer
def sniff(d)
pcaplet = Pcaplet.new("-i " + d)
c = pcaplet.capture
d = Dumper.open(c,“dump.txt”)
c.each_packet(50) { |pkt|
if pkt.ip?
d.dump(pkt)
puts "hello from #{pkt.src.to_num_s}"
end
}
pcaplet.close
end
end
if FILE == $0
d = ARGV[0]
sniffit = Sniffer.new
sniffit.sniff(d)
end
---- end of code
Any help would be greatly appreciated. Thanks.
- kenny r.