Authentication 使用Nsclient从VBS脚本运行exe时出现问题
我已经为intel cpu漏洞编写了一个vbs脚本,当我从命令行手动运行或双击它时,该脚本运行完全正常。 我们在所有服务器上都有一个NSClient/git infra,nagios使用它创建检查,我正试图在命令提示符下使用NSClient++.exe执行此脚本。但是,当我使用NSClient运行该文件时,它无法创建日志文件(SA-00086--) 以下是nsc.ini中的NSClient命令:Authentication 使用Nsclient从VBS脚本运行exe时出现问题,authentication,dll,vbscript,intel,Authentication,Dll,Vbscript,Intel,我已经为intel cpu漏洞编写了一个vbs脚本,当我从命令行手动运行或双击它时,该脚本运行完全正常。 我们在所有服务器上都有一个NSClient/git infra,nagios使用它创建检查,我正试图在命令提示符下使用NSClient++.exe执行此脚本。但是,当我使用NSClient运行该文件时,它无法创建日志文件(SA-00086--) 以下是nsc.ini中的NSClient命令: intel_cpu_vulnerability=C:\Windows\system32\cscrip
intel_cpu_vulnerability=C:\Windows\system32\cscript.exe //NoLogo //T:60 C:\WINDOWS\NSClient\scripts\DiscoveryTool\cpu-unsafe.vbs
以下是我的cpu-unsafe.vbs脚本:
' VB SCript to find the Intel Processor vulnerability.
Dim Maindir, objFSO, oFile, Executable, Vulnerable, NotVulnerable, objTextFile, Readme, VStatus, StatusLine, strLine
Const ForReading = 1
Maindir = "c:\Windows\nsclient\scripts\DiscoveryTool"
Executable = "Intel-SA-00086-console.exe"
Vulnerable = "Status: This system is vulnerable."
NotVulnerable = "Status: This system is not vulnerable."
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
'Deleting all previous log/xml files
For Each oFile In objFSO.GetFolder(Maindir).Files
If LCase(objFSO.GetExtensionName(oFile.Name))= "log" or LCase(objFSO.GetExtensionName(oFile.Name)) = "xml" Then
If oFile.Name <> "CommandLine.xml" Then
Deleteme = Maindir+"\"+oFile
objFSO.DeleteFile oFile
End If
End If
next
'Running the Intel detector
WSHShell.Run Maindir + "\" + Executable , 0, True
Set objShell = Nothing
WScript.Sleep 3000
'Setting the logfile to read
For Each oFile In objFSO.GetFolder(Maindir).Files
If LCase(objFSO.GetExtensionName(oFile.Name))= "log" Then
If oFile.Name <> "CommandLine.xml" Then
Readme = oFile
End If
End If
next
Set objTextFile = objFSO.OpenTextFile(Readme, ForReading)
'Reading the logfile and determining if the prosessor is affected.
VStatus = "Undetermined"
do until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine()
If Left(strLine, 7) = "Status:" Then
If InStr(strLine, NotVulnerable) <> 0 then
VStatus = "OK"
StatusLine = strLine
End If
If InStr(strLine, Vulnerable) <> 0 then
VStatus = "NOK"
StatusLine = strLine
End If
End If
If Left(strLine, 24) = "Status: Detection Error:" Then
VStatus = "Undetermined"
StatusLine = strLine
End If
loop
'The FINAL RESULTS:
If VStatus = "OK" then
Wscript.Echo VStatus + ": Not Vulnerable -> From File: " + StatusLine
Wscript.Quit(1)
ElseIf VStatus = "NOK" then
Wscript.Echo VStatus + ": Vulnerable -> From File: " + StatusLine
Wscript.Quit(3)
Else
Wscript.Echo VStatus + ": May be Vulnerable -> From File: " + StatusLine
Wscript.Quit(2)
End If
objTextFile.Close
输出:
l NSClient++.cpp(456) Enter command to inject or exit to terminate...
icvy
d NSClient++.cpp(1106) Injecting: icvy:
e \CheckExternalScripts.cpp(188) The command (C:\WINDOWS\NSClient\scripts\DiscoveryTool\Intel-SA-00086-console.exe) retu
rned an invalid return code: 11
d NSClient++.cpp(1142) Injected Result: WARNING 'Error: The file 'CommandLine.dll' authentication has failed.'
d NSClient++.cpp(1143) Injected Performance Result: ''
WARNING:Error: The file 'CommandLine.dll' authentication has failed.
尝试将当前工作目录设置为包含可执行文件的目录。我看到了相同的错误消息,直到我看到了。在VBScript中,我收集到如下信息:
WSHShell.CurrentDirectory = Maindir
WSHShell.Run Maindir + "\" + Executable , 0, True
尝试将当前工作目录设置为包含可执行文件的目录。我看到了相同的错误消息,直到我看到了。在VBScript中,我收集到如下信息:
WSHShell.CurrentDirectory = Maindir
WSHShell.Run Maindir + "\" + Executable , 0, True