# ------------------------------------------------------------------ # pktcopy.rb Copies given packets from file-1 to file-2 # usage : pktcopy # # ------------------------------------------------------------------ require 'win32ole' USAGE = "pktcopy " if ARGV.length != 3 puts USAGE exit 1 end FromFile = ARGV[0] ToFile = ARGV[1] PktIDs = ARGV[2] # Create required database objects FromDB = WIN32OLE.new("Unsniff.Database") ToDB = WIN32OLE.new("Unsniff.Database") FromDB.Open(FromFile) if File.exists?(ToFile) ToDB.Open(ToFile) else ToDB.New(ToFile) end FromPacketIndex = FromDB.PacketIndex PacketIDArr = PktIDs.chomp.split(/\s*,\s*/) PacketIDArr.each { |idx| pkt2copy = FromPacketIndex.Item(idx) ToDB.AddPacket(pkt2copy) } FromDB.Close() ToDB.Save() print "Copied #{PacketIDArr.length} packets to #{ToFile}\n"