' ' batchimp - Import all *.PCAP files into a Unsniff database ' ' ----------------------- ' Check usage & arguments ' ----------------------- Set Sout = WScript.Stdout if WScript.Arguments.Count <> 3 then Sout.WriteLine "Usage: batchimp <directory> <wildcard> <output-usnf-file>" WScript.Quit end if FromDir = WScript.Arguments.Item(0) WildCard = WScript.Arguments.Item(1) OutFile = WScript.Arguments.Item(2) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FolderExists(FromDir) Then WScript.Echo "Folder " & FromDir & " does not exist" WScript.Quit End If ' ----------------------------- ' Open or Create a New Database ' ----------------------------- Set UnsniffDB = CreateObject("Unsniff.Database") If fso.FileExists(OutFile) Then Sout.WriteLine "Opening Unsniff DB " & OutFile UnsniffDB.Open(OutFile) Else Sout.WriteLine "Creating Unsniff DB " & OutFile UnsniffDB.New(OutFile) End If ' --------------------------------------- ' Process Each *.pcap file in the directory ' --------------------------------------- Dim objRE Dim File Dim fileName FromDir = WScript.Arguments.Item(0) Set Folder = fso.GetFolder(FromDir) Set objRE = New RegExp objRE.Pattern = WildCard objRE.IgnoreCase = True On Error Resume Next For Each File in Folder.Files fileName = File.Name Sout.Writeline "Filename is " & fileName & " Wildcard is " & WildCard If objRE.Test(fileName) = True Then ImportFile File,UnsniffDB End If Next Set objRE = Nothing UnsniffDB.Save() Sout.Writeline "Done" ' ------------------------------------------------------------- ' Import a single file into the database ' ------------------------------------------------------------- Private Sub ImportFile(FromFile,ToDB) Sout.Writeline "Importing file " & FromFile.Path ToDB.Import "libpcap", FromFile.Path End Sub