Developers

VB Script to save all packets from an OmniEngine Capture

A place for developers to exchange information about extending OmniPeek, and ask technical questions about plugins on MyPeek, scripting, and programming.
Spacepacket
Posts: 78
Joined: Thu May 22, 2008 9:36 am

VB Script to save all packets from an OmniEngine Capture

Postby Spacepacket » Tue Jun 22, 2010 4:25 pm

' Here is another cool little script for the OmniEngine
' Create a capture, start it, stop it, and save all the packets to a local file

On Error Resume Next

'---------------------------------------------------
' Create the Remote Command Manager
'---------------------------------------------------
set EPRCmdMgr = CreateObject("EPRCmdAPI.WPRemoteCmdMgr")

'---------------------------------------------------
' Connect to Remote Agent
'---------------------------------------------------
EngineIP="127.0.0.1"
EnginePort=6367
WScript.Echo "Connecting to Remote Agent at " & EngineIP & ":" & EnginePort
errVal = EPRCmdMgr.Connect(EngineIP, EnginePort, 30000 )
if Err.number <> 0 then
WScript.Echo Err.Description
WScript.Quit
end if

if errVal <> 0 Then
WScript.Echo "Connect Failed" & vbNewLine
WScript.Echo "Press Enter to finish..."
WScript.StdIn.ReadLine()
WScript.Quit
end if

'---------------------------------------------------
' Create a capture
'---------------------------------------------------

WScript.Echo "Creating new capture"

Set theAdapterList = EPRCmdMgr.GetRemoteAdapterList
theAdapterName = theAdapterList.Item(0).Description

captureGUID = EPRCmdMgr.CreateNewCapture( "AutoCapture",_
False, False, 0, False, 0, False, 0,_
False, 0, 32000, theAdapterName )

if err.number <> 0 Then
WScript.Echo "Failed to create new capture" & vbNewLine &_
"Error Code: " & err.Description
WScript.Quit
End IF

WScript.Echo "Capture Created GUID: " & captureGUID

'---------------------------------------------------
' Start Capture
'---------------------------------------------------

EPRCmdMgr.StartCapture(captureGUID)

WScript.Sleep 10000

EPRCmdMgr.StopCapture(captureGUID)


'---------------------------------------------------
' Save All Packets
'---------------------------------------------------

errval = EPRCmdMgr.SaveAllPackets( captureGUID, "allpackets.pkt" )

if err.number <> 0 Then
WScript.Echo "Failed save packets" & vbNewLine &_
"Error Code: " & err.Description
WScript.Quit
End IF

WScript.Echo "Packets saved"

WScript.Echo "Done"

WScript.Quit

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 1 guest