#13752 - 2001-10-30 10:24 PM
file extension
|
tr6boy
Starting to like KiXtart
Registered: 2001-10-24
Posts: 131
|
Hi all, I'm putting together a script that will tell me whether a PC loggin in has Trend AV installed. If it soes, I would also like to find out what virus pattern. The pattern file always looks like: lpt$vpn.157The extension, like 157 above determines the pattern level. If a PC was on pattern 160, the file would be called lpt$vpn.160 So, I know I can search for the file using IF EXIST($PATH + "\lpt$vpn.*) etc but how do I return just the extension that it finds? Also, how would I deal with situations when it finds more than one? Thanks!! 1. How can I search for the file by
|
|
Top
|
|
|
|
#13753 - 2001-10-30 11:04 PM
Re: file extension
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
Here's some code I use for checking NAV patterns. I know it's not the same AV software, but you should be able to garner enough from my methodology to get you started.Basically, you'd read in the filenames with Dir() and then keep only the last three characters usinf Substr().
code:
Break on $Index = 0 Dim $FNArray[9] $FNewest = 0 $NewLine ="Current NAV Virus Definition File Date: " $FileName = Dir("C:\Program Files\Common Files\Symantec Shared\VirusDefs") While $FileName <> "" and @ERROR = 0 If Val($FileName) <> 0 $FNArray[$Index] = Val($FileName) $Index = $Index + 1 EndIf $FileName = Dir() LoopFor $X = 0 To $Index Step 1 If $FNArray[$X] > $FNewest $FNewest = $FNArray[$X] EndIf Next $VPDate = Substr($FNewest,5,2) + "/" + Substr($FNewest,7,2) + "/" + Substr($FNewest,1,4) If exist ("D:\Inetpub\wwwroot\VirusPattern2.txt") Del "D:\Inetpub\wwwroot\VirusPattern2.txt" EndIf If Open(1,"D:\Inetpub\wwwroot\VirusPattern2.txt",5) = 0 $ = WriteLine(1,$NewLine + $VPDate) EndIf $ = Close(1) Copy "D:\Inetpub\wwwroot\VirusPattern2.txt" "D:\Inetpub\wwwroot\VirusPattern.txt" exit 1
In My case, I post the pattern date on my intranet.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#13756 - 2001-10-31 04:24 AM
Re: file extension
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
NTDOC, OK, here's the same functionality rewritten for 3.62. I assume it would work for 3.63 as well.
code:
Break on $Index = 0 $X = 0 Dim $FNArray[9] $FNewest = 0 $NewLine ="Current NAV Virus Definition File Date: " $FileName = Dir("C:\Program Files\Common Files\Symantec Shared\VirusDefs\*.*")While $FileName <> "" and @ERROR = 0 If Val($FileName) <> 0 $FNArray[$Index] = Val($FileName) $Index = $Index + 1 EndIf $FileName = Dir() Loop While $X < $Index If $FNArray[$X] > $FNewest $FNewest = $FNArray[$X] EndIf $X = $X + 1 Loop $VPDate = Substr("$FNewest",5,2) + "/" + Substr("$FNewest",7,2) + "/" + Substr("$FNewest",1,4) If exist ("C:\Inetpub\wwwroot\VirusPattern2.txt") Del "C:\Inetpub\wwwroot\VirusPattern2.txt" EndIf If Open(1,"C:\Inetpub\wwwroot\VirusPattern2.txt",5) = 0 $ = WriteLine(1,$NewLine + $VPDate) EndIf $ = Close(1) Copy "C:\Inetpub\wwwroot\VirusPattern2.txt" "C:\Inetpub\wwwroot\VirusPattern.txt" Get $
I wrote this little snippet of code to run under Task Scheduler on my intranet server. While my network is on 3.62, I put RC3 on my web server.It was only tested on the one server as it was never intended to be used elsewhere. What this does is to search for the folders that hold the pattern files. They are named as 20011017.005, 20011026.021, etc. which is YYYYMMDD and the .005 is the fifth letter of the alphabet (e) etc. I ignore the extension. SInce NAV keeps older pattern folders, I needed to determine the newest. then I concatenate a string of text with the date formatted the same way as it appears in NAV. Current NAV Virus Definition File Date: 10/26/2001 This becomes a one-line file that, through server-side includes becomes part of our home page. It is meant to raise awareness for our home users (unmanaged) to make sure they have the most recent pattern.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#13760 - 2001-10-31 09:56 PM
Re: file extension
|
tr6boy
Starting to like KiXtart
Registered: 2001-10-24
Posts: 131
|
In working with the code above from Les, I'm getting an error "Array Reference Out of Bounds" on the lineIf $FNArray[$x] > $FNewest Can you explain what this means (what I should be looking for)? Thanks, tr6boy
|
|
Top
|
|
|
|
#13766 - 2001-11-02 12:48 AM
Re: file extension
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Assuming the server is using the newest version of defininitions, you can read the ini-file: Definfo.dat for the newest def-dates, and use this short form of the scriptcode:
Break On $CommonFiles = ReadValue("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion", "CommonFilesDir") $VirDefFile = $CommonFiles + "\Symantec Shared\VirusDefs\Definfo.dat" $CurrDefs = ReadProfileString($VirDefFile, "DefDates", "CurDefs") $VPDate = Substr("$CurrDefs",5,2) + "/" + Substr("$CurrDefs",7,2) + "/" + Substr("$CurrDefs",1,4) ? "Newest NAV Definition files are dated: " + $VPDate
This code will work on KiX 3.6? and KiX 2000 -Erik Doc, congrats, here is your chance for post #601 or more. I modified your code to include the name of the "Common files" library, because the "Common files" library is called "Fælles filer" in danish, and i assume something different in other languages.
You have to read "HKEY_CURENT_USER" instead of "HKEY_LOCAL_MACHINE". There is a lot ot other interresting values here, like: AppData Desktop Programs Start Menu Startup Quick Launch ProgramFilesDir Common Desktop Common Programs Common Start Menu And Common Startup [ 02 November 2001: Message edited by: kholm ]
|
|
Top
|
|
|
|
#13768 - 2001-11-02 03:45 AM
Re: file extension
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
Erik, Thanks for that tidbit. It's sure a lot easier than the way I was doing it.Well... I thought I'd look a bit closer at the registry to see if the path "C:\Program Files\Common Files\Symantec Shared\VirusDefs" was in fact stored in there. Sure enough it is, except that it's stored in 8.3 instead. The location is HKLM\Software\Symantec\InstalledApps "AVENGEDEFS" REG_SZ, "C:\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1" In fact, the pattern folder is stored in the registry as well.. The location is HKLM\Software\Symantec\SharedDefs in two values, DEFWATCH_10 and NAVCORP_70 as "C:\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20011026.021" Before you tell me my pattern is out of date, I know the newest is the 31st. I'm on my home machine (unmanaged). You know, I did a quick search of the reg for the path before I wrote that code, but didn't think to search for the 8.3 variant.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
#13770 - 2001-11-02 06:03 AM
Re: file extension
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
Les and Erik,Well to keep this thread off of the original topic I was right... I found the old code I was working on back in August. Don't remember why I quit working on it - probably got side tracked onto something else. Anyway, here is a sample. Let me know if you find anything wrong with it or if you think of a better way to do it. code:
$DefUpdate = '%compspec% /c "\\myserver\myshare\1101x86.exe /q"' $RC = "" $RC = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\SharedDefs","NAVCORP_70") $RC = SUBSTR($RC,INSTR($RC,".")-8,8) IF ((((@year-2000)*365)+@ydayno)-(((val(SUBSTR($RC,1,4))-2000)*365)+((val(SUBSTR($RC,5,2))-1)*30)+val(SUBSTR($RC,7,2))))>90 RUN $DefUpdate $nul = MESSAGEBOX("Warning...Norton AntiVirus definition files are over 90 days old on this system. Please wait while we attempt to update these files for you.", "Norton AntiVirus Definitions Check", 16) ENDIF
[ 02 November 2001: Message edited by: NTDOC ]
|
|
Top
|
|
|
|
#13771 - 2001-11-02 09:28 PM
Re: file extension
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Doc and Les,Keeping this tread of topic  After reading both your posts i think i have got the bullitproof solution to check for the the updatelevel. I have to decline on the multilanguage support, we only use english versions of NortonAV but in different programversions, versions: 5.?? to 7.?? Two thing that seems consistant, are the use of the file DefInfo.dat and the location of it found in reg-value: "HKEY_LOCAL_MACHINE\Software\Symantec\InstalledApps", "AVENGEDEFS" code:
Break On $VirDefPath = ReadValue("HKEY_LOCAL_MACHINE\Software\Symantec\InstalledApps", "AVENGEDEFS") $VirDefFile = $VirDefPath + "\Definfo.dat" $CurrDefs = ReadProfileString($VirDefFile, "DefDates", "CurDefs") $VPDate = Substr("$CurrDefs",5,2) + "/" + Substr("$CurrDefs",7,2) + "/" + Substr("$CurrDefs",1,4) ? "Newest NAV Definition files are dated: " + $VPDate
I believe the 'expanded' valuename for AVENGEDEFS would be AntiVirusEnglishDefinitons, so therefore only support for english versions with this code! The place to look for the path for windows general folders like startup, startmenu, desktop and so on are different for Win9x and WinNT. Win9x: Look in HKCU WinNT: Look in HKLM Just a comment to the differences in Microsoft OS's: Over time we will all be in a Win9x-like environment with improved NT-security. By this i mean that Win2k/XP behaves a lot like Win9x for the user, but like WinNT for the administrators with the added ADS-concept. I know that in the real world 'over time' will be years and years !!! We can only hope that microsoft will try to keep a consistant line for future versions, They don't keep it in the naming concept, i thought the year-naming was a good idea, easy to follow. What is the version following XP going to be called? Maybe VXP (Very Expanded - ) or EXP (Extreemly Expanded - ) or oldfashioned XP v.2 -Erik
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 883 anonymous users online.
|
|
|