2006-11-06 03:05:06 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
$:.unshift(File.dirname(__FILE__))
|
2006-11-06 03:43:33 +00:00
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2006-11-06 03:05:06 +00:00
|
|
|
|
2006-11-06 03:43:33 +00:00
|
|
|
require 'pcapletx'
|
|
|
|
include PcapX
|
2006-11-06 03:05:06 +00:00
|
|
|
|
2006-11-06 04:14:18 +00:00
|
|
|
class Time
|
|
|
|
# tcpdump style format
|
|
|
|
def to_s
|
|
|
|
sprintf "%0.2d:%0.2d:%0.2d.%0.6d", hour, min, sec, tv_usec
|
|
|
|
end
|
|
|
|
end
|
2006-11-06 03:05:06 +00:00
|
|
|
|
2006-11-06 04:14:18 +00:00
|
|
|
pcaplet = PcapletX.new(ARGV.join(' '))
|
2006-11-06 03:05:06 +00:00
|
|
|
|
2006-11-06 04:14:18 +00:00
|
|
|
pcaplet.each_packet do |pkt|
|
2007-02-15 21:14:11 +00:00
|
|
|
print "#{pkt.time} #{pkt} #{pkt.datalink} #{pkt.raw_data.index("\xff" * 6)}"
|
2006-11-06 04:14:18 +00:00
|
|
|
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"
|
2006-11-06 03:05:06 +00:00
|
|
|
end
|
|
|
|
|
2006-11-06 04:14:18 +00:00
|
|
|
|
2006-11-06 03:05:06 +00:00
|
|
|
pcaplet.close
|