/usr/share/doc/ruby-pcap/examples/tcpdump.rb is in ruby-pcap 0.7.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #!/usr/bin/env ruby
require 'rubygems'
require 'pcaplet'
include Pcap
class Time
# tcpdump style format
def to_s
sprintf "%0.2d:%0.2d:%0.2d.%0.6d", hour, min, sec, tv_usec
end
end
pcaplet = Pcaplet.new
pcaplet.each_packet { |pkt|
print "#{pkt.time} #{pkt}"
if pkt.tcp?
print " (#{pkt.tcp_data_len})"
print " ack #{pkt.tcp_ack}" if pkt.tcp_ack?
print " win #{pkt.tcp_win}"
end
if pkt.ip?
print " (DF)" if pkt.ip_df?
end
print "\n"
}
pcaplet.close
|