Anonymous
Anonymous
Unregistered
|
Thanks a lot for the info ! I've used the following code from Will Hetrick which was very usefull (export not available however):
; Requires the Kixforms.dll to be installed and registered or the corret server and share ; where it can be found. 8 lines down is the variable to set the sserver\share
Break ON ;$=setconsole("minimize") $=SetConsole("hide")
; to set the kixforms directory in case it is not installed. $kixformsdir="\\Dc01\netlogon\" ; ***
; *********************** Register Kixforms ************************* :top If VersionCompare(GetFileVersion("%windir%\system32\kixforms.dll"), "<", "2.3.0.41") Copy "$kixformsdir\kixforms.dll" %windir%\system32 EndIf $FORM = CreateObject("Kixtart.FORM") If NOT $form Shell 'regsvr32 /s %windir%\system32\kixforms.dll' GoTo top EndIf
; *********************** FORM Start ******************************** $Form.ClientWidth = 500 $Form.ClientHeight = 550 $Form.FontName = Verdana $Form.FontSize = 10 $Form.Text = "NEW McAfee Manager"
$Form.PrintXY(1,15,"Domain:") $txtArea = $Form.ComboBox $txtArea.Bounds = 50,10,100,150 $txtArea.Style = 1 $txtArea.DropDownWidth = 450 $txtArea.onClick = "EnumOU()"
$Check = $Form.ToolButton $Check.Icon = 10 $Check.Bounds = $txtArea.Right + 10,$txtArea.top, 75, 25 $Check.Text = "Check" $Check.ToolTip = "Check List for McAfee Version" $Check.OnClick = "Check_Click()"
$update = $Form.ToolButton $update.Icon = 36 $update.Bounds = $check.Right + 10,$txtArea.top,75,25 $update.Text = "Update" $update.ToolTip = "Update Selected Clients" $update.OnClick = "update_Click()" $update.enabled = 0
$Scan = $Form.ToolButton $Scan.Icon = 43 $Scan.Bounds = $Update.Right + 10,$txtArea.top,75,25 $Scan.Text = "Scan" $Scan.ToolTip = "Scan Selected Clients" $Scan.OnClick = "Scan_Click()"
$Exit = $Form.ToolButton $Exit.Icon = 9 $Exit.Bounds = $scan.Right + 10,$txtArea.top,75,25 $Exit.Text = "Exit" $Exit.OnClick = "Quit()"
$List = $Form.ListView() $List.Bounds = 10,$check.bottom +10,480,$Form.ClientHeight - 200 $List.Sorted = 1 $List.MultiSelect = True $List.GridLines = True ;$List.View = 3 $List.View = 1 $List.FullRowSelect = True $List.OnClick = "Single_Click()" $List.OnDoubleClick = "Double_Click()"
$Form.PrintXY(10,$list.bottom + 10,"Path to Eng:") $txtsdat = $form.TextBox $txtsdat.Bounds = 100,$list.bottom + 10,315,20
$sfind = $Form.ToolButton $sfind.Icon = 5 $sfind.Bounds = $txtsdat.Right + 10,$txtsdat.Top,65,20 $sfind.Text = "Find" $sfind.OnClick = "sfind()"
$Form.PrintXY(10,$txtsdat.Bottom+10,"Path to DAT:") $txtxdat = $form.TextBox $txtxdat.Bounds = 100,$txtsdat.Bottom+10,315,20
$xfind = $Form.ToolButton $xfind.Icon = 5 $xfind.Bounds = $txtxdat.Right + 10,$txtxdat.Top,65,20 $xfind.Text = "Find" $xfind.OnClick = "xfind()"
$txtstatus = $form.listBox $txtstatus.Bounds = $list.Left,$txtxdat.Bottom+10,$list.width,$Form.ClientHeight - ($txtxdat.Bottom +10) -10 $txtstatus.Enabled = 1 ;******************************************************************************************** ;************** Start the application ... ************* ;********************************************************************************************
$NAITVD ="HKEY_LOCAL_MACHINE\Software\Network Associates\TVD" $vsengine ="$NAITVD\Shared Components\VirusScan Engine\4.0.xx" $mcupdate ="$NAITVD\Shared Components\McUpdate\CurrentVersion" $Check.enabled = 0 $Scan.enabled = 0 $txtsdat.text = ReadValue("HKEY_LOCAL_MACHINE\Software\McAfeeManager","Eng") $txtxdat.text = ReadValue("HKEY_LOCAL_MACHINE\Software\McAfeeManager","xDat") $txtArea.ListIndex = 0
$objNamespace=GetObject("WinNT:") For Each $sDom In $objNamespace $TxtArea.Additem ($sDom.Name) Next
$_ = $List.Columns.Add("PC Name") $_ = $List.Columns.Add("Engine") $_ = $List.Columns.Add("Dat Version") $_ = $List.Columns.Add("MacAfee Ver")
For Each $Column In $List.Columns $Column.Width = ($List.ClientWidth-15) / $List.Columns.Count Next
$Form.Center $Form.Show
While $Form.Visible $= Execute($Form.DoEvents) Loop Exit 1
;******************************************************************************************** ;************** Start the UDF Section ... ************* ;******************************************************************************************** Function EnumOUs($LDAP, $Filter) Dim $aFilter[0], $pos, $objOU, $i, $j If $Filter <> 'user' $Filter = 'computer' EndIf $objOU = GetObject($LDAP) If VarTypeName($objOU)='Object' $aFilter[0] = $Filter $objOU.Filter = $aFilter For Each $item In $objOU If $item.class = $Filter $i = $LDAP EndIf Next $aFilter[0] = "organizationalUnit" $objOU.Filter = $aFilter For Each $item In $objOU $Name = $item.Name $pos = InStrRev($LDAP,"/") $DN = Left($LDAP,$pos) + $Name + ", " + SubStr($LDAP, $pos+1) $j = EnumOUs($DN, $Filter) If $j If $i $i = $i +"|"+ $j Else $i = $j EndIf EndIf Next Else ; ? "GetObject COM error: " + @error + " " + @serror Exit 1 EndIf $EnumOUs = $i EndFunction ;************************************************************************************************************************* Function EnumOU() Dim $computers, $name, $cn $area=$txtArea.text $List.Items.Clear $checkComplete=0 $Computers = Netviewfulldomain($area) For Each $Item In $computers $cn=$Item.name $Item = $List.Items.Add($item.name) $item.selected = 1 Next $check.enabled = 1 $List.SetFocus $computers=0 EndFunction ;************************************************************************************************************************* Function Check_Click() Dim $computer, $p, $eng, $dat $List.SetFocus If $List.SelectedItems.Count = 0 For Each $item In $list.items $item.selected = 1 Next EndIf $counter=0 $count=$List.selectedItems.count For Each $item In $List.selectedItems $list.listindex=$item.index $counter=$counter+1 $computer=$Item.text Status("Checking $computer - $counter of $count") $p=WSHPing($Computer) If $p[1]=1 $=FN_check_Mcafee($Computer) $Mac=$Macver $eng=$Engver $dat=$regver $Item.SubItems(1).Text=$eng $Item.SubItems(2).Text=$dat $Item.SubItems(3).Text=$Mac Else $Item.SubItems(1).Text="Offline" $Item.SubItems(2).Text="" $Item.SubItems(3).Text=""
EndIf $item.selected = 0 Next $checkComplete = 1 Status("Check complete") $List.SetFocus Double_Click() EndFunction ;************************************************************************************************************************* Function Single_Click() Dim $count $count=$List.SelectedItems.Count Status("$count items selected") If $List.SelectedItems.Count > 0 AND $checkComplete=1 $scan.enabled = 1 If Exist($txtsdat.text) OR Exist($txtxdat.text) $update.enabled = 1 Else $update.enabled = 0 EndIf Else $scan.enabled = 0 EndIf EndFunction ;************************************************************************************************************************* Function Double_Click() Dim $sdat, $xdat, $edat, $sdatver, $xdatver, $edatver If $txtsdat.text OR $txtxdat.text $sdat=validate($txtsdat.text) If NOT @error $sdatver = $sdat[2] EndIf $xdat=validate($txtxdat.text) If NOT @error $xdatver = $xdat[2] EndIf For Each $item In $list.Items Select ; case $Item.SubItems(1).Text = '' ; or $Item.SubItems(2).Text = '' $item.selected = 0 ; Case $Item.SubItems(1).Text = 'Offline' ; OR $Item.SubItems(1).Text = 'Unavailable' $item.selected = 0 Case VersionCompare($Item.SubItems(1).Text, "<", $sdatver) OR VersionCompare($Item.SubItems(2).Text, "<", $xdatver) $item.selected = 1 EndSelect Next Single_Click() EndIf EndFunction ;************************************************************************************************************************* Function Update_Click() Dim $computer, $old, $pass, $file, $exe, $ver, $key, $allowdelay, $item Dim $arrfile[2] $scan.enabled = 0 $update.enabled = 0 $check.enabled = 0 $sfind.enabled = 0 $xfind.enabled = 0 $allowdelay = 0 $arrfile[0] = $txtsdat.text $arrfile[1] = $txtxdat.text For $pass=0 to 1 $sdat = Validate($arrfile[$pass]) If NOT @error $file = $sdat[0] $exe = $sdat[1] $ver = $sdat[2] $key = Split("szEngineVer szDatVersion")[$pass] If Exist("$file\$exe") For Each $Item In $List.SelectedItems $computer=$Item.text If NOT VersionCompare($Item.SubItems($pass+1).Text, ">=", $ver) AND NOT $Item.SubItems($pass+1).Text='Offline' AND NOT $Item.SubItems($pass+1).Text='Unavailable' AND NOT $Item.SubItems($pass+1).Text='' $allowdelay=1 $Item.SubItems($pass+1).Text="Updating" Status("Updating $exe on $Computer") $=EnumProcess("scan32.exe", 1, $Computer) Status("Updating $exe on $Computer - Copying $exe") $Item.SubItems($pass+1).Text="Copying" ; Copy '%windir%\kix32.exe' '\\$computer\c$$\winnt' Copy '$file\$exe' '\\$computer\c$$' $command='C:\$exe /silent /f' $=RMTEXEC($computer, $command) Status("Updating $exe on $Computer - Executing $exe Updater") $Item.SubItems($pass+1).Text="Executing" EndIf Next If $allowdelay=1 For $delay = 30 to 0 step -1 $txtstatus.removeitem($txtstatus.listcount-1) Status("Pausing for execution - $delay seconds") Sleep 1 Next $allowdelay=0 EndIf For Each $Item In $List.SelectedItems $computer=$Item.text $old=$Item.SubItems($pass+1).Text If $old="Executing" Status("Updating $exe on $Computer - removing temp files") Del "\\$computer\c$$\$$exe" Status("Updating $Computer - Verifying the update") $=FN_check_Mcafee($computer) $Mac=$Macver $eng=$Engver $dat=$regver $Item.SubItems(1).Text=$eng $Item.SubItems(2).Text=$dat $Item.SubItems(3).Text=$Mac $Item.SubItems($pass+1).Text=$dat If $Item.SubItems($pass+1).Text=$old Status("Updating $exe on $Computer - Failed") Else Status("Updating $exe on $Computer - Succeeded") EndIf EndIf Next EndIf EndIf Next Status("Update Complete") $scan.enabled = 1 $update.enabled = 1 $check.enabled = 1 $sfind.enabled = 1 $xfind.enabled = 1 Double_Click() $List.SetFocus EndFunction ;************************************************************************************************************************* Function Scan_Click() $List.SetFocus $scan.enabled = 0 $update.enabled = 0 $check.enabled = 0 $sfind.enabled = 0 $xfind.enabled = 0 For Each $item In $List.SelectedItems If NOT $Item.SubItems(1).Text = '' AND NOT $Item.SubItems(1).Text = 'Offline' AND NOT $Item.SubItems(1).Text = 'Unavailable' $computer=$Item.text $=EnumProcess("scan32.exe", 1, $Computer) $command='"C:\Program Files\Common Files\Network Associates\On Demand Scanner\Scan32\scan32.exe" c: /nosplash /autoscan /uinone /continue /noprompt /clean' $rex=RMTEXEC($computer, $command) Status("Executing Scan on $Computer - PID $rex") EndIf Next Status("Force Scan Job Complete") $scan.enabled = 1 $update.enabled = 1 $check.enabled = 1 $sfind.enabled = 1 $xfind.enabled = 1 EndFunction ;************************************************************************************************************************* Function sfind() $FileName = $Form.FileOpenDialog("Find engine.exe Update", ".\", "", "SuperDat|*sdat.exe", 0) $=Validate($FileName) $List.SetFocus EndFunction ;************************************************************************************************************************* Function xfind() $FileName = $Form.FileOpenDialog("Find xDat.exe Update", ".\", "", "SuperDat|*.exe", 0) $=Validate($FileName) $List.SetFocus EndFunction ;************************************************************************************************************************* Function Efind() $FileName = $Form.FileOpenDialog("Find SDat.exe Update", ".\", "", "SuperDat|*sDat.exe", 0) $=Validate($FileName) $List.SetFocus EndFunction ;************************************************************************************************************************* Function Validate($FilePath) $FilePos= InStrRev($FilePath,"\") $File = Right($FilePath,Len($FilePath)-$FilePos) $Path = Left($FilePath,$FilePos) Select Case Right($File,8)="xdat.exe" $txtxdat.text = $FilePath $Ver ="4.0."+Left($File,4) $= WriteValue("HKEY_LOCAL_MACHINE\Software\McAfeeManager","xDat","$FilePath",REG_SZ) Status("Found xDat - $ver") $validate=$Path,$File,$Ver Case Right($File,7)="eng.exe" $txtsdat.text = $FilePath $Ver =SubStr($File,1,1)+"."+SubStr($File,2,1)+"."+SubStr($File,3,2) $= WriteValue("HKEY_LOCAL_MACHINE\Software\McAfeeManager","Eng","$FilePath",REG_SZ) Status("Found Engine - $ver") $validate=$Path,$File,$Ver Case Left($File,4)="sdat" $txtxdat.text = $FilePath $Ver1 = + Left($File,8) $Ver ="4.0."+Right($Ver1,4) $= WriteValue("HKEY_LOCAL_MACHINE\Software\McAfeeManager","xDat","$FilePath",REG_SZ) Status("Found SDat - $ver") $validate=$Path,$File,$Ver
Case 1 Exit 1 EndSelect EndFunction ;************************************************************************************************************************* Function Status($text) $txtstatus.additem($text) $txtstatus.listindex=$txtstatus.listcount-1 EndFunction ;************************************************************************************************************************* Function RMTEXEC($computer, $command) Dim $Connect $Connect = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer/root/cimv2:Win32_Process") $RMTEXEC = $Connect.Create($Command) Exit @error $Connect = 0 EndFunction ;**************************************************************************** Function EnumProcess($exe, optional $terminate, optional $Computer) Dim $winmgmts, $ExecQuery, $Process, $id If NOT $computer $computer=@wksta EndIf $winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER" Select Case Val($exe)>0 $ExecQuery="select * from Win32_Process where ProcessId='$exe'" $GetObject=GetObject($winmgmts).ExecQuery($ExecQuery) For Each $Process In $GetObject If $terminate $=$Process.Terminate EndIf $EnumProcess = $Process.name Next $GetObject=0 Case VarType($exe)=8 $ExecQuery="select * from Win32_Process where Name='$exe'" $GetObject=GetObject($winmgmts).ExecQuery($ExecQuery) For Each $Process In $GetObject If $terminate $=$Process.Terminate EndIf $id=$Process.ProcessId $EnumProcess = "$Id" + "|" + "$EnumProcess" Next $EnumProcess=Left($EnumProcess,Len($EnumProcess)-1) $GetObject=0 Case 1 Exit 1 EndSelect EndFunction ;******************************************************************************************************** Function WSHPing($Computer,optional $replies) Dim $ip, $l, $r, $count, $Return, $line ,$pos, $avg If NOT $replies $replies=1 EndIf $ip=$computer $Count=0 $Shell='%comspec% /c %windir%\system32\ping $Computer -n $replies ' $Return=WSHPipe($Shell,1) If NOT @error For Each $line In $Return Select Case InStr($line,"[") $l=InStr($line,"[")+1 $r=InStr($line,"]") $ip=SubStr($line,$l,$r-$l) Case InStr($line,"reply from") $Count=$Count+1 Case InStr($line,"Average") $pos=InStr($line,"Average")+8 $avg=Val(Right("$line",Len($line)-$pos)) EndSelect If InStr($line,"timed out") $Count=$Count-1 EndIf Next $WSHPing=$ip,$count,$avg Else $WSHPing="0.0.0.0","0","0" Exit(487) EndIf EndFunction ;**************************************************************************** Function WshPipe($ShellCMD, OPTIONAL $NoEcho) Dim $WshShell, $oExec, $AllOutput, $Exit, $WshExitCode $WshErrorMsg="" $WshShell=CreateObject("WScript.Shell") $oExec=$WshShell.Exec($ShellCMD) While $Exit<>1 Dim $Output Select Case NOT $oExec.StdOut.AtEndOfStream $Output=$oExec.StdOut.ReadAll Case NOT $oExec.StdErr.AtEndOfStream $Output=$oExec.StdErr.ReadAll $WshErrorMsg = $Output Case 1 $Output=-1 EndSelect If $Output=-1 If $oExec.Status=1 $Exit=1 EndIf Else If $NoEcho<>1 ? $Output EndIf $AllOutput = $AllOutput + $Output EndIf Loop $WshExitCode=$oExec.ExitCode $WshPipe=Split($AllOutput,Chr(10)) Exit($WshExitCode) EndFunction ;**************************************************************************** Function VersionCompare($Ver1, $Comparison, $Ver2, OPTIONAL $Limit) Dim $Ver1Sep, $Ver2Sep, $Ver1A, $Ver2A, $SegIndex $Limit=0+$Limit If $Limit=0 OR $Limit>4 $Limit=4 EndIf $Ver1=''+$Ver1 $Ver2=''+$Ver2 If $Ver1='' OR $Ver2='' OR $Comparison='' $VersionCompare='' Return EndIf If InStr($Ver1,',') $Ver1Sep=',' Else $Ver1Sep='.' EndIf If InStr($Ver2,',') $Ver2Sep=',' Else $Ver2Sep='.' EndIf $Ver1=$Ver1+$Ver1Sep+$Ver1Sep+$Ver1Sep+$Ver2Sep $Ver2=$Ver2+$Ver2Sep+$Ver2Sep+$Ver2Sep+$Ver2Sep $Ver1A=Split($Ver1,$Ver1Sep) ReDim preserve $Ver1A[$Limit-1] $Ver2A=Split($Ver2,$Ver2Sep) ReDim preserve $Ver2A[$Limit-1] $Ver1A[0]=Right(''+'0000'+$Ver1A[0],4) $Ver2A[0]=Right(''+'0000'+$Ver2A[0],4) For $SegIndex = 1 to $Limit-1 $Ver1A[$SegIndex]=Left(''+Trim($Ver1A[$SegIndex])+'0000',4) $Ver2A[$SegIndex]=Left(''+Trim($Ver2A[$SegIndex])+'0000',4) Next $Ver1=Join($Ver1A,'.') $Ver2=Join($Ver2A,'.') Select Case InStr($Comparison,'=') AND $Ver1=$Ver2 $VersionCompare=1 Case InStr($Comparison,'<') AND $Ver1<$Ver2 $VersionCompare=1 Case InStr($Comparison,'>') AND $Ver1>$Ver2 $VersionCompare=1 Case 1 $VersionCompare=0 EndSelect EndFunction
;**************************************************************************** Function netview(optional $domain) Dim $array[255] Dim $ReDim $ReDim = 255 Dim $i $i = 0 Dim $j $j = 0 Dim $tempfile $tempfile = "%temp%\netview.tmp" If $domain $domain = "/domain:$domain" EndIf If Exist("$tempfile") Del "$tempfile" EndIf Shell '%comspec% /c net view $domain >"$tempfile"' If @error = 0 If Open(10,$tempfile) = 0 For $j = 1 to 5 $line = ReadLine(10) ; skip headings Next While @error = 0 $array[$i] = RTrim(SubStr($line,3,InStr($line," ")-1)) $i=$i+1 If $i = $ReDim $ReDim=$ReDim*2 ReDim preserve $array[$ReDim] EndIf $line = ReadLine(10) Loop $=Close(10) ;Del "$tempfile" If $i ReDim preserve $array[$i-4] $netview = $array Exit @error EndIf EndIf EndIf $netview = 0 Exit @error EndFunction ;*********************************************************************** Function FN_Check_Mcafee($Computer)
$HKEYTVD = "\\$computer\HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\" Select ; #### Check if installed Viruscan Enterprise Version 7.0.0.xxx Case ExistKey($HKEYTVD + "VirusScan Enterprise\CurrentVersion") = 0 $macver = ReadValue($HKEYTVD + "VirusScan Enterprise\CurrentVersion","szProductver") $regver = ReadValue($HKEYTVD + "VirusScan Enterprise\CurrentVersion","szVirDefVer") $engver = ReadValue($HKEYTVD + "VirusScan Enterprise\CurrentVersion","szEngineVer") ; #### Check if installed Viruscan Multiplatform version 4.5.x.xxxx Case ExistKey($HKEYTVD + "VirusScan") = 0 $macver = ReadValue($HKEYTVD + "VirusScan","szCurrentVersionNumber") $regver = ReadValue($HKEYTVD + "Shared Components\VirusScan Engine\4.0.xx","szDatVersion") $engver = ReadValue($HKEYTVD + "Shared Components\VirusScan Engine\4.0.xx","szEngineVer") ; #### Check if NetShield 4.5.x.xxxx installed Case ExistKey($HKEYTVD + "NetShield NT") = 0 $macver = ReadValue($HKEYTVD + "NetShield NT\CurrentVersion","szProductver") $regver = ReadValue($HKEYTVD + "NetShield NT\CurrentVersion","szVirDefVer") $engver = ReadValue($HKEYTVD + "NetShield NT\CurrentVersion","szEngineVer") ; #### DEFAULT WHEN AN OUTDATED VERSION OR NO MCAFEE CAN BE FOUND Case 1 $Macver = "Unavailable" $REGVER = "Unavailable" $ENGVER = "Unavailable" EndSelect ; corrects the Dat Version on different install versions to match the same format. If $regver > 4000 AND $Regver <> "Unavailable" $regver = "4.0." + $regver Else If $regver < 1 $regver = "4." + SubStr($Regver,1,6) EndIf EndIf
EndFunction
;----------------------------------------------------------------------------------------------------------------
Function NetViewFulldomain($Domain)
$Comp=GetObject("WinNT://$Domain") $Comp.filter="Computer","" $NetViewFulldomain = $Comp
EndFunction
|