See all Security articles
See all Privacy articles
See all Performance articles
Select language
Select language
Avast Academy Security Viruses The Essential Guide to Computer Viruses

The Essential Guide to Computer Viruses

Computer viruses can steal personal information, damage computer performance, and wreak all kinds of other havoc. Read on to learn how viruses work and how to protect yourself against viruses and other dangerous online threats with a comprehensive security solution like Avast One.

Editors' choice
Editor's choice
Top Rated

What is a computer virus?

There’s lots of information (and misinformation) swirling around online about the term “virus,” so let’s get it straight and define computer virus once and for all: a computer virus is a self-replicating, malicious program or piece of code that sneaks onto your device without your knowledge or permission.

Hamburguer menu icon

This article contains:

    Some viruses are merely annoying, but most viruses are destructive and designed to infect and gain control over your device. A virus can spread across computers and networks by making copies of itself, just like a biological virus passes from one person to another.

    And what about viruses vs. malware? Although many people use the term “virus” to refer to any kind of dangerous program, a virus is just one type of malware (malicious software), which includes any code created to be harmful. For more info about other malware strains to watch out for beyond viruses, check out all our articles on malware.

    How do computer viruses work?

    “Computer virus” is an umbrella term that includes many different types of viruses, delivery mechanisms, and impacts. In defining exactly how computer viruses work, we can split them into two different categories: those that begin to infect and replicate as soon as they land on your computer, and those that lay dormant, waiting for you to trigger them (i.e., waiting for you to unwittingly execute its code).


    Viruses have four phases (inspired by biologists’ classification of a real-life virus’s life cycle).

    • Dormant phase: This is when the virus stays hidden on your system, lying in wait.

    • Propagation phase: Now it’s time for the virus to get viral — it replicates, stashing copies of itself in files, programs, or other parts of your disk. The clones may be slightly altered in an attempt to avoid detection, and they will also self-replicate, creating more clones that continue to copy themselves, and so on and so forth.

    • Triggering phase: A specific action is generally required to trigger or activate the virus. This could be a user action, like clicking on an icon or opening an app. Some other viruses are programmed to come to life after a certain amount of time, such as after your computer has rebooted ten times (this is done to obfuscate the origin of the virus).

    • Execution phase: The “fun” begins. The virus releases its payload, the malicious code that harms your device.

    How do computer viruses spread?

    Computer viruses can spread through several infection mechanisms over the internet. You might get viruses on your computer through:

    • Emails: Cybercriminals’ favorite method, emails can carry harmful attachments (in the form of executable files like EXE or ZIP), malicious links, or even contain an infection right in the body of the message through HTML.

    • Downloads: Hackers can hide viruses in apps, documents sent over file-sharing services, plug-ins, and most other places you can think of where files are available to download.

    • Messaging services: Viruses can be spread through SMS messages or messaging services like Facebook Messenger, WhatsApp, and Instagram. There, as with email, they also take the form of malicious links, attachments, or executable files.

    • Old software: If you haven’t updated your apps or operating system in a while, you almost certainly have vulnerabilities that cybercrooks can exploit to sneak viruses in.

    • Malvertising: Viruses can be hidden in online advertisements, such as banner ads. Malvertising is so insidious because perpetrators can hide their malicious code even in legitimate, trusted websites like The New York Times and the BBC, both of which have been hit.

    Virus removal tools and other techniques can guard you against all of these attack vectors, which we’ll get into a bit later.

    What computer viruses do

    After entering their execution phase and releasing their payload, a computer virus begins its attack, and you’ll start to experience negative impacts on your device. Because viruses hijack your system’s code and resources in order to replicate, you may also notice issues during this phase as well. Look out for the following effects:

    • Sloooowww performance

    • Missing or corrupted files

    • Incessant pop-ups

    • Constant spinning of your hard drive

    • Programs or the operating system freezing and/or crashing

    • Things happening out of nowhere, like apps opening on their own or new files appearing randomly

    Scanning for computer viruses with Avast One.

    Aside from causing these negative performance issues, viruses can also steal sensitive personal data such as usernames, passwords, and credit card details. Some viruses can spam all of your contacts and try to trick them into contracting the virus as well, which is another way they spread.

    Can all devices get viruses?

    To answer this question, we need to go back to the distinction between viruses and malware: recall that a virus is just one type of malware. There are many other computer infections that can damage your device, steal your data, and otherwise wreak havoc.

    All devices, including Macs, iOS, and Android devices can get malware. In fact, any device that can access the internet can get malware, even smart devices like coffee makers!

    From ransomware to spyware to Trojans, there are some nasty strains of malware to watch out for on all your gadgets.

    Types of computer viruses

    Even if we're talking strictly about viruses (as opposed to other forms of malware that don’t self-replicate), there are still many different types of computer viruses.

    Here’s a look at a few examples of computer viruses floating around the internet these days:

    • Direct action virus: The most common type of virus and the easiest to create, direct action viruses enter your computer, cause chaos (usually by attaching themselves to a lot of COM or EXE files), and then delete themselves. The famous Vienna virus searched for COM files to infect and/or destroy them, and while it was the first virus ever to be defeated by an antivirus program in 1987, the fix wasn’t available to those living under communist regimes. In 1988, Avast founder Pavel Baudis also beat the virus and brought the solution to those who couldn’t access the first fix.

    • Boot sector virus: As the name suggests, boot sector viruses sneak into your boot sector (responsible for loading your computer’s operating system upon startup) to infect your memory right away. These types of viruses were traditionally spread through hardware, such as floppy disks, USB drives, and CDs. As these become obsolete, this type of virus is also on its way out, though the Stoner virus of 2014 was one leftover variety — it displayed messages in support of marijuana legalization on screen.

    • Resident virus: Another type of memory-infecting virus, a resident virus will set up shop in your RAM (short-term memory). Its residence in your RAM allows the virus to persist even if you remove the original infector. A notable example was the Magistr virus, which travels to all your friends by spamming your full email contact list. It also deletes tons of files, destroys the memory in your computer’s motherboard, and even writes you rude messages.

    • Multipartite virus: Increasing their power by infecting both your files and your boot space, multipartite viruses are a nasty one. They’re very hard to eradicate because they can hide pieces of themselves in either files or the boot space. The Invader virus was one such example, which began overwriting your hard drive as soon as you hit CTRL+ALT+DEL to try to get rid of it.

    • Polymorphic virus: Another stubborn type, polymorphic viruses hide by changing shape. As they replicate, their clones are all slightly different, which also helps them avoid detection. An example is the VirLock virus, which changes shape while also incorporating a bit of ransomware — it locks up your files and demands you pay to release them.

    • Macro virus: Macro viruses are created to hide inside word document files, such as DOC or DOCX. When you download the file, you’ll be prompted to enable macros — and as soon as you do, you trigger the virus. Infected macros have also been used in ransomware, such as the Locky strain which targeted healthcare institutions, encrypting their files and demanding payment in order to decrypt them again.

    Avoiding the latest computer virus threats

    As with any type of malware, prevention is the best medicine. You can avoid the latest computer virus threats by practicing sensible browsing habits. Here are a few tricks to keep in mind:

    • Have a healthy sense of skepticism: Be vary of special offers, links, or attachments that you weren’t expecting in emails and other messages.

    • Go legit: Don’t try to pirate media like music or movies from file-sharing platforms. You never know what you might get when you download a file from those unverified sources.

    • Be careful even on established stores: While the Google Play Store and Apple App Store monitor their apps for safety, occasionally some malware slips through and manages to infect a few people before it gets taken down. Before downloading something, check that the app is safe.

    • Steer clear of ads and pop-ups: Malvertising can insert viruses or other malicious code into ads, so it’s best to avoid clicking on any type of ads online. If you’re interested in a product you see, go to the company’s website directly.

    • Install updates: The only pop-ups you shouldn’t ignore are notifications about updates from your operating system or other programs. These updates often include security patches that plug vulnerabilities, so it’s important to apply them right away.

    • Add an extra layer of protection: No matter how savvy you are online, viruses can sometimes slip through. Enhance your defenses with a robust antivirus like Avast One, which will act as a safety net that catches viruses before they can even get close to your system.

    If you suspect you might already have a virus or other malware on your system, you can perform a scan and remove it with a free antivirus app. See our guides for more detail about getting rid of any malicious code infecting your devices:

    Signs your device may be infected

    Have you ever had several friends let you know that your email account sent them a suspicious message? That’s one classic sign of a computer virus infection. One of the ways viruses continue to spread is by spamming your full contact list — either by email, text, or other messaging service — to try to trick others into downloading it.

    As mentioned above, there are several other symptoms of a computer virus to look out for, like lots of pop-up windows, device and app crashes or freezes, unexpectedly slow performance, and especially, unexplained changes to your device and/or account settings. A free malware removal tool will monitor your device to detect, block, and remove viruses and other malware in real time.

    Get the ultimate protection against computer viruses

    Thanks to our advanced threat-detection network blocking tens of millions of threats every day, Avast One automatically detects viruses and malware and stops them from ever reaching your computer. And it’ll find and remove all viruses and other malware if any are already on your system.

    Get extra protection against viruses, malicious links, downloads, and unsafe websites so you’re never caught off guard.

    Protect your Android against viruses and malware with Avast One


    Protect your iPhone against malware and data leaks with Avast One