home *** CD-ROM | disk | FTP | other *** search
- Function CreateDir(Directory)
- Dim fl As Object
- Set fl = file.connect("127.0.0.1")
- If Not fl is Nothing Then
- If fl.open(Directory, Generic_read,open_existing) Then
- Else
- fl.createfolder(Directory)
- End If
- End If
- fl.close
- End Function
-
- Function WriteToLocalFile(filenm,message)
- Dim fl As Object
- Dim filename As String
- filename = filenm
- Set fl = file.connect("127.0.0.1")
-
- If fl is Nothing Then
-
- Else
-
- If fl.open(filename, GENERIC_write, Open_always) = true Then
-
- If fl.size < 2 Then
-
- fl.write(Chr(34) &"Date" & Chr(34) & "," & Chr(34) &"Computer IP" & Chr(34) & "," & Chr(34) & "Computer Name" & Chr(34))
- fl.write("," & Chr(34) & "Configuration Installed" & Chr(34)& "," & Chr(34) & "Configuration Build No" & Chr(34) & "," & Chr(34) & "Agent Installed")
- fl.write(Chr(34) & "," & Chr(34) & "Agent Build No" & Chr(34) & "," & Chr(34) & "Agent Running" & Chr(34)& "," & Chr(34) & "Status")
- fl.write(Chr(34) & "," & Chr(34) & "Configuration Path")
- fl.writeline(Chr(34) & "," & Chr(34) & "Agent Path"& Chr(34))
- End If
-
- fl.seek 0,2
-
- fl.writeline(message)
- End If
-
- fl.close
- End If
-
- End Function
-
- Function buildreport(ComputerIP,ComputerName,ServiceStatus, Agent, Full, AgentBuild,MainBuild,ServiceRuns,AgentPath,MainPath)
- Dim report As String
- Dim Status As String
- If servicestatus = 0 Then
- Status = "Agent Not installed, Computer is unprotected"
- End If
- If servicestatus = 1 Then
- Status = "Agent installed and running"
- End If
- If servicestatus = 2 Then
- Status = "Agent installed but is currently Stopped, Agent might have been tempered with"
- End If
- If servicestatus = 3 Then
- Status = "Agent installed but is DISABLED, Agent has most likely been tempered"
- End If
- If servicestatus = 4 Then
- Status = "Agent installed but is set to Manual start, Agent has most likely been tempered"
- End If
- report = Chr(34) & Now & Chr(34) & "," & Chr(34) & ComputerIP & Chr(34) & "," & Chr(34) & ComputerName & Chr(34)
- report = report & "," & Chr(34) & full & Chr(34) & "," & Chr(34) & MainBuild & Chr(34) & ","
- report = report & Chr(34) & Agent & Chr(34) & "," & Chr(34) & AgentBuild & Chr(34) & "," & Chr(34) & ServiceRuns & Chr(34) & ","
- report = report & Chr(34) & Status & Chr(34) & "," & Chr(34) & MainPath & Chr(34) & "," & Chr(34) & AgentPath & Chr(34)
- buildreport = report
- End Function
-
-
- Function main
- Dim strip, strcompip, strcompname, struser, strpasswd As String
- Dim wmiinst As Object
- Dim reg As Object
- Dim locreg As Object
- Dim objs As Object
- Dim foundpsc As Boolean
- Dim agent As Boolean
- Dim Full As Boolean
- Dim AgentPath As String
- Dim AgentBuild As Long
- Dim FullBuild As Long
- Dim FullPath As String
- Dim HomePath As String
- Dim SaveFile As String
- Dim Build
- Dim filecheck As Object
- Dim servicestatus As Integer '0 - not installed 1 - running 2 - stopped - 3 disabled - 4 manual
- Dim serviceruns As Boolean
- Dim objSWbemLocator As Object
- Dim objSWbemServices As Object
- foundpsc = false
-
- strcompip = GetParameter("ComputerIP")
- strcompname=GetParameter("Computername")
- struser = GetParameter("User")
- strpasswd = GetParameter("Password")
- Set locreg = Registry.Connect("127.0.0.1")
- If Not locreg is Nothing Then
- HomeDir = locreg.read("SOFTWARE\GFI\LNSS7","Path")
- SaveFile = HomeDir & "Data\Reports\LPMC-Network-Report.csv"
- End If
- If struser = "" Then
- ' echo("This script must run under alternative credentials")
- WriteToLocalFile HomeDir & "Data\Reports\Error.txt","Currently Logged-On user detected. This script must run under alternative credentials "
- ' Exit Sub
- End If
- 'Socket.SetTimeout 1000,1000
- strip = Socket.DnsLookup(Socket.ReverseDnsLookup("127.0.0.1"))
- If strip = strcompip Then
- struser = "" 'localhost
- strpasswd = ""
- End If
-
- cr = Chr(13) + Chr(10) 'carriage return
- Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
- Set objSWbemServices = objSWbemLocator.ConnectServer(strcompip, "root/cimv2", struser, strpasswd)
- Set wmiinst = objSWbemServices.execquery("Select * from Win32_service")
- If wmiinst is Nothing Then
- WriteToLocalFile "Data\Reports\Error.txt","Error Retrieving services information instances from WMI on the target machine " & strcompip
- ' check to see if that instance is available
- Else
- For Each objs In wmiinst ' loop through each instance
- If objs.DisplayName = "GFI LANguard P.S.C. 2.0 agent service" Then
- servicestatus = 1
- foundpsc = true
- Agent = True
- If objs.State = "Running" Then
- servicestatus = 1
- serviceruns = true
- Else
- serviceruns = false
- End If
- If objs.State = "Stopped" Then servicestatus = 2
- If objs.StartMode = "Disabled" Then servicestatus = 3
- If objs.StartMode = "Manual" Then servicestatus = 4
- End If
- Next
-
- Set reg = Registry.Connect(strcompip)
- If Not reg is Nothing Then 'Detecting Full installation information
- FullPath = reg.read("SOFTWARE\GFI\LPSC2","Path")
- FullBuild = reg.read("SOFTWARE\GFI\LPSC2","Build")
- ' CreateDir(HomeDir & "Reports")
- If Fullpath <> "" Then
- Set filecheck = file.connect(strcompip)
- If Not filecheck is Nothing Then
- If filecheck.open(Fullpath & "lpsc.exe", GENERIC_READ,OPEN_EXISTING) Then
- full = true
- Else
- full = false
- End If
- End If
- End If
- Else
- WriteToLocalFile "Error.txt","Unable to connect to registry on remote computer:" & strcompip
- End If
-
- If Agent = true Then ' Agent Information detection
- AgentPath = reg.read("SOFTWARE\GFI\LPSC2\AgentSettings","Path")
- AgentBuild = reg.read("SOFTWARE\GFI\LPSC2\AgentSettings","Build")
- End If
- If foundpsc = false Then
- servicestatus=0
- WriteToLocalFile SaveFile,buildreport(strcompip,strcompname,ServiceStatus, Agent, full, AgentBuild,FullBuild,ServiceRuns,AgentPath,FullPath)
-
- Else
- WriteToLocalFile SaveFile,buildreport(strcompip,strcompname,ServiceStatus, Agent, full, AgentBuild,FullBuild,ServiceRuns,AgentPath,FullPath)
-
- End If
-
-
- End If
- End Function
-