pktcopy.rb
# ------------------------------------------------------------------
# pktcopy.rb	Copies given packets from file-1 to file-2
#	usage : pktcopy <from-file> <to-file> <pkts-csv>
#
# ------------------------------------------------------------------
require 'win32ole'
 
USAGE = "pktcopy <from-file> <to-file> <packet-list>"
 
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"
unsniff/samples/pktcopy/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