Malware Explained: Viruses, Worms, Trojans and More
Learn how the main kinds of malware differ, how each one gets onto a device, what it does there and how to block it.
Key takeaways
- A virus attaches itself to other files, a worm spreads over networks on its own, and a trojan relies on you to run it because it looks like something useful.
- Most modern malware is built to make money through theft, extortion, fraud or renting out the infected machine.
- The common ways in are unpatched software, tricked users, stolen passwords and downloads from untrustworthy places.
- Updates, limited privileges, careful installing and offline backups block or contain most infections.
- If you suspect an infection, disconnect the device, and change important passwords from a different, clean one.
Malware is any software built to act against the interests of the person who owns the device it runs on. The familiar names, such as virus, worm and trojan, mostly describe how the code spreads. Other names, such as ransomware or spyware, describe what it does once it arrives.
Those two ideas are separate, which is why one sample can be a trojan, a spy and a downloader all at once. If you keep "how it gets in" apart from "what it wants", the vocabulary stops being confusing and the defenses start to make sense.
Spreading styles: viruses, worms and trojans
A virus is code that inserts itself into another program, document or boot area and runs when that host runs. It needs a carrier and usually some human action, such as opening the infected file or passing it to someone else. Classic viruses infected executable files on floppy disks. Macro viruses later hid inside office documents, which is why office suites now block or warn about macros in files from the internet.
A worm is a standalone program that copies itself from machine to machine across a network without waiting for anyone to click. It typically exploits a flaw in a network service or tries weak passwords. The Morris worm of 1988 showed early on how quickly this can disrupt connected computers, and the WannaCry outbreak in 2017 spread through a Windows file-sharing flaw that already had a patch available.
A trojan (short for Trojan horse) pretends to be something you want: a free game, a cracked application, a video player update, an invoice. It does not need to spread itself because you install it. Today this is by far the most flexible disguise, since it works against any system where the user has permission to run new software.
Payloads: what malware does once inside
The payload is the part that does the damage or earns the money. A single infection often delivers several, one after another.
- Ransomware encrypts files or whole systems and demands payment. See how ransomware works for the full chain.
- Infostealers collect saved passwords, browser cookies and wallet files, then send them out within minutes. Their quietness is covered in the guide to infostealers.
- Banking trojans watch for visits to financial sites and try to capture logins or alter transactions.
- Spyware monitors activity, location or messages. When installed by someone close to the victim it is often called stalkerware.
- Keyloggers record what you type.
- Remote access trojans give an operator hands-on control: files, screen, camera and microphone.
- Adware and hijackers inject ads or redirect searches. They are less dangerous but often arrive bundled with worse things.
- Cryptominers use your processor and electricity to mine cryptocurrency for someone else.
- Bot agents enlist the device into a botnet that sends spam or floods websites with traffic.
A downloader or dropper is a small first stage whose only job is to fetch or unpack the real payload. This lets criminals swap in whatever pays best that week, and sell access to infected machines to others.
Hiding and staying put
Malware that is removed at the next restart is not very useful to its owner, so most of it sets up persistence: a startup entry, a scheduled task, a service, a browser extension or a changed system setting that relaunches it.
A rootkit goes further by hiding files, processes or network connections from the operating system's own tools, sometimes by loading code deep in the system. A bootkit loads before the operating system does. Features such as Secure Boot, which checks the signatures of startup software, exist largely to make this harder.
Fileless malware is a loose term for attacks that live mainly in memory or lean on legitimate built-in tools such as scripting engines. There is little or no obvious malicious program on disk, so defenses have to watch behavior and not only scan files.
Attackers also change the packaging of their code constantly so that yesterday's fingerprint no longer matches. That is why modern security software combines known signatures with reputation checks and behavior monitoring.
How it gets onto your device
Nearly every infection starts through one of a handful of doors.
- You are persuaded to run something. Phishing attachments, fake update pop-ups, pirated software and look-alike download pages all fit here.
- A flaw is exploited. An out-of-date browser, document reader, router or server accepts a crafted file or request and runs the attacker's code.
- Someone signs in with your credentials. Exposed remote access services protected by weak or reused passwords are a favorite.
- A trusted supplier is compromised. A legitimate update, package or extension carries the malicious code, as explained in supply chain attacks.
- Physical access. Someone with the unlocked device installs it, or an unknown storage device is plugged in.
A newer variation asks you to do the attacker's work: a web page claims something is broken or that you must prove you're human, then tells you to paste a command into a terminal or run dialog. No genuine website needs you to do that. Close the page.
Warning signs and their limits
Possible symptoms include security software that has been switched off, new programs or browser extensions you don't remember adding, a changed search engine or home page, unexplained processor or network activity, ransom notes, renamed files, and contacts receiving messages you didn't send.
None of these proves an infection. A slow laptop usually has an ordinary cause. The reverse matters more: well-made malware, especially a credential thief, may show no symptoms at all. Sometimes the first clue is a sign-in alert from an account somewhere else.
To check a Windows machine, look at the Startup apps list in Task Manager and the installed apps list in Settings. On macOS, review Login Items in System Settings. On any computer, review browser extensions. On phones, look through installed apps and which ones hold accessibility or device administrator rights. Menu names vary by version.
Defenses that actually matter
No single product stops everything, so stack several modest habits.
- Update promptly. Turn on automatic updates for the operating system, browser, apps and router. Updates close the holes worms and drive-by attacks depend on.
- Install from reliable sources. Use official app stores or the maker's own site, and skip cracked software entirely.
- Use a standard account for daily work where practical, so a mistake can't change the whole system without a prompt.
- Keep built-in protection on. For most home users the question of whether you still need extra antivirus depends on how you use the device.
- Handle links and files carefully. A few habits with attachments remove a large share of the risk.
- Protect accounts with unique passwords and a second factor, so one leak does not open everything.
- Back up, with at least one copy disconnected or protected from changes. See the 3-2-1 backup rule.
If you think you're infected
Disconnect the device from the network to stop data leaving and to protect other machines. On a work computer, call your IT or security team before doing anything else, because wiping or restarting can destroy evidence they need.
On a personal device, run a full scan with up-to-date security software, and consider an offline or boot-time scan if your system offers one. For serious infections, particularly remote access tools, rootkits or anything that stole credentials, the dependable fix is to back up personal files, erase the device and reinstall from official media.
Then deal with the accounts. From a clean device, change the password on your email first, then banking and anything important, and sign out all other sessions. The longer checklist is in what to do if you've been hacked.
Common questions
Can Macs, Linux machines and phones get malware?
Yes. Every general-purpose system can run hostile software. The volume and typical methods differ between platforms, and phones restrict apps more tightly than desktops do, but none of them is immune.
Is a suspicious file safe if I only open it to look?
Not necessarily. Programs and scripts run code by design, and documents or images can sometimes exploit flaws in the software that displays them. If you don't expect a file, verify it with the sender through a separate channel first. A file's checksum can confirm that a download matches what a publisher released, though only if you got the checksum from a trustworthy place.
Is a virus the same thing as malware?
In everyday speech, often. Technically a virus is one subtype. "Malware" is the umbrella term, and most of what circulates today would be classed as trojans of one kind or another.