mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-09-26 03:19:05 +02:00
- Update win32 agent vbscript
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@28 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ed22c629ca
commit
73191dac41
@ -9,13 +9,13 @@ debug 1
|
|||||||
module_begin
|
module_begin
|
||||||
module_name NetbiosServer_KBSent
|
module_name NetbiosServer_KBSent
|
||||||
module_type generic_data
|
module_type generic_data
|
||||||
module_exec net statistics servidor | findstr "KB enviados" |c:\pandora\util\head -1 | c:\pandora\util\tr -s " " | c:\pandora\util\cut -f 3 -d " "
|
module_exec net statistics server | findstr "enviados sent" |c:\pandora\util\head -1 | c:\pandora\util\tr -s " " | c:\pandora\util\cut -f 3 -d " "
|
||||||
module_end
|
module_end
|
||||||
|
|
||||||
module_begin
|
module_begin
|
||||||
module_name VMwareStart
|
module_name Number_of_hidden_Shares
|
||||||
module_type generic_data_inc
|
module_type generic_data
|
||||||
module_eventid 105
|
module_exec net share |findstr \$ |c:\pandora\util\cut -f1 -d" " |c:\pandora\util\wc -l|c:\pandora\util\tr -s " "
|
||||||
module_end
|
module_end
|
||||||
|
|
||||||
module_begin
|
module_begin
|
||||||
@ -28,7 +28,7 @@ module_end
|
|||||||
#module_name find_string
|
#module_name find_string
|
||||||
#module_type generic_proc
|
#module_type generic_proc
|
||||||
#module_file C:\pandora\testfile.txt
|
#module_file C:\pandora\testfile.txt
|
||||||
#module_string cretino
|
#module_string test
|
||||||
#module_end
|
#module_end
|
||||||
|
|
||||||
module_begin
|
module_begin
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
' | Agente Windows para Pandora | Pandora Agent for Windows
|
' | Agente Windows para Pandora | Pandora Agent for Windows
|
||||||
' | Este codigo ha sido desarrollado por:
|
' | Este codigo ha sido desarrollado por:
|
||||||
' | This code has beed coded by:
|
' | This code has beed coded by:
|
||||||
' | 2004-2005, Sancho Lerena <slerena@iname.com>
|
' | 2004-2006, Sancho Lerena <slerena@gmail.com>
|
||||||
' | 2004-2005, Sergio Iglesias <sergio@genterara.com>
|
' | 2004-2005, Sergio Iglesias <sergio@genterara.com>
|
||||||
' | Este codigo esta distribuido y protegido bajo la licencia GPL.
|
' | Este codigo esta distribuido y protegido bajo la licencia GPL.
|
||||||
' | This code is distributed and protected under GPL licence.
|
' | This code is distributed and protected under GPL licence.
|
||||||
' ----------------------------------------------------------------
|
' ----------------------------------------------------------------
|
||||||
version = "1.2a"
|
version = "1.2a for Windows"
|
||||||
|
|
||||||
' ====================================
|
' ====================================
|
||||||
' Configuracion del agente
|
' Configuracion del agente
|
||||||
@ -20,8 +20,8 @@ dim fichero_log
|
|||||||
dim debug_mode
|
dim debug_mode
|
||||||
|
|
||||||
PANDORA_HOME = "c:\pandora\"
|
PANDORA_HOME = "c:\pandora\"
|
||||||
CONFIG_FILE= PANDORA_HOME & "pandora_agent.conf"
|
CONFIG_FILE = PANDORA_HOME & "pandora_agent.conf"
|
||||||
fichero_log = "c:\pandora\pandora_agent.log"
|
fichero_log = PANDORA_HOME & "pandora_agent.log"
|
||||||
debug_mode = 0
|
debug_mode = 0
|
||||||
|
|
||||||
' ======================================================
|
' ======================================================
|
||||||
@ -78,7 +78,7 @@ if debug_mode Then
|
|||||||
Set fs = CreateObject("Scripting.FileSystemObject")
|
Set fs = CreateObject("Scripting.FileSystemObject")
|
||||||
Set a = fs.OpenTextFile(fichero_log,8, true)
|
Set a = fs.OpenTextFile(fichero_log,8, true)
|
||||||
texto = "DEBUG Mode: Starting Pandora Agent " & version & " execution " & vbcrlf
|
texto = "DEBUG Mode: Starting Pandora Agent " & version & " execution " & vbcrlf
|
||||||
texto = texto & "DEBUG Mode: Reading startup variables...." &vbcrlf
|
texto = texto & "DEBUG Mode: Reading startup variables..." &vbcrlf
|
||||||
texto = texto & "Home Path : " & PANDORA_HOME & vbcrlf
|
texto = texto & "Home Path : " & PANDORA_HOME & vbcrlf
|
||||||
texto = texto &"Hostname : " & NOMBRE_HOST & vbcrlf
|
texto = texto &"Hostname : " & NOMBRE_HOST & vbcrlf
|
||||||
texto = texto &"Server : " & SERVER & vbcrlf
|
texto = texto &"Server : " & SERVER & vbcrlf
|
||||||
@ -87,7 +87,7 @@ if debug_mode Then
|
|||||||
texto = texto &"Interval : " & INTERVALO & vbcrlf
|
texto = texto &"Interval : " & INTERVALO & vbcrlf
|
||||||
texto = texto & "PrivateKey: " & PRIVATE_KEY & vbcrlf
|
texto = texto & "PrivateKey: " & PRIVATE_KEY & vbcrlf
|
||||||
wScript.echo texto
|
wScript.echo texto
|
||||||
a.WriteLine("DEBUG Starting Pandora Agent" & version)
|
a.WriteLine("DEBUG Starting Pandora Agent " & version)
|
||||||
a.WriteLine("Home Path : " & PANDORA_HOME)
|
a.WriteLine("Home Path : " & PANDORA_HOME)
|
||||||
a.WriteLine("Hostname : " & NOMBRE_HOST)
|
a.WriteLine("Hostname : " & NOMBRE_HOST)
|
||||||
a.WriteLine("Server : " & SERVER)
|
a.WriteLine("Server : " & SERVER)
|
||||||
@ -136,8 +136,8 @@ do ' Main loop
|
|||||||
Set WshSysEnv = WshShell.Environment("SYSTEM")
|
Set WshSysEnv = WshShell.Environment("SYSTEM")
|
||||||
strOS = WshSysEnv("OS")
|
strOS = WshSysEnv("OS")
|
||||||
strVersionNumber = WshShell.RegRead("HKLM\Software\Microsoft\" & "Windows NT\CurrentVersion\CurrentVersion")
|
strVersionNumber = WshShell.RegRead("HKLM\Software\Microsoft\" & "Windows NT\CurrentVersion\CurrentVersion")
|
||||||
strBuildNumber = WshShell.RegRead("HKLM\Software\Microsoft\" & "Windows NT\CurrentVersion\CurrentBuildNumber")
|
strServicePack = WshShell.RegRead("HKLM\Software\Microsoft\" & "Windows NT\CurrentVersion\CSDVersion")
|
||||||
strActualOS = strOS & ", " & strVersionNumber & ", " & strBuildNumber
|
strActualOS = strOS & ", " & strVersionNumber & ", " & strServicePack
|
||||||
|
|
||||||
' ========================================================================
|
' ========================================================================
|
||||||
' Begin XML construction (agent_data header)
|
' Begin XML construction (agent_data header)
|
||||||
@ -149,6 +149,7 @@ do ' Main loop
|
|||||||
' =====================================================================
|
' =====================================================================
|
||||||
' Module parser
|
' Module parser
|
||||||
' =====================================================================
|
' =====================================================================
|
||||||
|
debug_log fichero_log, "*BEGIN PARSING MODULES"
|
||||||
Set ts = fs.OpenTextFile(CONFIG_FILE)
|
Set ts = fs.OpenTextFile(CONFIG_FILE)
|
||||||
'Loop while not at the end of the file.
|
'Loop while not at the end of the file.
|
||||||
Do While Not ts.AtEndOfStream
|
Do While Not ts.AtEndOfStream
|
||||||
@ -177,14 +178,14 @@ do ' Main loop
|
|||||||
end if
|
end if
|
||||||
i = i +1
|
i = i +1
|
||||||
loop
|
loop
|
||||||
debug_log fichero_log, "Module name: " & nombre
|
debug_log fichero_log, chr(9) & "--" & vbcrlf & chr(9) & "Module name: " & nombre
|
||||||
|
|
||||||
' Parse 3th line (module TYPE)
|
' Parse 3th line (module TYPE)
|
||||||
linea_3 = ts.ReadLine
|
linea_3 = ts.ReadLine
|
||||||
contenidos_3 = Split(linea_3, " ")
|
contenidos_3 = Split(linea_3, " ")
|
||||||
tipo = contenidos_3(1)
|
tipo = contenidos_3(1)
|
||||||
'debug_mode introduzco el tipo de modulo
|
'debug_mode introduzco el tipo de modulo
|
||||||
debug_log fichero_log, "Module type : " & tipo
|
debug_log fichero_log, chr(9) & "Module type : " & tipo
|
||||||
|
|
||||||
' Parse 4th linea (could contain spaces between words!)
|
' Parse 4th linea (could contain spaces between words!)
|
||||||
' 4th line contains process/service names
|
' 4th line contains process/service names
|
||||||
@ -202,7 +203,7 @@ do ' Main loop
|
|||||||
i = i +1
|
i = i +1
|
||||||
loop
|
loop
|
||||||
contenidos_4(1)=temp4
|
contenidos_4(1)=temp4
|
||||||
debug_log fichero_log, "Content search for : " & temp4
|
debug_log fichero_log, chr(9) & "Content search for : " & temp4
|
||||||
|
|
||||||
' ================================================
|
' ================================================
|
||||||
' module_service
|
' module_service
|
||||||
@ -210,7 +211,7 @@ do ' Main loop
|
|||||||
if (lcase(contenidos_4(0)) = "module_service") Then
|
if (lcase(contenidos_4(0)) = "module_service") Then
|
||||||
es_servicio = 1
|
es_servicio = 1
|
||||||
nombre_servicio = contenidos_4(1)
|
nombre_servicio = contenidos_4(1)
|
||||||
debug_log fichero_log, "Service Module: " & nombre_servicio
|
debug_log fichero_log, chr(9) & "Service Module: " & nombre_servicio
|
||||||
existe = servicio (nombre_servicio) ' Check service function
|
existe = servicio (nombre_servicio) ' Check service function
|
||||||
s = render_output (s, nombre, "generic_proc", existe)
|
s = render_output (s, nombre, "generic_proc", existe)
|
||||||
end if
|
end if
|
||||||
@ -222,7 +223,7 @@ do ' Main loop
|
|||||||
es_proceso = 1
|
es_proceso = 1
|
||||||
nombre_proceso = contenidos_4(1)
|
nombre_proceso = contenidos_4(1)
|
||||||
existe = proceso (nombre_proceso)
|
existe = proceso (nombre_proceso)
|
||||||
debug_log fichero_log, "Process module: " & nombre_proceso
|
debug_log fichero_log, chr(9) & "Process module: " & nombre_proceso
|
||||||
s = render_output (s, nombre, "generic_proc", existe)
|
s = render_output (s, nombre, "generic_proc", existe)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
@ -232,7 +233,7 @@ do ' Main loop
|
|||||||
if (lcase(contenidos_4(0)) = "module_system") Then
|
if (lcase(contenidos_4(0)) = "module_system") Then
|
||||||
es_sistema = 1
|
es_sistema = 1
|
||||||
dato_sistema = contenidos_4(1)
|
dato_sistema = contenidos_4(1)
|
||||||
debug_log fichero_log, "Internal system module" & dato_sistema
|
debug_log fichero_log, chr(9) & "Internal system module " & dato_sistema
|
||||||
'==================================================
|
'==================================================
|
||||||
' Internal module: Freemem
|
' Internal module: Freemem
|
||||||
'==================================================
|
'==================================================
|
||||||
@ -273,10 +274,10 @@ do ' Main loop
|
|||||||
contenidos_5 = Split(linea_5, " ") ' 5th line is word to search
|
contenidos_5 = Split(linea_5, " ") ' 5th line is word to search
|
||||||
busqueda = contenidos_5(1)
|
busqueda = contenidos_5(1)
|
||||||
Set fso = CreateObject("Scripting.FileSystemObject")
|
Set fso = CreateObject("Scripting.FileSystemObject")
|
||||||
debug_log fichero_log, "File module: " & fichero & " token " & busqueda
|
debug_log fichero_log, chr(9) & "File module: " & fichero & " token " & busqueda
|
||||||
linea_encontrada = 0
|
linea_encontrada = 0
|
||||||
If Not fso.FileExists(fichero) Then ' If file doesnt exists
|
If Not fso.FileExists(fichero) Then ' If file doesnt exists
|
||||||
debug_log fichero_log, "Doesnt exist file " & fichero & " returning 0\n"
|
debug_log fichero_log, chr(9) & "Doesn't exist file " & fichero & " returning 0\n"
|
||||||
else
|
else
|
||||||
Set str_file = fs.OpenTextFile(fichero) ' File exists and
|
Set str_file = fs.OpenTextFile(fichero) ' File exists and
|
||||||
Do While Not str_file.AtEndOfStream
|
Do While Not str_file.AtEndOfStream
|
||||||
@ -295,7 +296,7 @@ do ' Main loop
|
|||||||
' ================================================
|
' ================================================
|
||||||
if (lcase(contenidos_4(0)) = "module_exec") Then
|
if (lcase(contenidos_4(0)) = "module_exec") Then
|
||||||
ejecucion = contenidos_4(1)
|
ejecucion = contenidos_4(1)
|
||||||
debug_log fichero_log, "Exec module: " & ejecucion
|
debug_log fichero_log, chr(9) & "Exec module: " & ejecucion
|
||||||
Set objFSO = CreateObject("Scripting.FileSystemObject")
|
Set objFSO = CreateObject("Scripting.FileSystemObject")
|
||||||
strFileName = objFSO.GetTempName
|
strFileName = objFSO.GetTempName
|
||||||
strFullName = objFSO.BuildPath(temporal, strFileName)
|
strFullName = objFSO.BuildPath(temporal, strFileName)
|
||||||
@ -312,13 +313,13 @@ do ' Main loop
|
|||||||
' ================================================
|
' ================================================
|
||||||
if (lcase(contenidos_4(0)) = "module_registry") Then
|
if (lcase(contenidos_4(0)) = "module_registry") Then
|
||||||
entrada_registro = contenidos_4(1)
|
entrada_registro = contenidos_4(1)
|
||||||
debug_log fichero_log, "Registry module: " & entrada_registro
|
debug_log fichero_log, chr(9) & "Registry module: " & entrada_registro
|
||||||
salida = ""
|
salida = ""
|
||||||
on error resume next
|
on error resume next
|
||||||
salida = wshShell.regread(entrada_registro)
|
salida = wshShell.regread(entrada_registro)
|
||||||
on error goto 0
|
on error goto 0
|
||||||
if salida = "" then
|
if salida = "" then
|
||||||
debug_log fichero_log, "Error reading Registry module: " & entrada_registro
|
debug_log fichero_log, chr(9) & "Error reading Registry module: " & entrada_registro
|
||||||
end if
|
end if
|
||||||
s = render_output ( s, nombre, tipo, salida)
|
s = render_output ( s, nombre, tipo, salida)
|
||||||
end if ' end registry module
|
end if ' end registry module
|
||||||
@ -328,7 +329,7 @@ do ' Main loop
|
|||||||
' ================================================
|
' ================================================
|
||||||
if (lcase(contenidos_4(0)) = "module_eventid") Then
|
if (lcase(contenidos_4(0)) = "module_eventid") Then
|
||||||
id_event_log = contenidos_4(1)
|
id_event_log = contenidos_4(1)
|
||||||
debug_log fichero_log, "EventLog module: " & id_event_log
|
debug_log fichero_log, chr(9) & "EventLog module: " & id_event_log
|
||||||
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
|
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
|
||||||
Set colLoggedEvents = objWMIService.ExecQuery ("Select * from Win32_NTLogEvent Where Logfile = 'Application' and Eventcode = '" & id_event_log & "'")
|
Set colLoggedEvents = objWMIService.ExecQuery ("Select * from Win32_NTLogEvent Where Logfile = 'Application' and Eventcode = '" & id_event_log & "'")
|
||||||
eventos = 0
|
eventos = 0
|
||||||
@ -343,6 +344,7 @@ do ' Main loop
|
|||||||
Loop
|
Loop
|
||||||
'Close the file.
|
'Close the file.
|
||||||
ts.Close
|
ts.Close
|
||||||
|
debug_log fichero_log, "*END PARSING MODULES"
|
||||||
|
|
||||||
' Creamos el filehandle y escribimos en el archivo
|
' Creamos el filehandle y escribimos en el archivo
|
||||||
' ================================================
|
' ================================================
|
||||||
@ -479,7 +481,7 @@ Function check_init (config_file)
|
|||||||
|
|
||||||
'Comprobar que ejecutamos con v5.6 de WSH
|
'Comprobar que ejecutamos con v5.6 de WSH
|
||||||
If CDbl(wScript.Version) < CDbl("5.6") then
|
If CDbl(wScript.Version) < CDbl("5.6") then
|
||||||
text = " \n ERROR: Windows Scripting Host Incorrect version \n\n Your actual version is " & wScript.Version & "\n \n Please download a latest version from http://msdn.microsoft.com/downloads/default.asp \n"
|
text = " \n ERROR: Windows Scripting Host Incorrect version \n\n Your current version is " & wScript.Version & "\n \n Please download a latest version from http://msdn.microsoft.com/downloads/default.asp \n"
|
||||||
wScript.Echo Text
|
wScript.Echo Text
|
||||||
wScript.Quit
|
wScript.Quit
|
||||||
End if
|
End if
|
||||||
|
Loading…
x
Reference in New Issue
Block a user