Page 1 of 2 12>
Topic Options
#13752 - 2001-10-30 10:24 PM file extension
tr6boy Offline
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.157

The 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 Offline
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()
Loop

For $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
#13754 - 2001-10-31 12:21 AM Re: file extension
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Hi Les,

Can you modify your code to work with KiXtart v3.63? I tried with 3.63 and I get an error at the STEP 1 line.

When I use KiXtart 2001 RC3 it works fine. I also had to change code to F: (in production I would probably get the install info from the Registry) my Windows 2000 install is on my F: drive.

Your method may be a better way of getting this info then the one I was using. Trying to do math on the HEX entry in the Registry.

Top
#13755 - 2001-10-31 03:21 AM Re: file extension
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
PING LES
unknown host les? (no, we know of him)
NSLOOKUP LES
Name:LLigetfa.coding.KiXtart.kind.of.guy
Address:127.0.0.0

Les, did you take the day off again? Please let me know what you think about altering this code for v3.63 when you get back in.

Top
#13756 - 2001-10-31 04:24 AM Re: file extension
Les Offline
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
#13757 - 2001-10-31 05:13 AM Re: file extension
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
tr6boy,
OK, I tossed together the code you'd need:
code:

Break on
$Index = 0
$X = 0
Dim $FNArray[9]
$FNewest = 0
$FileName = Dir("C:\temp\lpt$vpn.*")
While $FileName <> "" and @ERROR = 0
If Val(Substr($FileName,Instr($FileName,".")+1,3)) <> 0
$FNArray[$Index] = Val(Substr($FileName,Instr($FileName,".")+1,3))
$Index = $Index + 1
EndIf
$FileName = Dir()
Loop

While $X < $Index
If $FNArray[$X] > $FNewest
$FNewest = $FNArray[$X]
EndIf
$X = $X + 1
Loop

? $FNewest
Get $


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#13758 - 2001-10-31 05:51 AM Re: file extension
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Thanks Les,

That works good on v3.63 for me.

Here is the modified code so that it works when the OS has been installed on a different drive.

code:
Break on
$ProgFiles = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
$VirDefFiles = "\Common Files\Symantec Shared\VirusDefs\*.*"
$CombinedPath = $ProgFiles+$VirDefFiles
$Index = 0
$X = 0
Dim $FNArray[9]
$FNewest = 0
$NewLine ="Current NAV Virus Definition File Date: "
$FileName = Dir($CombinedPath)
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)

? "Your NAV Definition files are dated: " $VPDate


Thanks again Les

Top
#13759 - 2001-10-31 03:48 PM Re: file extension
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
you all have been busy - several posts since I left last night! Thanks for all the help!
tr6boy

Top
#13760 - 2001-10-31 09:56 PM Re: file extension
tr6boy Offline
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 line

If $FNArray[$x] > $FNewest

Can you explain what this means (what I should be looking for)?

Thanks,
tr6boy

Top
#13761 - 2001-10-31 10:54 PM Re: file extension
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
tr6boy,
On the line "Dim $FNArray[9]", I dimension it for ten possible hits (or is it 9 with RC3) with the Dir() command. Is it possible there would be more than 10 matches?

You can always up the number.

[ 31 October 2001: Message edited by: LLigetfa ]

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#13762 - 2001-10-31 11:07 PM Re: file extension
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Hi tr6boy,

You could use:

Dim $FNArray[600]

to matach the number of posts I have now reached...


It should be able to check for 599 or is it 600 folders before getting an error.

Top
#13763 - 2001-10-31 11:10 PM Re: file extension
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Doc, congrats on number 600 - hope to see you hit 1000 !!!
Top
#13764 - 2001-10-31 11:12 PM Re: file extension
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Uggghhhh! Dumb typo error. I found it...thanks again!
Top
#13765 - 2001-10-31 11:39 PM Re: file extension
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
NTDOC,
Yeah! I too would like to see you in the millenium club! At this rate you'll pass me soon enough. You already got me beat on votes!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#13766 - 2001-11-02 12:48 AM Re: file extension
kholm Offline
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 script

code:
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
#13767 - 2001-11-02 01:40 AM Re: file extension
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Hi Erik,

Thanks for the info. I could sware I used that in the past and somewhere along the line the file/path changed between vesions. I have all kinds of versions so I needed a more foolproof way. But now that I look at an old version and a new version they both seem to be using that file. back to my old Nightmare I guess.

However, your also right in that I should have gotten the folder closer using a Registry read, but on my English version of Windows 2000 I don't have any of those values in HKCU, but they do exist in HKLM
Please let me know if HKLM does not have these same values in your Danish version. I would use HKLM if they exist since HKCU does not have them for me. What about the NAV folders? Are they in English once you get that far?

Top
#13768 - 2001-11-02 03:45 AM Re: file extension
Les Offline
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
#13769 - 2001-11-02 03:49 AM Re: file extension
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
tr6boy,
How's it going? Do you have everything you need to make a go of it? Hope you don't mind our little side trips on your thread.
_________________________
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 Offline
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 Offline
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
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 883 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.172 seconds in which 0.146 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org