TweetFollow Us on Twitter

Virus
Volume Number:4
Issue Number:5
Column Tag:Advanced Mac'ing

A Vaccine for the 'nVIR' Virus

By Mike™ Scanlin, Contributing Editor

Unless you are going to Africa or Indochina, viruses and vaccinations are not something that most of us need to worry about. However, even if you’re not planning on travelling, there is one virus you need to be aware of. It is a computer virus that is infecting Macintoshes everywhere. [Note: The virus described in this article is apparently only one of at least three viruses that are going around as reported in the press. This article discusses what we shall name the ‘nVIR’ virus. The other two are the infamous ‘peace message’ virus and the ‘scrapbook’ virus reported in this month’s mousehole column, and in a recent MacWeek article. -Ed]

Are you infected?

Use ResEdit to open your system file and look for ‘nVIR’ resources. If you have them, then your system has been infected and chances are that at least some (if not most or all) of your applications are infected. Don’t panic. This particular virus is relatively harmless. There is an application at the end of this article that will allow you to remove the virus from your infected applications. There is also an ‘INIT’ resource you can put in your System Folder that will warn you if this virus ever shows up on your system. [Note that this vaccine and virus warning init applies only to this particular ‘nVIR’ virus. New vaccines will be necessary for the other two once it is known how they operate. -Ed]

Fig. 1 Vaccination Alert tells Application status

How I found it

Until last week, I had had no experience with computer viruses. I had heard rumors about the existence of Mac viruses, but didn’t really believe them. I do not know when this virus first got into my system. It must have come from some program I downloaded off of a network, but I do not know which one. By the time I figured out what was going on, the virus had modified seventeen of the applications on my hard disk and my System file.

Virus Symptoms

Sometime near the beginning of last week, I started hearing a beep when launching programs. It didn’t happen every time, only once in a while and with no discernable pattern. Using TMON, I trapped SysBeep() and discovered that something was modifying ‘CODE’ 0 and installing several ‘nVIR’ resources into every application I launched. I looked in my System file and, in addition to several ‘nVIR’ resources, found an ‘INIT’ 32 resource that I didn’t put there. I compared the standard ‘INIT’s from an original system disk and none of them matched the ‘INIT’ 32 I had found. What really clued me in to the idea of a virus was that if I took the ‘INIT’ 32 resource out of my System file, quit ResEdit, and then relaunched ResEdit, the ‘INIT’ 32 resource would be back in there. After disassembling ‘INIT’ 32, I learned how it worked and how to make my system immune to it. I am sharing this information so that other Mac users can protect themselves as well. [Note that this virus exhibits the ability to re-install itself after being patched out with ResEdit! -Ed]

How to make your System file immune

Use ResEdit to open your System file. Create an ‘INIT’ 32 resource that consists of these 2 hex bytes: 4E 75 (which is an RTS instruction). If ‘INIT’ 32 already exists and has a size of 366 bytes, then you can be pretty sure it is the virus’ ‘INIT’. Replace the existing ‘INIT’ 32 with the 2 byte version (4E 75). Now create 8 resources of the type ‘nVIR’; the case of the resource type is important -- do not use ‘NVIR’ or ‘nvir’. Their IDs should be 0 through 7, with size zero bytes. If they already exist, then delete them and create 8 new empty ones (with IDs 0-7).

That’s it. Your system is now immune to this particular virus (but not all possible viruses). If you now run an infected application, the virus will think that it is already installed in your system file, since it sees the ‘INIT’ and ‘nVIR’ resources it expects, and will leave it alone.

If your System file was infected before you immunized it, you should reboot the system before using the procedure below to remove the virus from your applications. This guarantees that the effects of ‘INIT’ 32 are removed from memory.

Removing the virus from infected applications

If an application has been infected, it will have several ‘nVIR’ resources, a ‘CODE’ 256 resource, and a possibly modified ‘CODE’ 0 resource. Here are instructions on how to restore an infected application (note: this is only useful if you are certain that your System file is not infected. Otherwise, the applications will become infected again. Also, you should practice on a copy of an infected application):

1) Open the application with ResEdit. If ‘CODE’ 256 exists, use GetInfo on it to check its size. If it is 372 bytes, then remove it. The reason we check for the size is because some applications, such as ReadySetGo, already have a ‘CODE’ 256 resource of their own and we don’t want to remove part of the application’s code.

2) Open ‘CODE’ 0 and look at the 3rd line of 8 hex bytes (bytes 16-23). If it is “0000 3F3C 0100 A9F0” then you need to replace that line of hex numbers with the 8 bytes contained in the ‘nVIR’ 2 resource. If the third line does not look like the above 8 bytes, then the ‘CODE’ resource is probably protected and did not get modified -- see below for an explanation. In this case leave it alone.

3) Remove all ‘nVIR’ resources. Make sure you have completed step 2 before removing ‘nVIR’ 2. You cannot restore the application without it.

Because this procedure is so automatic, I have written a program that does it for you. The application Vaccination displays the SFGetFile dialog and allows you to choose an application to vaccinate. A message is displayed that tells you the result of the vaccination and the SFGetFile dialog is displayed again. If your system has been infected, you should vaccinate every application on your hard drive. You will only see files of type ‘APPL’, ‘FNDR’ (for the Finder), and ‘dahd’ (for the DA handler) in the SFGetFile dialog so you might want to do a manual tree walk of your hard drive to be sure you vaccinate all of your applications. There is no harm in vaccinating an uninfected application or in vaccinating the same application more than once. This program does not make applications immune to this virus, it only removes this virus from them. But if your System file is immune, then there is no way this particular virus can spread to your applications. Note: you cannot use the Vaccination program to make your System file immune. You will have to do that manually using the procedure above.

How this virus works

This particular virus modifies the ‘CODE’ 0 resource of an application in such a way that when you launch that application the first thing to execute is a piece of virus installation code. That installation code looks for the virus’ presence in the System file you are launching from. If it does not find evidence of the virus, it then installs itself (as ‘INIT’ 32 and several ‘nVIR’ resources) into your System file and then executes the application you had originally launched. Once your System file is infected, every application launched from that system will become infected. The whole infection process only takes a second or two, so there is little chance you will notice it. If the virus detects that it is already in the System file and in the application you are launching (meaning that no installation of itself is necessary on this launch), then there is about a 6% chance (1 in 16) that you will hear a short beep. This is the beep that first got my attention. According to a friend of mine, Chris Borton, whose computer was also infected, if you have MacinTalk in your System Folder, then the virus speaks the words “Don’t Panic” instead of beeping.

This virus does not check if the ‘CODE’ 0 resource of the application it is trying to infect is protected or not. Consequently, applications that have ‘CODE’ 0 resources with the resProtected bit set are still infected, but are not contagious, i.e. they have the ‘CODE’ 256 resource and the ‘nVIR’ resources added to them, but they can not pass the virus on to a clean System file. I learned this by noticing that QUED/M and PageMaker were infected, but were not contagious. I couldn’t figure out why some programs had protected ‘CODE’ resources and others didn’t. Then one of the people I work with, Victor Romano, put it together. He told me that Lightspeed C (which QUED/M and PageMaker were written in) automatically sets the resProtected bit of the ‘CODE’ resources it generates. MPW does not. So, protecting the ‘CODE’ resources (which can be done with ResEdit) is another simple way of preventing this virus from affecting an application.

To be forewarned

I don’t know how far this virus has already spread, or how far it will spread. As a partial defense, however, I have written a piece of code that can be installed as an ‘INIT’ file in your System Folder that will warn you if it detects something that looks like this particular virus. VirusWarnINIT is a patch on 2 routines that this virus relies on: GetResource() and ChangedResource(). The patch to GetResource() makes a beep if theType == ‘nVIR’. The patch to ChangedResource() makes a beep if theResource is a handle to a ‘CODE’ 0 resource. I wouldn’t suggest installing this ‘INIT’ in a system known to be infected -- the number of beeps is sure to annoy you. I would have used something like an alert window instead of a beep as a warning, but I can’t be sure that the Window Manager has been initialized at the time the virus is detected. If you install this ‘INIT’ in a clean system and then launch a contagious application, you will hear about 5 or 6 beeps in a row as the virus tries to install itself in your System file.

Note that this ‘INIT’ is only a warning, not a vaccination. The virus will still install itself. The advantage is that you will know about it right away and can stop it before it spreads very far.

Now that my Mac has been vaccinated, it’s my turn. After Typhoid, Yellow Fever, Cholera and Meningococcal vaccinations, I’m off to Africa and Indochina. I wonder if I can get David Smith to send MacTutor to Serengeti National Park? Or do they already get it there? I’ll let you know

/* Vaccination.c
   * by Mike™ Scanlin   12 March 88
   *
   * Removes the ‘nVIR’ virus from an 
 * application chosen by the user.
  */
  
#include“QuickDraw.h”
#include“ResourceMgr.h”
#include“StdFilePkg.h”
#include“FileMgr.h”

#define NIL 0L
#define reg register

#define REPORT_STATUS_ALERT 129

#define nVIR_CODE_256_SIZE372

#define nVIR2Bad -10
#define nVIR2NotFound-11

void    RemoveResourceFromFile(long theType, int theID, int    
 refNum);
intInnoculate(Str255 *fileName, int vRef);
void    pStrCpy(char *p2, char *p1);
Boolean ChooseFile(Str255 *fn, int *vRef);
void    main(void);

static  SFReply  reply;
static  int applResFile;


/* RemoveResourceFromFile(theType, theID, refNum)
   *
   * This will remove the resource of type theType 
 * and ID theID from the open resource file
   * whose refNum is refNum.
  */
void  RemoveResourceFromFile(theType, theID, refNum)
long  theType;
inttheID;
intrefNum;
{
 reg Handle theResource;
 
 if ((theResource = GetResource(theType, theID)) && (HomeResFile(theResource) 
== refNum))
 RmveResource(theResource);
}

/* Innoculate(fileName, vRef)
  *
  * This removes the ‘nVIR’ virus from *fileName 
 in directory vRef.
  */
int     Innoculate(fileName, vRef)
reg Str255*fileName;
intvRef;
{
 reg Handle oldCODE, currentCODE;
 reg inti, refNum, returnVal;
 ParamBlockRec   pb;
 
 /* init the ParamBlockRec to all zeros */
 asm {
 lea    pb,A0
 move.l #sizeof(ParamBlockRec),D0
 subq.l #1,D0
 
 @1clr.b(A0)+
 dbra D0,@1
 }
 
 /* set the current working directory */
 pb.ioParam.ioVRefNum = vRef;
 PBHSetVol(&pb, FALSE);
 
 refNum = OpenResFile(fileName);
 
 if ((oldCODE = GetResource(‘nVIR’, 2)) && (HomeResFile(oldCODE) == refNum)) 
{
 if (GetHandleSize(oldCODE) != 8)
 /* if ‘nVIR’ 2 isn’t 8 bytes, then something 
 isn’t right. */
 returnVal = nVIR2Bad;
 else {
 if ((currentCODE = GetResource(‘CODE’, 0)) && (HomeResFile(currentCODE) 
== refNum)) {
 asm {
 MOVE.L oldCODE, A1
 MOVE.L (A1),A1
 MOVE.L currentCODE, A0
 MOVE.L (A0),A0
 ADDA #16, A0
 MOVE.L (A1)+, (A0)+
 MOVE.L (A1), (A0)
 }
 ChangedResource(currentCODE);
 }
 
 /* kill the ‘nVIR’ resources */
 for (i = 0; i <= 7; i++)
 RemoveResourceFromFile(‘nVIR’, i, refNum);

 /* kill the extra ‘CODE’ resource that this 
 virus adds (only if it has the size 
 of nVIR_CODE_256_SIZE) */
 if ((currentCODE = GetResource(‘CODE’, 256)) &&
 (GetHandleSize(currentCODE) == 
 nVIR_CODE_256_SIZE) && (HomeResFile(currentCODE) 
 == refNum))
 RmveResource(currentCODE);
 
 returnVal = noErr;
 }
 }
 else
 returnVal = nVIR2NotFound;
 
 if (refNum != applResFile)
 CloseResFile(refNum);
 
 return(returnVal);
}

/* pStrCpy(p2, p1)
  *
  * Copy the pascal string at *p1 to *p2.
  */
void pStrCpy(p2, p1)
reg char*p2, *p1;
{
 reg intlen;
 
 len = *p2++ = *p1++;
 while (--len >= 0) 
 *p2++ = *p1++;
}


/* ChooseFile(fn, vRef)
   *
   * Use SFGetFile() to get the name of an 
 * application from the user. Return the directory
   * of the chosen file in *vRef. Return FALSE if the 
 * user clicked Cancel, TRUE if they clicked
   * Open.
  *
  * Thanks to Chris Borton for this routine.
  */
Boolean ChooseFile(fn, vRef)
Str255  *fn;
int*vRef;
{
 SFTypeList myTypes;
 static Point  SFGwhere = { 90, 82 };
 
 myTypes[0] = ‘APPL’;
 myTypes[1] = ‘FNDR’;
 myTypes[2] = ‘dahd’;
 
 SFGetFile(SFGwhere, NIL, 0L, 3, myTypes, 0L, &reply);
 if (reply.good) {
 pStrCpy((char *)fn , (char *)reply.fName);
 *vRef = reply.vRefNum;
 return(TRUE);
 }
 else
 return(FALSE);
}

void main() {
 
 Str255 fileName;
 int    vRef;
 
 /* save the application’s resource file refNum */
 applResFile = CurMap;
 
 InitGraf(&thePort);
 InitFonts();
 InitWindows();
 InitMenus();
 InitDialogs(0L);
 InitCursor();

 /* keep choosing files until the user hits Cancel */
 while (ChooseFile(&fileName, &vRef)) {
 switch (Innoculate(&fileName, vRef)) {
 case   nVIR2Bad:
 ParamText(&fileName, “\pResource ‘nVIR’ 2 is not 8 bytes long. File 
cannot be repaired.”, NIL, NIL);
 break;
 case nVIR2NotFound:
 ParamText(&fileName, “\pResource ‘nVIR’ 2 not found. File is not infected 
or cannot be repaired.”, NIL, NIL);
 break;
 default:
 ParamText(&fileName, “\pVirus successfully removed.”, NIL, NIL);
 }
 
 /* show the result of the attempted removal */
 Alert(REPORT_STATUS_ALERT, NIL);
 }
}


/* VirusWarnINIT.c
   * by Mike™ Scanlin   13 March 88
   *
   * Put this in your system folder to warn you 
 * about the ‘nVIR’ virus.
   * It patches GetResource() and ChangedResource().
  */
  
#include “Asm.h”
#include “ResourceMgr.h”

#define GetResource0xA9A0
#define ChangedResource 0xA9AA
#define JMP 0x4EF9
#define memFullErr -108
#define beepDuration 20

void  main(void);

void  main()
{
 asm  {

/* beginning of the code that installs the patches */

 move.l D3,-(SP)
 
/* get the original GetResource address */   
 move #GetResource,D0
 _GetTrapAddress
/* set up the JMP instruction that calls the original GetResource */
 lea    @origGR,A1
 move #JMP,(A1)+
 move.l A0,(A1)

/* get the original ChangedResouce address */
 move #ChangedResource,D0
 _GetTrapAddress
/* set up the JMP instruction that calls the original ChangedResource 
*/
 lea    @origCR,A1
 move #JMP,(A1)+
 move.l A0,(A1)

/* get some space in the system heap for the patches */
 lea    @last,A0
 lea    @first,A1
 suba.l A1,A0    /* the length of our patches */
 move.l A0,D0
 add.l  #254,D0  /* the extra space for the Str255 at the end (@name) 
*/
 move.l D0,D3    /* save for _BlockMove */
 _NewPtrSYS
 cmpi   #memFullErr,D0
 beq.s  @noPatch
 move.l A0,-(SP) /* save for _BlockMove */
 move.l (SP),-(SP) /* for _SetTrapAddress */

/* set GetResource to the beginning of the space we just got in the system 
heap */
 move #GetResource,D0
 _SetTrapAddress

/* set ChangedResource trap */
 lea    @changedResouce,A0
 lea    @getResource,A1
 suba.l A1,A0
 adda.l (SP)+,A0
 move #ChangedResource,D0
 _SetTrapAddress
 
/* now move it into place */
 lea    @first,A0
 move.l (SP)+,A1
 move.l D3,D0
 _BlockMove

@noPatchmove.l (SP)+,D3
 rts
 
/* end of the code that installs the patches */

@first  

/*
  * This is the patch to GetResource
  *
  */
@getResource
 move.l 6(SP),D0 /* get theType */
 cmpi.l #’nVIR’,D0
 bne.s  @origGR

/* at this point we know something is trying to load an ‘nVIR’ resource 
*/ 
 move #beepDuration,-(SP)
 _SysBeep
/* note that this is only a warning beep, it falls through 
 * to the original GetResource, so the calling function 
 * never knows that it was detected. */
@origGR nop /* JMP to original trap */
 nop
 nop

/*
  * This is the patch to ChangedResource
  *
  */
@changedResouce

/* call GetResInfo() to see if we are changing a CODE 0 resource */
 move.l 4(SP),-(SP)/* copy the resource handle 
 * that was passed to
   * ChangedResouce() */
 pea    @theID
 pea    @theType
 pea    @name
 _GetResInfo
 
 lea    @theType,A0
 move.l (A0),D0
 cmpi.l #’CODE’,D0
 bne.s  @origCR
 
 lea    @theID,A0
 tst    (A0)
 bne.s  @origCR

/* give a warning beep a CODE 0 resource is being changed */   
 
 move #beepDuration,-(SP)
 _SysBeep
 
@origCR nop /* JMP to original trap */
 nop
 nop
 
@theID  dc0
@theTypedc.l0
@name   dc0 
 /* there are actually 254 more bytes to this
 * variable (for a total of 256). Check the
 * add.l #254,D0 instruction in the install code. */

@last
 }
}
 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Whitethorn Games combines two completely...
If you have ever gone fishing then you know that it is a lesson in patience, sitting around waiting for a bite that may never come. Well, that's because you have been doing it wrong, since as Whitehorn Games now demonstrates in new release Skate... | Read more »
Call of Duty Warzone is a Waiting Simula...
It's always fun when a splashy multiplayer game comes to mobile because they are few and far between, so I was excited to see the notification about Call of Duty: Warzone Mobile (finally) launching last week and wanted to try it out. As someone who... | Read more »
Albion Online introduces some massive ne...
Sandbox Interactive has announced an upcoming update to its flagship MMORPG Albion Online, containing massive updates to its existing guild Vs guild systems. Someone clearly rewatched the Helms Deep battle in Lord of the Rings and spent the next... | Read more »
Chucklefish announces launch date of the...
Chucklefish, the indie London-based team we probably all know from developing Terraria or their stint publishing Stardew Valley, has revealed the mobile release date for roguelike deck-builder Wildfrost. Developed by Gaziter and Deadpan Games, the... | Read more »
Netmarble opens pre-registration for act...
It has been close to three years since Netmarble announced they would be adapting the smash series Solo Leveling into a video game, and at last, they have announced the opening of pre-orders for Solo Leveling: Arise. [Read more] | Read more »
PUBG Mobile celebrates sixth anniversary...
For the past six years, PUBG Mobile has been one of the most popular shooters you can play in the palm of your hand, and Krafton is celebrating this milestone and many years of ups by teaming up with hit music man JVKE to create a special song for... | Read more »
ASTRA: Knights of Veda refuse to pump th...
In perhaps the most recent example of being incredibly eager, ASTRA: Knights of Veda has dropped its second collaboration with South Korean boyband Seventeen, named so as it consists of exactly thirteen members and a video collaboration with Lee... | Read more »
Collect all your cats and caterpillars a...
If you are growing tired of trying to build a town with your phone by using it as a tiny, ineffectual shover then fear no longer, as Independent Arts Software has announced the upcoming release of Construction Simulator 4, from the critically... | Read more »
Backbone complete its lineup of 2nd Gene...
With all the ports of big AAA games that have been coming to mobile, it is becoming more convenient than ever to own a good controller, and to help with this Backbone has announced the completion of their 2nd generation product lineup with their... | Read more »
Zenless Zone Zero opens entries for its...
miHoYo, aka HoYoverse, has become such a big name in mobile gaming that it's hard to believe that arguably their flagship title, Genshin Impact, is only three and a half years old. Now, they continue the road to the next title in their world, with... | Read more »

Price Scanner via MacPrices.net

B&H has Apple’s 13-inch M2 MacBook Airs o...
B&H Photo has 13″ MacBook Airs with M2 CPUs and 256GB of storage in stock and on sale for up to $150 off Apple’s new MSRP, starting at only $849. Free 1-2 day delivery is available to most US... Read more
M2 Mac minis on sale for $100-$200 off MSRP,...
B&H Photo has Apple’s M2-powered Mac minis back in stock and on sale today for $100-$200 off MSRP. Free 1-2 day shipping is available for most US addresses: – Mac mini M2/256GB SSD: $499, save $... Read more
Mac Studios with M2 Max and M2 Ultra CPUs on...
B&H Photo has standard-configuration Mac Studios with Apple’s M2 Max & Ultra CPUs in stock today and on Easter sale for $200 off MSRP. Their prices are the lowest available for these models... Read more
Deal Alert! B&H Photo has Apple’s 14-inch...
B&H Photo has new Gray and Black 14″ M3, M3 Pro, and M3 Max MacBook Pros on sale for $200-$300 off MSRP, starting at only $1399. B&H offers free 1-2 day delivery to most US addresses: – 14″ 8... Read more
Department Of Justice Sets Sights On Apple In...
NEWS – The ball has finally dropped on the big Apple. The ball (metaphorically speaking) — an antitrust lawsuit filed in the U.S. on March 21 by the Department of Justice (DOJ) — came down following... Read more
New 13-inch M3 MacBook Air on sale for $999,...
Amazon has Apple’s new 13″ M3 MacBook Air on sale for $100 off MSRP for the first time, now just $999 shipped. Shipping is free: – 13″ MacBook Air (8GB RAM/256GB SSD/Space Gray): $999 $100 off MSRP... Read more
Amazon has Apple’s 9th-generation WiFi iPads...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Discounted 14-inch M3 MacBook Pros with 16GB...
Apple retailer Expercom has 14″ MacBook Pros with M3 CPUs and 16GB of standard memory discounted by up to $120 off Apple’s MSRP: – 14″ M3 MacBook Pro (16GB RAM/256GB SSD): $1691.06 $108 off MSRP – 14... Read more
Clearance 15-inch M2 MacBook Airs on sale for...
B&H Photo has Apple’s 15″ MacBook Airs with M2 CPUs (8GB RAM/256GB SSD) in stock today and on clearance sale for $999 in all four colors. Free 1-2 delivery is available to most US addresses.... Read more
Clearance 13-inch M1 MacBook Airs drop to onl...
B&H has Apple’s base 13″ M1 MacBook Air (Space Gray, Silver, & Gold) in stock and on clearance sale today for $300 off MSRP, only $699. Free 1-2 day shipping is available to most addresses in... Read more

Jobs Board

Medical Assistant - Surgical Oncology- *Apple...
Medical Assistant - Surgical Oncology- Apple Hill Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Business Analyst | *Apple* Pay - Banco Popu...
Business Analyst | Apple PayApply now " Apply now + Apply Now + Start applying with LinkedIn Start + Please wait Date:Mar 19, 2024 Location: San Juan-Cupey, PR Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.