Antivirus Tips Techniques
Antivirus Tips Techniques
WHITE PAPER
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
Table of Contents
Introduction .................................................................................................................. 2 Early Anti-Virus Suggestions from Microsoft ..............................................................3 Microsoft Word Macro Viruses .................................................................................... 5 Excel Macro Viruses .....................................................................................................18 PowerPoint Macro Viruses ..........................................................................................19 Office 2000 Viruses ......................................................................................................20 Script Viruses................................................................................................................21 Additional Tips.............................................................................................................22 Authors Conclusions ...................................................................................................23 Acknowledgments ........................................................................................................24
The information in this white paper has been provided by Network Associates, Inc. To the best knowledge of Network Associates, Inc., these companies offer the types of products described. These companies are solely responsible for their software, distribution, and support services. Network Associates, Inc. disclaims any and all liabilities for and makes no warranties, expressed or implied, with respect to these products, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose. Distribution of these products, or information concerning these products, does not constitute Network Associates, Inc. endorsement of the products, the companies, or support services. Product information is subject to change without notice.
N E T W O R K
A S S O C I AT E S
Introduction
In the summer of 1995, the Word Concept virus was unleashed upon an unsuspecting
world, changing the scope of the virus problem forever. For the first time, viruses could reside in
common word processing and spreadsheet documents. Since that time, Word and Excel macro
viruses have become the most dominant virus threat to organizations and individuals alike,
appearing at a rate of over 200 new viruses per month. In 1999 alone, $7.6 billion in damage was
done by viruses, many of them macro viruses affecting Word and Excel environments.
AUTHOR PROFILE
Chengi Jimmy Kuo is a wellknown anti-virus researcher, specializing in how viruses affect the common user and how best to protect users' data. He is the author of numerous technical papers which have been independently translated into several languages, and he has appeared on TV and in newspapers worldwide thanks to his virus expertise. Kuo holds a Bachelor of Science degree in Engineering and Applied Sciences from the California Institute of Technology, and his previous areas of research include IBM PS/2 BIOS (his initials can be found in the some models of BIOS chips), AIX-UNIX development, and natural language processing. Kuo presently serves as Director of Anti-Virus Research for the Network Associates Anti-Virus Emergency Response Team (AVERT), and holds a Senior Fellow position at NAI Labs, a Network Associates advanced research facility.
Network Associates offers a comprehensive solution for all existing and new macro
viruses in its McAfee Total Virus Defense suite scanning engine. Part of any good virus
security policy, however, involves things you can do at no cost to reduce your exposure to
macro viruses.
The objective of this paper is to introduce a variety of free macro anti-virus techniques
and discuss the pros and cons of each. This paper concludes with the author discussing several
methods he personally uses to protect himself against macro viruses in his day-to-day work.
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
N E T W O R K
A S S O C I AT E S
ScanProt
ScanProt is a macro package written by Microsoft. Its original intention was to protect against Concept.A and to provide a mechanism for users to be alerted if any incoming document contained macros. One unintended side effect of the original ScanProt workaround was the fact that various ScanProt macros were actually absorbed into spreading viruses. This caused a "mating" scenario between an existing virus and ScanProt, producing a new virus variant. The positive benefits of this approach, however, have since been incorporated directly into Word 7.0a and Word 97. Another action undertaken by ScanProt is to rename macros associated with known viruses to alternative names. Although this approach makes some known viruses nonfunctional, it also makes them irremovable by some anti-virus products. With more than 200 new macro viruses appearing each month, it is also an ineffective method of maintaining ongoing virus security. PROS: Early solution that protected against Concept.A Alerts if any macros exist in document (now a feature of Word 7.0a and 97) CONS: ScanProt macros can be absorbed and spread as part of new viruses
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
option, simply click on Tools and Options..., then choose the Save tab. From this menu, check the Prompt to Save Normal Template option. As noted above, viruses spread by definition. This is most easily accomplished by getting into the global environment. The global environment is represented by the file normal.dot. If a virus attempts to alter normal.dot and this option is in use, Word will inform you that there is a request to change the Normal Template as you attempt to exit. At this time, you can respond that you do not wish to allow such a change. Presumably, the user would know of any intentional changes. An unexpected attempt to modify this file could, therefore, indicate a virus attack in progress. Even with this option in use, however, it is possible to open an infected file and infect the environment. The warning does not occur until exit from Word. Thus any documents opened and saved after the initial infected document will also be infected. Furthermore, many of today's most prevalent macro viruses are aware of this attempt, and can easily deactivate this feature themselves, rendering it largely ineffective. PROS: Easy to set Commands required to set this feature can be automated Reduced risk from early macro viruses like Concept.A, Wazzu.A, and NPad Easy for a "smart" virus to deactivate Does not inform until AFTER infection when user exits Word
CONS:
N E T W O R K
A S S O C I AT E S
PROS: CONS:
Effective against the AutoOpen and AutoClose macros Easy to forget or perform incorrectly If done incorrectly, you will not know until it is too late Viruses that do not use AutoOpen or AutoClose will still infect
DisableAutoMacros
DisableAutoMacros is a Word macro function does exactly what the name implies. If the function is activated, no auto functions will execute automatically until the function is turned off (or until the next Word session). Removing the ability to automatically execute the auto functions limits those viruses from easily infecting your system. Ironically, the best way to invoke this function is through an AutoExec macro. However, in the following instructions, the end result will be an AutoExec function in its own template file, not in the normal.dot file. I recommend the template file be placed in the default startup directory in order to keep the normal.dot file pristine. And, in this manner, it is easier to give the file to others and harder for viruses to find and remove. Start by making sure your normal.dot is writeable, and empty... Click on Tools, Macros... In the Macro Name: box, Enter autoexec Click on Create. Edit the macro to insert the DisableAutoMacros command: Sub MAIN DisableAutoMacros 1 End Sub Close the editing session. Exit and save all changes. In the DOS environment: copy \msoffice\templates\normal.dot \msoffice\winword\startup\noauto.dot erase \msoffice\templates\normal.dot PROS: Disables all Auto macros Greatly reduces chance of infection Not foolproof Does not disable other intercepted macros, key shortcuts, etc. Environment is no longer pristine. May lead others to believe the macro you have established is suspicious and cause technical support issues.
CONS:
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
N E T W O R K
A S S O C I AT E S
button to change the label to Open File... Click on Open File... to get a Browse box. Choose the target file to investigate. (By default, Word lists the .dot files. If the file you wish to investigate is not so named, you should change the Files of Type: drop-down box to All Files.) The filename will be shown. If any macros exist in the file, they will be listed in the big box. If not, normal.dot will show up again with its macros. Practice on a file that you know has macros in it. PROS: CONS: Safely determines if any macros exist in the target file Difficult to tell whether macros contain a virus Complex set of tasks
Customized Tools/Macro
Because default menu items are often targeted and intercepted by macro viruses, it is important to know how to create menu items which will have the same functionality as those which would be intercepted. Following are instructions to create an equivalent to Tools/Macros... Make sure the normal.dot is writeable Click on Tools, Customize... Choose the Menus tab Under Categories click on Tools Under Commands click on ListMacros For Position on menu: choose (At bottom) Click on Rename. Close the editing session. Exit and save all changes. In DOS, remember to make normal.dot read-only again. Following this, you will have an additional choice under Tools to list the macros in your document. PROS: Bypasses the need to use Tools/Macro... Not subject to virus payloads tied to Tools/Macro CONS: Works until viruses start to interept Tools/ListMacros Requires creation of customized menus to regain use of lost menu features
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
If the user chooses to continue with the macros disabled, the file is opened in a readonly state and cannot be changed. If you do not normally make use of macros, it may be wise to have the features activated by default. Although simple to activate, some of the usability touches added to this feature create exceptions that are not readily apparent. These conditions have previously been documented by Vesselin Bontchev and revolve around certain conditions where Microsoft would expect macros to appear. Thus if those macros turn out to be viral, the initial warning will not alert because the macros were expected to be there. PROS: CONS: Generally effective. If there's a macro in the document, it tells you so. Prevents editing of any document with normal healthy macros Can be defeated by viruses that fall under Word's exceptions list
N E T W O R K
A S S O C I AT E S
The disadvantage is that only select people can clean up such an infection. And on those occasions when normal.dot is allowed to be infected, no warning is given that it has been infected. To set up this option: Start a Word session and explicitly open the normal.dot file. (\MsOffice\Templates) Click on Tools, Options... Choose the Save tab. The instructions are the same as above. At the lower left under File-Sharing Options for normal.dot, type a password into the WriteReservation Password box. You will then be asked to confirm the password. Close the editing session. Exit and save all changes. PROS: CONS: Allows flexibility for those who occasionally want their normal.dot to be read-only Asserts messages to you each time you start Word Only that same select few can clean up the global infection
10
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
11
N E T W O R K
A S S O C I AT E S
PRO:
For distribution, the smallest possible file is sent Your friends are not infected by your documents You and your company are not embarrassed You get in the practice of distributing only RTF files, a good habit to have It is a few extra steps May not be perfect
CON:
attribute of normal.dot to read-only. As it is so easy to do and quite effective, it is also the most talked about method on the Internet. DOS has the concept of attribute bits. The most commonly referenced are the System, Read-Only (RO), Hidden, and Archive bits. The specific attribute bit which interests us is the Read-Only bit. If the RO bit is set, normal DOS system calls will refuse to write or change the file. Thus, in theory, if the normal.dot file is RO, no virus will be able to change it. As noted before, a virus generally wants to change the global environment. This generally causes the normal.dot to be rewritten. However, if the RO bit is set, when Word opens normal.dot, it recognizes and stores this fact. When Word exits, it remembers normal.dot was RO and refuses any attempt to change it. Anyone who uses macros would be severely limited by this approach, however, as it would require constantly modifying the read-only status. A user of macros can still operate with a RO normal.dot, however, if he/she stores all files in the default startup directory. Macros would be handled in the way we described in the noauto.dot section above. Second, and a very important note, is that one doesn't realize a virus is active until AFTER exiting Word. The significant technical note is to recognize that Word informs you of the attempt to write to normal.dot when it exits. So, throughout the time you are using Word, files will continue to be infected without warning. Only on exit do you realize that something bad has been happening throughout the day. At that point, of course, you can immediately shift into "virus forensics" mode. Forensics needs as much historical information as it can muster. To facilitate this, we would want to make use of the Most Recently Used (MRU) list. By default, Word's MRU list is set to remember the last four files opened by the user. These are going to be the files of interest anyway. The files saved on that day are the ones to be chased down if any of them had been sent to anyone.
12
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
With a default of only four, you would most likely need to increase the length of the MRU list to the maximum number of files you might expect to use during the average day. To do so, choose Tools then Options then General. Go to the Recently Used File List and increase the number to its maximum. PROS: System level protection Slows down viral spread Will know of an infection by the end of the day Viruses cannot circumvent this to infect normal.dot in the same session If user must constantly update his macros, productivity would be hindered Could require significant backtracking if virus is discovered May create false sense of security
CONS:
Word Viewer
One of the most common infection scenarios involves receiving a document through email, double-clicking on it, and having Word automatically open the document. This is governed by one of two setups. It will be either the e-mail program itself being programmed to activate Word based on whatever criteria it uses, or it will be based on the e-mail program making use of the registry. In this section, we will cover the steps necessary to change the default association of .DOC and .DOT files to Word. This affects such activities as double-clicking, drag-and-drop, and Explorer. The title of this section is Word Viewer because instead of using Word to read .DOC files, another program is used instead, one which does not support macros. WordView or WordPad are such programs. WordPad supports no macros. WordView has restricted support of macros. This section covers the necessary steps to redirect the registry associations of .DOC and .DOT from Word to WordPad or WordView. Find WordPad.EXE (or WordView.EXE) on your system Note the full pathname for the file Find REGEDIT.EXE or REGEDT32.EXE on your system and execute Under HKEY_CLASSES_ROOT, locate .doc and .dot Traverse the structure until you locate Shell then command Change the associated command to the full pathname of WordPad.EXE HKEY_CLASSES_ROOT .doc Word.Document.6 Word.Document.6 shell open command C:\Program Files\Windows NT\Accessories\WordPad.exe "%1"
13
N E T W O R K
A S S O C I AT E S
NOTE: All the commands have to be changed: Open, New, etc. PROS: CONS: Does not allow macros of any kind to execute Limited word processing capabilities Avoid macros, but doesn't tell you they are there Some e-mail programs disregard the registry
If you do not have a viewer, one can be retrieved, free, from: http://www.microsoft.com/msword/internet/viewer/viewer97/license.htm
14
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
CONS:
Not effective until next bootup Requires expert to setup Requires expert to understand use
N E T W O R K
A S S O C I AT E S
directory to make sure the contents of the directory do not change. To make sure no viruses are added to the directory, we need to store a listing of the directory from a known clean state. Then, each time the machine is started, we make use of autoexec.bat to check that the current contents of the directory is not different from the list which represents what it should be. The code needed to make this happen can be seen below. To set up: Start Word and locate the default Startup directory Click on Tools Go to Options Choose the File Locations tab Look for the entry related to Startup (If there are three dots in the directory name, double click on the entry to see the full directory name. Write down this directory name. Below, the code example uses \msoffice\Winword\Startup as that directory.) Cancel, etc. and exit from Word In DOS, continue by executing the following instruction: dir /b /a \msoffice\Winword\Startup > %TEMP%\startup.lst This dir command creates the list which lists the current contents of the Startup directory and stores this list in your defined "temporary" directory. If you have an older version of DOS, it may not have some of the parameters that are used. To explain the instruction: /b creates the short form of this command /a includes hidden files so virus writers cannot use that to hide %TEMP% is replaced by DOS with the defined "temp" directory Add the following to autoexec.bat: dir /b /a \msoffice\Winword\Startup > %TEMP%\startup.chk diff %TEMP%\startup.lst %TEMP%\startup.chk > NUL if errorlevel 1 goto diff_startup [continue] goto end :diff_startup echo Word startup directory changed^G pause :end endbat
16
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
PROS:
Informs of any change Ensures clean boot up each day Generally transparent No warning until next boot up Requires expert to setup Requires expert to understand use
CONS:
Using endbat.bat
In the battle against macro viruses, it is important to know that many macro viruses have payloads which attach extra code to the autoexec.bat file. When this happens, the next time the machine is started, the code added by the macro virus will execute. Thus, it is important to come up with a method which prevents such payloads from taking effect. With batch files, there are two different ways to transfer control to another batch file. One method is to "call" the second batch file. In this way, after the completion of the second batch file, control is returned to the "caller." The second method transfers control directly to another batch file. This method does not return control upon completion of the second batch file. First, we create an empty batch file called endbat.bat. In the autoexec.bat, instead of letting it end by executing the last instruction, we transfer control to endbat, which finishes the startup process. With this setup, any code that is added by a macro virus to the end of autoexec.bat never gains control. Thus, none of that code runs. This same setup will cause software installations which add to the end of autoexec.bat to also fail in the same way. In such situations, simply remove the endbat transfer and replace it at the end of autoexec.bat again. PROS: CONS: Endbat.bat immunizes against the effect of viruses May interfere with software installations that write to autoexec.bat
In the battle against macro viruses, it is important to know that many macro viruses have payloads which attach extra code to the autoexec.bat file.
17
N E T W O R K
A S S O C I AT E S
PROS: CONS:
Eliminates effect of virus payloads that use debug to plant such onto machines Not a solution for programmers who need to use debug
Rename WScript.exe
This next technique is similar to the previous section, involving a file named WScript.exe. Virus writers have started to take advantage of VisualBasic Script, which requires the installation of something called the Windows Scripting Host. If your operating system is Windows 95 or WindowsNT, in order to have Windows Scripting Host installed, you must install it as an adjunct. But since Windows 98, the Windows Scripting Host comes installed by default. So, similar to renaming debug.exe, you can rename or remove WScript.exe. PRO: CON: Users not affected by viruses that use VB Script to invoke payloads or to spread Some people actually do want VB Script
CONS:
18
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
19
N E T W O R K
A S S O C I AT E S
Versions prior did not support macros, thus were not capable of having viruses. However, later versions, as with PowerPoint 2000, will also support macros and are therefore equally susceptible to viruses as the PowerPoint97 version.
Blank Presentation.pot
As with Word, PowerPoint has a default template mechanism similar to normal.dot. For PowerPoint97, this file is called Blank Presentation.pot and can be found in the \Office\Templates directory (\Program Files\Microsoft Office\Templates typically). As it is a singular file, the techniques described in points entitles " ReadOnly Normal.dot," "Replace Normal.dot Every Time," and "Check For Changes to Normal.dot" are all equally applicable to PowerPoint. All the PROS and CONS stated for those sections apply as well.
Access 2000
Access 2000 will finally support Macro virus protection under Tools/Options/General, like the other Office products. See also points entitled "Word 7.0 and Word97," "Excel Macro Virus Protection" and "PowerPoint Macro Virus Protection."
Word 2000
Word 2000 will check the registry for settings to decide whether it will allow macros to execute or to always open a document with macros disabled. It will check in two locations. One of the registry locations will be under the HKEY_LOCAL_MACHINE tree, which will require someone with admin rights in order to change it. Thus, if it is set, and users are not granted admin rights, users can be forced to do without macros.
20
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
Script Viruses
As introduced in the point entitled "Rename WScript.exe", the Visual Basic Script language can be used by macro viruses. There are other methods than renaming WScript.exe that can make your system less vulnerable to an automatic, or silent, infection.
21
N E T W O R K
A S S O C I AT E S
Additional Tips
Handling Suspect Documents
For the network administrator who must handle a corporation's suspect documents, here are some additional suggestions. First be sure to use all the techniques in the sections above. If a file is suspect, create a clean environment by using the process outlined in the "DisableAutoMacros" section (one of the "Methods Provided in Microsoft Word"). Examine the file using File/Templates/Organizer, before opening any other files. If the suspect file does not have a ToolsMacro entry, use it to rename the macros to shortened names before examining the macros. If it does, create your own ListMacros menu option and use it instead of ToolsMacro.
22
F R E E
A N T I - V I R U S
T I P S
&
T E C H N I Q U E S
Author's Conclusions
Obviously, the most simple, effective, and reliable method of protecting against viruses is the use of proven anti-virus products. Because the purpose of this paper is to examine free techniques, however, I would like to conclude by noting which of the free methods I use personally. To begin with, I set my normal.dot file to read-only. In addition, I use Prompt to Save Normal Template. As detailed earlier, the two do not conflict and thus it's possible to use both. Both are meant to warn you by the end of the day if your environment was infected during the day. But, why use both? Isn't one enough? The first answer is that it doesn't hurt, so why not? The second answer is that some viruses try to undo one or the other. So, using both techniques means a virus has to attack both simultaneously to circumvent the protection. And if nothing is happening, both are transparent, so they will not disturb your everyday work. I also use the DisableAutoMacros template as distributed in the separate file noauto.dot. Most viruses make use of an auto macro of one sort or another to spread. And all the viruses in the wild do. With this macro in place, viruses will not automatically activate and the chance of spreading something, even if you come in contact with it, is much smaller. Furthermore, as described in its section, an MIS director can create this file and send it to the whole company to be placed in the appropriate location. Thus this can have corporate wide impact with little effort. Lastly, throughout all the Office97 products, each is programmed to alert if any macros exist in an incoming document, be that Word, Excel, or PowerPoint. The products in their default mode have the macro alert on. Don't turn it off until you hit your first false alarm. And even then, judge how much trouble the false alarm caused. If you feel that it was not a problem, leave the setting on. The alert is not perfect (the problem scenarios have been documented in Vesselin Bontchev's paper for the 1996 Virus Bulletin Conference). But until you experience a false alarm, it will not have caused you any issues.
Obviously, the most simple, effective, and reliable method of protecting against viruses is the use of proven anti-virus products.
23
N E T W O R K
A S S O C I AT E S
Acknowledgments
Vesselin Bontchev, Anti-Virus Research, FRISK Software Intl. Stefan Geisenheiner, Anti-Virus Research, Amsterdam, NL, Network Associates, Inc. Raymond M. Glath, Sr., President, RG Software Systems Jivko Koltchev, Anti-Virus Research, Santa Clara, CA, Network Associates, Inc. Akihiko Muranaka, Tokyo, Japan, Network Associates, Inc. Francois Paget, Anti-Virus Research, Paris, France, Network Associates, Inc. Translations available in German, French, Spanish and Portuguese
24
For more information on products, services, and support, contact your authorized Network Associates sales representative.
CORPORATE HEADQUARTERS
3965 Freedom Circle Santa Clara, CA 95054-1203 Tel (408) 988-3832* Fax (408) 970-9727 *Call for additional Worldwide Sales Offices
McAfee, Total Virus Defense and Network Associates are registered trademarks of Network Associates, Inc. and/or its affiliates in the U.S. and/or other countries. All other registered and unregistered trademarks in this document are the sole property of their respective owners. 1999 Networks Associates Technology, Inc. All rights reserved.
6-TVD-FAV-001 9/99