tcpports2.vbs
'
'	PRINT TCP Src / Dest Ports by using the Find method
'
Dim Sout
Set Sout = WScript.Stdout
 
if WScript.Arguments.Count <> 1 then
	Sout.Writeline   "Usage: tcpport2 <filename>"
	WScript.Quit
end if
 
Set Sout = WScript.Stdout
ArgFile     = WScript.Arguments.Item(0)
 
 
Set UnsniffDB = CreateObject("Unsniff.Database")
UnsniffDB.Open(ArgFile)
 
 
Set PacketStore    = UnsniffDB.PacketIndex
PacketCount	   = PacketStore.Count
 
Dim FName
For I = 0 To PacketCount-1
	Set Packet = PacketStore(I)
	For Each  Layer In Packet.Layers
	If Layer.Name = "TCP" Then
		Set FldSrcPort = Layer.FindField ("Src Port")
		Set FldDestPort = Layer.FindField ("Dest Port")
		Sout.Write   "s:" & FldSrcPort.Value &  vbTab & _
			     "d:" & FldDestPort.Value & vbCrLf
 
 
	End If
	Next
Next
 
UnsniffDB.Close()