How Computer Viruses Work

Anyone who has ever been through a virus attacking their system knows all too well that it can be incredibly stressful.
© Horrocks

Strange as it may sound, the computer virus is something of an Information Age marvel. On one hand, viruses show us how vulnerable we are -- a properly engineered virus can have a devastating effect, disrupting productivity and doing billions of dollars in damages. On the other hand, they show us how sophisticated and interconnected human beings have become.

For example, experts estimate that the Mydoom worm infected approximately a quarter-million computers in a single day in January 2004. Back in March 1999, the Melissa virus was so powerful that it forced Microsoft and a number of other very large companies to completely turn off their e-mail systems until the virus could be contained. The ILOVEYOU virus in 2000 had a similarly devastating effect. In January 2007, a worm called Storm appeared -- by October, experts believed up to 50 million computers were infected. That's pretty impressive when you consider that many viruses are incredibly simple.



In this article, we will discuss viruses -- from "traditional" viruses to e-mail viruses and exploits that could target your mobile phone -- so that you can learn how they work and understand how to protect yourself.

Virus Origins



Similar to the way a biological virus must hitch a ride on a cell, a computer virus must piggyback on top of some other program or document in order to launch. Once a computer virus is running, it can infect other programs or documents. Obviously, the analogy between computer and biological viruses stretches things a bit, but there are enough similarities that the name sticks.

People write computer viruses. A person has to write the code, test it to make sure it spreads properly and then release it. A person also designs the virus's attack phase, whether it's a silly message or the destruction of a hard disk. Why do they do it?

There are at least four reasons. The first is the same psychology that drives vandals and arsonists. Why would someone want to break a window on someone's car, paint signs on buildings or burn down a beautiful forest? For some people, that seems to be a thrill. If that sort of person knows computer programming, then he or she may funnel energy into the creation of destructive viruses.

The second reason has to do with the thrill of watching things blow up. Some people have a fascination with things like explosions and car wrecks. When you were growing up, there might have been a kid in your neighborhood who learned how to make gunpowder. And that kid probably built bigger and bigger bombs until he either got bored or did some serious damage to himself. Creating a virus is a little like that -- it creates a virtual bomb inside a computer, and the more computers that get infected, the more "fun" the explosion.

The third reason involves bragging rights. Sort of like Mount Everest -- the mountain is there, so someone is compelled to climb it. If you are a certain type of programmer who sees a security hole that could be exploited, you might simply be compelled to exploit the hole yourself before someone else beats you to it.

And then there's cold, hard cash. Viruses can trick you into buying fake software, steal your personal information and use it to get to your money, or be sold on the digital equivalent of the black market. Powerful viruses are valuable -- and potentially lucrative -- tools.

Of course, most virus creators seem to miss the point that they cause real damage to real people with their creations. Destroying everything on a person's hard disk is real damage. Forcing a large company to waste thousands of hours cleaning up after a virus attack is real damage. Even a silly message is real damage because someone has to waste time getting rid of it. For this reason, the legal system continues to develop more rigorous penalties for people who create viruses.

Virus History

Ah, the floppy disk: When most people were using these to store and transport computer programs, viruses spread like wildfire.

Traditional computer viruses were first widely seen in the late 1980s, and came about because of several factors. The first factor was the spread of personal computers (PCs). Prior to the 1980s, home computers were nearly non-existent. Real computers were rare, and were locked away for use by "experts." During the '80s, real computers started to spread to businesses and homes because of the popularity of the IBM PC (released in 1982) and the Apple Macintosh (released in 1984). By the late 1980s, PCs were in businesses, homes and college campuses.

The second factor was the use of computer bulletin boards. People could dial up a bulletin board with a modem and download programs of all types. Games were extremely popular, and so were simple word processors, spreadsheets and other productivity software. Bulletin boards led to the precursor of the virus known as the Trojan horse. A Trojan horse masquerades as a program with a cool-sounding name and description, enticing you to download it. When you run the program, however, it does something uncool, like erasing your hard drive. You think you're getting a neat game, but instead, you get a wiped-out system. Trojan horses only hit a small number of people because they're quickly discovered, and word of the danger spreads among users.

The third factor that led to the creation of viruses was the floppy disk. In the 1980s, programs were small, and you could fit the entire operating system, a few programs and some documents onto a floppy disk or two. Many computers did not have hard disks, so when you turned on your machine it would load the operating system and everything else from the floppy disk. Virus authors took advantage of this to create the first self-replicating programs.

Early viruses were pieces of code embedded in a larger, legitimate program, such as a game or word processor. When the user downloads and runs the legitimate program, the virus loads itself into memory --­ and looks around to see if it can find any other programs on the disk. If it can find one, it modifies the program to add the virus's code into that program. Then the virus launches the "real program." The user really has no way to know that the virus ever ran. Unfortunately, the virus has now reproduced itself, so two programs are infected. The next time the user launches either of those programs, they infect other programs, and the cycle continues.

If one of the infected programs is given to another person on a floppy disk, or if it is uploaded so other people can download it, then other programs get infected. This is how the virus spreads -- similar to the infection phase of a biological virus. But viruses wouldn't be so violently despised if all they did was replicate themselves. Most viruses also have a destructive attack phase where they do real damage. Some sort of trigger will activate the attack phase, and the virus will then do something -- anything from displaying a silly message on the screen to erasing all of your data. The trigger might be a specific date, a number of times the virus has been replicated or something similar.

In the next section, we will look at how viruses have evolved over the years.

Virus Evolution





E-mail Viruses

Virus authors adapted to the changing computing environment by creating the e-mail virus. For example, the Melissa virus in March 1999 was spectacular in its attack. Melissa spread in Microsoft Word documents sent via e-mail, and it worked like this:

Someone created the virus as a Word document and uploaded it to an Internet newsgroup. Anyone who downloaded the document and opened it would trigger the virus. The virus would then send the document (and therefore itself) in an e-mail message to the first 50 people in the person's address book. The e-mail message contained a friendly note that included the person's name, so the recipient would open the document, thinking it was harmless. The virus would then create 50 new messages from the recipient's machine. At that rate, the Melissa virus quickly became the fastest-spreading virus anyone had seen at the time. As mentioned earlier, it forced a number of large companies to shut down their e-mail systems to control the spread.

The ILOVEYOU virus, which appeared on May 4, 2000, was even simpler. It contained a piece of code as an attachment. People who double-clicked on the attachment launched the code. It then sent copies of itself to everyone in the victim's address book and started corrupting files on the victim's machine. This is as simple as a virus can get. It is really more of a Trojan horse distributed by e-mail than it is a virus.


Microsoft applications have a feature called Macro Virus Protection built into them to prevent this sort of virus. With Macro Virus Protection turned on (the default option is ON), the auto-execute feature is disabled. So, when a document tries to auto-execute viral code, a dialog pops up warning the user. Unfortunately, many people don't know what macros or macro viruses are, and when they see the dialog they ignore it, so the virus runs anyway. Many other people turn off the protection mechanism. Because of this, the Melissa virus spread despite the safeguards in place to prevent it.

In the case of the ILOVEYOU virus, the whole thing was human-powered. If a person double-clicked on the program that came as an attachment, then the program ran and did its thing. What fueled this virus was the human willingness to double-click on the executable. The same kinds of exploits have also been passed over instant messaging networks like AIM and Windows Live Messenger. Commandeered accounts will send out links to viruses in instant messages; anyone who clicks the link and installs a Trojan application will have their own account hijacked and unwittingly spam their own friends with the compromising link.

Now that we've covered e-mail viruses, let's take a look at worms.


A worm is a computer program that has the ability to copy itself from machine to machine. Worms use up computer processing time and network bandwidth when they replicate, and often carry payloads that do considerable damage. A worm called Code Red made huge headlines in 2001. Experts predicted that this worm could clog the Internet so effectively that things would completely grind to a halt.

A worm usually exploits some sort of security hole in a piece of software or the operating system. For example, the Slammer worm (which caused mayhem in January 2003) exploited a hole in Microsoft's SQL server. Wired magazine took a fascinating look inside Slammer's tiny (376 byte) program.

Worms normally move around and infect other machines through computer networks. Using a network, a worm can expand from a single copy incredibly quickly. The Code Red worm replicated itself more than 250,000 times in approximately nine hours on July 19, 2001 [Source: Rhodes].


The Code Red worm had instructions to do three things:

  • Replicate itself for the first 20 days of each month
  • Replace Web pages on infected servers with a page featuring the message "Hacked by Chinese"
  • Launch a concerted attack on the White House Web site in an attempt to overwhelm it [source: eEyeDigitalSecurity]

Upon successful infection, Code Red would wait for the appointed hour and connect to the domain. This attack would consist of the infected systems simultaneously sending 100 connections to port 80 of (

The U.S. government changed the IP address of to circumvent that particular threat from the worm and issued a general warning about the worm, advising users of Windows NT or Windows 2000 Web servers to make sure they installed the security patch.

A worm called Storm, which showed up in 2007, immediately started making a name for itself. Storm used social engineering techniques to trick users into loading the worm on their computers. And boy, was it effective -- experts believe between 1 million and 50 million computers have been infected [source: Schneier]. Anti-virus makers adapted to Storm and learned to detect the virus even as it went through many forms, but it was easily one of the most successful viruses in Internet history and could someday rear its head again. At one point, the Storm worm was believed to be responsible for 20 percent of the Internet's spam mail [source: Kaplan].

When the worm is launched, it opens a back door into the computer, adds the infected machine to a botnet and installs code that hides itself. Botnets are small peer-to-peer groups, rather than a larger, more easily identified network. Experts think the people controlling Storm rent out their micro-botnets to deliver spam or adware, or for denial-of-service attacks on Web sites.

Viruses of all kinds were a major threat in the early years of the Internet's growth. They're still out there, but since the mid-2000s anti-virus software has gotten better and Web browsers and operating systems have become more secure. Will the big threat of the 2010s be levied against smartphones rather than PCs?

Viruses In the 2000s and Beyond

Anti-virus software is vital to keeping your system free of problems.
© Broek

New viruses pop up all the time, but it's rare for a worm or other exploit to have the kind of impact that Storm once did. The 10 Worst Computer Viruses of All Time struck around the turn of the century and in the early 2000s. Computers were ripe targets: Anti-virus software was expensive and not always reliable, Microsoft's Internet Explorer was ripe for exploitation and PC users were unaware of how easily viruses could spread over the Internet. Viruses haven't had the same kind of impact in recent years for a number of reasons.

People are a bit better educated about viruses. Free anti-virus software is easy to download. Microsoft recommends its own Security Essentials, while companies like AVG and Avast offer their own free alternatives. Computer software, in general, is designed with the Internet in mind and is less susceptible to viruses. Just compare today's Chrome and Firefox browsers to the infamously terrible Internet Explorer 6, which was patched for over a decade after its release in 2001. Viruses are still around, of course -- in 2009, a worm called Downadup infected millions of computers in a matter of days. We're just getting better at handling them.

There are more viruses than ever out there for anti-virus software to keep track of. These programs will automatically update themselves regularly -- often even daily -- to guard against the latest virus mutations on the Internet. Just look at Avast's Virus Update History to see how many Trojans, worms and other nefarious bits of code are added to the database every day.

In a modern era of smartphones and tablets, it's actually easier than ever to browse the Internet without getting a virus. Why? Because viruses are written for specific platforms. A virus intended to exploit something on Windows won't work on Apple's Mac operating system -- the code that makes up the two systems is completely different. Similarly, the code that makes up mobile operating systems like Android and iOS is different from the code on PCs. Viruses that would cripple your computer won't work on mobile devices.

But mobile devices aren't completely secure, themselves. There are viruses out there that can extract personal information from Android phones. Because Apple's iOS is a closed source platform, unlike the open source Android, it's more difficult to target with viruses. Besides, Windows is still a juicier target. While mobile viruses will certainly become more popular as smartphone sales increase, as of 2011, they're a very minor concern.

In the next section, we'll look at patching your PC and other things you can do to protect your computer.

How to Protect Your Computer from Viruses

You can protect yourself against viruses with a few simple steps:








Related Articles

More Great Links


  • "Avoiding Social Engineering and Phishing Attacks" U.S. Computer Emergency Readiness Team. (Oct. 4, 2007)
  • Baratz, Adam, and McLaughlin, Charles. " Malware: what it is and how to prevent it" Ars Technica. Nov. 11, 2004. (Oct. 8, 2007)
  • Boutin, Paul. "Slammed! An inside view of the worm that crashed the Internet in 15 minutes." Wired Magazine. July 2003 (Oct. 3, 2007)
  • Johnston, Stuart J. "Bugs & Fixes: Save Your PC From Virus Attacks." PC World. 2/27/2002. (Oct. 8, 2007),81968/article.html
  • Kaplan, Dan. "Storm Worm making comeback with new spam run." April 28, 2010. (Oct. 29, 2011)
  • Kawamoto, Dawn. "Storm worm rages across the globe." CNET January 19, 2007 (Oct. 4, 2007)
  • Leedham, Robert. "Android Gingerbread virus poses fresh smartphone threat." Aug. 22, 2011. (Oct. 30, 2011)
  • Lemos, Robert. "Worm double whammy still hitting hard." CNET Aug 21, 2003 (Oct. 5, 2007)
  • McAfee fact sheet on ILOVEYOU virus. (Oct. 3, 2007)
  • "Worst virus in years infects 6.5 million computers." Jan. 16, 2009. (Oct. 30, 2011)
  • "Mydoom virus floods computers worldwide." Times Online. Jan. 27, 2004 (Oct. 3, 2007),,1-979473,00.html
  • Permeh, Ryan and Maiffret, Marc. "ANALYSIS: .ida "Code Red" Worm." eEye Digital Security. July 17, 2001 (Oct. 3, 2007)
  • Rhodes, Keith A., Chief Technologist, U.S. Government Accounting Office. "Information Security: Code Red, Code Red II, and SirCam Attacks Highlight Need for Proactive Measures" Aug. 29, 2001 (Oct. 5, 2007)
  • Schneier, Bruce. "Gathering 'Storm' Superworm Poses Grave Threat to PC Nets." Oct. 4, 2007. (Oct. 4, 2007)
  • Turner, Dean, Executive Editor, et. al.; "Symantec Internet Security Threat Report: Trends for January-June 07" Sept. 2007. (Oct. 8, 2007)
  • US-CERT advisory on the Melissa virus. Mar. 27, 1999. (Oct. 3, 2007)
  • "Virus Top Twenty for September 2007" Kaspersky Lab. Oct. 1, 2007. (Oct. 8, 2007)
The Ten Worst Computer Viruses