- prstmidx.rb
#----------------------------------------------------------
# prstmidx.rb - Print all the streams in the capture file
# Alternate approach demostrating Ruby Classes
#
# usage: prstmidx <capture-filename>
#
#---------------------------------------------------------
require 'win32ole'
USAGE = "prstmidx <capture-filename>"
endl = "\n"
tab = "\t"
class UStream
def initialize(usnfstream)
@stm = usnfstream
end
def to_s
"#{@stm.ID}\t#{@stm.StartTimeStamp}\t#{@stm.SourceAddress}\t" +
"#{@stm.DestinationAddress}\t#{@stm.InByteCount}\t#{@stm.OutByteCount}\t" +
"#{@stm.Description}\n"
end
end
class StreamList
def initialize(stmindex)
@streamList = Array.new
count = stmindex.Count
(0..count-1).each { |idx| @streamList.push( UStream.new(stmindex.Item(idx)) ) }
end
def to_s
s = "Number of streams in capture file = #{@streamList.length}\n"
@streamList.each { |itm| s += itm.to_s }
s
end
end
if ARGV.length != 1
puts USAGE
exit 1
end
UnsniffDB = WIN32OLE.new("Unsniff.Database")
UnsniffDB.Open(ARGV[0])
slist = StreamList.new(UnsniffDB.StreamIndex)
print slist
UnsniffDB.Close()