tcpports.rb
# ------------------------------------------------------------------
# tcpports.rb	Print TCP Port Information 
#	usage : tcpports <capture-file> 
#
#
# ------------------------------------------------------------------
require 'win32ole'
 
USAGE = "tcpports <capture-filename> "
 
if ARGV.length != 1
	puts USAGE
	exit 1
end
 
InputFile = ARGV[0]
UnsniffDB = WIN32OLE.new("Unsniff.Database")
UnsniffDB.Open(InputFile)
 
PacketIndex = UnsniffDB.PacketIndex
(0..PacketIndex.Count-1).each do |idx|
	pkt = PacketIndex.Item(idx)
	layers = pkt.Layers
	layers.each do |lyr| 
		if lyr.Name == "TCP"
			sport = lyr.FindField("Src Port")
			dport = lyr.FindField("Dest Port")
			print "s: #{sport.Value}\t\td: #{dport.Value}\n"
		end
	end
end
 
UnsniffDB.Close()
unsniff/samples/tcpports/ruby.txt · Last modified: 2014/09/11 23:23 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki