Cybersecurity

Types of Malware Explained: Viruses, Trojans, Spyware and More

A reference guide to the common types of malware, how each one spreads, what it does and the warning signs to watch for.

Quick answer

The main types of malware are viruses, worms, trojans, ransomware, spyware, adware, keyloggers, infostealers, rootkits, botnets, remote access trojans, cryptojackers, wipers and fileless malware. They differ in how they spread and what they do, from encrypting files for ransom to stealing passwords. Most arrive through phishing, malicious downloads or unpatched software.

Types of Malware Explained: Viruses, Trojans, Spyware and More

Photo: Unsplash

On this page

“Malware” gets used as a catch-all for anything bad that happens to a computer. That’s fair, since the word is short for malicious software. But the different types behave very differently. A virus that corrupts files, a trojan hiding in a fake invoice and an infostealer quietly copying saved passwords call for different responses.

Knowing the main types helps you recognize warning signs, understand what your security tools are doing and talk clearly with your IT provider when something looks wrong. This guide covers each common type, how it spreads, what it does and how to protect against it.

What counts as malware

NIST defines malware as software or firmware intended to perform an unauthorized process that will harm the confidentiality, integrity or availability of a system. In plain terms, it’s any program designed to do something to your device or data that you didn’t agree to.

Malware types are often grouped in 2 ways:

  • How it spreads: viruses attach to files, worms spread on their own, and trojans trick you into installing them.
  • What it does once inside: ransomware encrypts, spyware watches, infostealers take credentials, botnets recruit your device.

Many modern attacks combine several types. A trojan might install an infostealer, which steals a password that later lets an attacker deploy ransomware.

Malware types at a glance

Use this table as a quick reference.

Type How it spreads What it does Warning signs
Virus Attaches to files or programs; spreads when they’re opened or shared Corrupts or deletes files, can carry other malware Files changing or failing to open, crashes
Worm Spreads on its own across networks by exploiting flaws Rapid spread, network slowdown, often delivers other payloads Sudden network slowdown, many devices affected at once
Trojan Disguised as legitimate software, attachments or updates Opens the door for other malware or remote access New programs you didn’t intend to install
Ransomware Phishing, stolen credentials, exposed remote access, other malware Encrypts files and often steals data, then demands payment Files renamed or unreadable, ransom note
Spyware Bundled apps, malicious links, physical access Monitors activity, location, messages Unexplained data use, battery drain, settings changes
Adware Bundled with free software, browser extensions Floods you with ads, redirects searches Pop-ups, changed home page, new toolbars
Keylogger Trojans, malicious downloads Records keystrokes, including passwords Often none; accounts accessed unexpectedly
Infostealer Fake software, cracked apps, malicious ads Steals saved passwords, browser cookies, crypto wallets Logins from unknown locations, accounts taken over
Rootkit Installed by other malware with high privileges Hides malware deep in the system Security tools disabled, persistent problems after cleanup
Botnet malware Worms, trojans, weak passwords on IoT devices Turns devices into a remote-controlled network for attacks or spam Slow device or network, unusual outbound traffic
Remote access trojan (RAT) Phishing attachments, fake apps Gives an attacker full remote control Mouse moving on its own, webcam light on unexpectedly
Cryptojacker Malicious websites, compromised software, cloud misconfigurations Uses your computing power to mine cryptocurrency Fans running hard, high CPU use, rising cloud bills
Wiper Delivered like ransomware, often in targeted attacks Permanently destroys data Data deleted or systems unbootable
Fileless malware Exploits, malicious scripts, built-in system tools Runs in memory using legitimate tools, leaving few files Hard to spot; unusual script or admin tool activity

How the main types behave

Viruses and worms: the classics

A virus is code that attaches itself to a legitimate file or program and runs when that file is opened. It needs a person to spread it, for example by sharing an infected file. True file-infecting viruses are less common today than they were, but the word is still used loosely for all malware.

A worm spreads by itself, usually by exploiting a vulnerability in software that’s reachable over a network. That makes worms fast and dangerous. The 2017 WannaCry outbreak combined ransomware with a worm that spread through a Windows file-sharing flaw. According to CISA, Microsoft had released a patch for that flaw in March 2017, before the outbreak began in May. Unpatched systems were the ones hit.

Trojans, RATs and loaders: malware in disguise

A trojan pretends to be something useful, such as a PDF invoice, a software update, a game mod or a free version of a paid app. Once you run it, it does something else entirely.

Common trojan variations include:

  • Remote access trojans (RATs) that give an attacker control of your machine.
  • Loaders or droppers whose only job is to download more malware later.
  • Banking trojans that target online banking sessions.

Trojans rely on trust, so the best defenses are caution about downloads and attachments, and installing software only from official sources.

Ransomware and wipers: malware that hits operations

Ransomware encrypts your files and demands payment for the key. Most modern groups also steal data first and threaten to publish it, so backups alone don’t remove all the risk. It typically gets in through phishing, stolen passwords, exposed remote desktop or unpatched internet-facing devices. Our guide to ransomware protection for small business covers prevention and response in detail.

Wipers look similar but destroy data with no way to recover it, even if a ransom is paid. They’re more common in targeted or state-linked attacks.

Key takeaway: Ransomware is usually the last step of an attack, not the first. Phishing, stolen passwords and unpatched systems are how attackers get in, so blocking those stops most ransomware before it starts.

Spyware, keyloggers and infostealers: malware that watches and steals

Spyware monitors what you do: browsing, messages, location or microphone. On phones, a specific kind called stalkerware is often installed by someone with physical access. See how to tell if your phone is hacked for signs and cleanup steps.

Keyloggers record every keystroke, capturing passwords and messages.

Infostealers have become one of the most damaging types for businesses. They grab saved browser passwords, session cookies and other credentials in seconds, often from a single download of fake or cracked software. Stolen session cookies can let attackers skip MFA by reusing a logged-in session. If an infostealer hits a device, change passwords from a clean device and sign out of all sessions. Our data breach checklist walks through the account steps.

Adware, cryptojackers, rootkits and botnets

  • Adware shows unwanted ads and redirects your searches. It’s often more annoying than dangerous, but some adware tracks browsing and opens the door to worse.
  • Cryptojackers quietly use your computer or cloud account to mine cryptocurrency. On cloud accounts, the first sign may be a surprise bill.
  • Rootkits bury themselves deep in the operating system, sometimes below it, to hide other malware from security tools. They often require a full reinstall to remove.
  • Botnet malware enlists devices into a network controlled by an attacker, used for spam, password attacks or flooding websites with traffic. Poorly secured routers, cameras and other connected devices are frequent recruits, which is why changing default passwords matters.

Fileless malware: hiding in plain sight

Fileless malware runs in memory and abuses legitimate built-in tools, such as scripting engines and admin utilities, instead of dropping obvious files. Because there’s little on disk to scan, traditional antivirus may miss it. Endpoint detection and response (EDR) tools that watch behavior, rather than just files, are better at catching it.

How to protect against all types of malware

The same core controls defend against nearly every type on this list.

  1. Keep everything updated, including operating systems, browsers, apps, routers and firmware. Turn on automatic updates.
  2. Use reputable endpoint protection, ideally with behavior-based detection. Built-in tools such as Microsoft Defender on Windows are a solid baseline.
  3. Turn on MFA everywhere, and use a password manager instead of saving passwords in the browser on shared or high-risk devices.
  4. Install software only from official sources and avoid cracked or pirated programs.
  5. Treat attachments and links with caution, especially unexpected invoices, shipping notices and urgent requests.
  6. Limit admin rights so everyday accounts can’t install software or change system settings.
  7. Back up with the 3-2-1 rule and keep at least 1 copy offline. Test restores.
  8. Change default passwords on routers, cameras and other connected devices.

What to do if you suspect malware

The FTC’s advice for a suspected infection starts with stopping sign-ins to sensitive accounts, then updating and running your security software, then changing passwords and turning on 2-factor authentication. For a business:

  1. Disconnect the device from the network, but don’t wipe it yet if you may need to investigate.
  2. Tell your IT provider or security contact right away.
  3. Change passwords for accounts used on that device, from a different, clean device.
  4. Scan and clean, or reinstall the system if the infection is serious or a rootkit is suspected.
  5. Check for spread to other devices and accounts.
  6. Report serious incidents to the FBI’s IC3 or CISA.

The bottom line

Malware comes in many forms, but most of it gets in the same few ways: phishing, risky downloads, stolen passwords and unpatched software. Learn the types so you recognize the signs, then focus your energy on updates, MFA, careful downloads, limited admin rights and tested backups. For a broader view of how these defenses fit together, start with our guide to what cybersecurity is.

Sources

Questions readers ask

Frequently asked questions

What are the most common types of malware?

The most common types include trojans, ransomware, spyware, adware, infostealers, worms and viruses. Trojans and infostealers are especially widespread because they arrive through convincing downloads and phishing. Ransomware does the most visible damage to businesses. Many attacks chain types together, such as a trojan that installs an infostealer, which then leads to ransomware.

What is the difference between a virus and malware?

Malware is the umbrella term for all malicious software. A virus is one specific type that attaches itself to a legitimate file or program and spreads when that file is opened or shared. People often say "virus" for any infection, but worms, trojans, ransomware and spyware are all different kinds of malware with different behavior.

What is the difference between a worm and a trojan?

A worm spreads on its own across networks by exploiting software vulnerabilities, without anyone clicking anything. A trojan doesn't spread by itself. It tricks you into installing it by pretending to be something legitimate, such as an invoice or software update. Worms are stopped mainly by patching; trojans mainly by caution and download controls.

Can malware infect phones?

Yes. Phones can get spyware, adware, banking trojans and stalkerware, usually through malicious apps, phishing links or someone with physical access. iPhones and Android phones have strong built-in protections, so keeping them updated and installing apps only from official stores prevents most infections. Account takeovers are more common than true phone malware.

Does antivirus protect against all malware?

No tool catches everything. Modern endpoint protection, including built-in tools like Microsoft Defender, blocks most known malware and some new threats through behavior detection. Fileless malware, new variants and social engineering can still get through. Combine antivirus with updates, MFA, limited admin rights, careful downloads and offline backups.

How do I know if my computer has malware?

Warning signs include slowdowns or crashes, pop-ups, a changed browser home page, new toolbars or programs you didn't install, security tools that are turned off, and emails or posts sent from your accounts that you didn't write. Some malware, like infostealers and keyloggers, shows no signs at all, so watch for unexpected account logins too.

What should I do if I click a malicious link?

Disconnect from the network if you downloaded or ran anything, and don't enter any passwords. Run a full scan with up-to-date security software. If you typed a password on the page, change it immediately from a clean device and turn on MFA. At work, report it to your IT team right away, because fast reporting limits damage.

Reader reviews

Was this guide useful

No reviews yet. Share your experience and help other readers.

Write a review
Your rating
Never shown publicly

Reviews are checked before they appear. We never show your email. Please review only places or services you have used.

Manishdai
Written by

Manishdai

Manishdai writes about the technology that is reshaping every industry — from AI agents and cloud platforms to healthtech, fintech and the IT companies building it all across the United States.