Chapter 5: Malware¶
Malware, or malicious software, is any program designed to damage, steal or gain unauthorised access. The many kinds are distinguished by how they spread, how they hide and what damage they do. This chapter works through ten kinds, from the virus, which needs a person to run it, to fileless malware, which never touches the disk. A table at the end of the chapter compares them side by side.
Layman analogy
Just as the biological world has viruses, worms, parasites, bacteria, and toxins — each with different infection strategies and effects on the human body — computer malware comes in distinct "species," each with different strategies and damage profiles.
5.1 Virus¶
Malicious code that attaches itself to a legitimate file or program. A virus cannot spread on its own — it requires a human action (opening an infected file, running an infected program) to activate and propagate.
Layman analogy
Like a biological virus: it needs a host cell (legitimate file) to exist, and needs you to "touch" it (open the file) to spread to other hosts.
- Attaches to executables, documents (macro viruses), or boot sectors
- Requires human action to propagate: opening email attachment, running infected programme
- Damage: corrupts or deletes files, overwrites boot sector, destroys data
Example 5.1: Virus
ILOVEYOU virus (2000): Arrived as an email with subject "I Love You" and attachment "LOVE-LETTER-FOR-YOU.txt.vbs." When opened, it overwrote image files, music files, and documents, then emailed itself to every contact in the victim's Outlook address book. It spread to 50 million computers in 10 days and caused an estimated $10 billion in damage globally.
5.2 Worm¶
Self-replicating malware that spreads automatically across networks WITHOUT any user action required. Unlike viruses, worms don't need to attach to a host file — they travel independently.
Layman analogy
A biological worm that reproduces on its own and burrows through soil independently. It doesn't need to attach to a host to exist or spread.
- Exploits network vulnerabilities to propagate automatically — no human click required
- Consumes network bandwidth and system resources
- Often drops additional malware payloads, enables backdoors, or forms botnets
Example 5.2: Worm
WannaCry (2017): Exploited the NSA's "EternalBlue" exploit (stolen from the NSA and leaked online) to attack Windows SMB protocol. Self-propagated across 150 countries in hours. Hit the UK's NHS (forcing cancellation of thousands of medical appointments), Spain's Telefónica, and FedEx. Estimated $4 billion in total damages.
5.3 Trojan Horse¶
Malware disguised as legitimate, useful software. Unlike viruses, Trojans don't self-replicate — they rely entirely on user deception to get installed.
Layman analogy
The ancient Greek myth: soldiers hide inside a giant wooden horse presented as a gift. Once the Trojans accept the "gift" inside their city walls, the soldiers emerge and attack from within. On your computer: you accept the "gift" (install the software), and the hidden malware attacks from the inside.
- Disguised as games, utilities, cracked software, fake "security tools," or free applications
- Once installed: creates backdoors, steals credentials, fetches more malware, grants remote access
Example 5.3: Trojan Horse
Zeus Trojan (2007–present): Disguised as various legitimate software, Zeus infected 3.6 million Windows PCs and stole banking credentials through keylogging and form-grabbing. Used to steal over $70 million from US bank accounts before its source code was leaked in 2011. Its code has since spawned dozens of banking malware variants still active today.
5.4 Ransomware¶
Encrypts all the victim's files using strong cryptography, then demands a ransom payment (almost always in cryptocurrency, which is harder to trace) for the decryption key. Modern ransomware often also steals data first and threatens to publish it (double extortion).
Layman analogy
Someone breaks into your house, puts industrial padlocks on every single door, drawer, wardrobe, and cabinet, then leaves a note: "Pay $10,000 in Bitcoin to this address for the master key." Even a skilled locksmith (IT expert) cannot open cryptographic locks without the key.
- Spread via phishing emails with malicious attachments
- Exploit kits targeting unpatched systems
- RDP (Remote Desktop Protocol) brute-force attacks
- Supply chain attacks
Example 5.4: Ransomware
Colonial Pipeline (2021): DarkSide ransomware encrypted systems of the largest US fuel pipeline operator. The company paid $4.4 million in Bitcoin ransom and shut down operations for 6 days, causing fuel shortages, panic buying, and a state of emergency across the US East Coast.
5.5 Spyware¶
Malware that silently monitors all user activity — collecting browsing habits, screenshots, keystrokes, microphone audio, and webcam feeds — and secretly transmits this data to a remote attacker.
Layman analogy
A hidden camera, microphone, and keylogger installed throughout your home, recording everything you do and transmitting a live feed to a complete stranger.
Example 5.5: Spyware
Pegasus spyware (NSO Group): Sold exclusively to governments, used to surveil journalists, human rights activists, lawyers, and political opponents. Could silently activate iPhone and Android microphones and cameras without any user interaction. Exposed in 2021 by Citizen Lab and Amnesty International; found on phones in 50+ countries including those of heads of state.
5.6 Keylogger¶
Records every keystroke a user types on their keyboard, capturing passwords, credit card numbers, private messages, PINs, and any other information typed.
- Software keyloggers — malware installed on the system
- Hardware keyloggers — physical device plugged between the keyboard and the computer (invisible in software scans)
- Acoustic keyloggers — analyse the sound of keystrokes to reconstruct what was typed
Example 5.6: Keylogger
Olympic Vision keylogger: Targeted business executives across 18 countries via spear-phishing emails, stealing banking credentials and wire transfer authorisations. Used to conduct fraudulent wire transfers from corporate accounts.
5.7 Adware¶
Automatically displays intrusive advertisements, hijacks browser settings (home page, search engine, new tab page), slows system performance, and may silently install additional malware in the background.
Example 5.7: Adware
Fireball (2017): Discovered by Check Point, this adware infected 250 million PCs worldwide. It hijacked browsers and turned them into automated advertising click-fraud machines, generating revenue for its operators. It also had the full capability to fetch and execute any code from its command server — essentially a backdoor with a monetisation scheme.
5.8 Botnet¶
A network of malware-infected computers ("bots" or "zombies") all controlled by a central Command-and-Control (C2) server. Infected machine owners typically have no idea their computers are part of the botnet.
Layman analogy
Imagine thousands of people who have been secretly hypnotised. They go about their normal days, but at a signal from the hypnotist, they all simultaneously stop what they're doing and carry out his instructions. The hypnotist (attacker) controls an army without the "soldiers" knowing.
Common botnet uses:
- DDoS attacks — flood targets with traffic from thousands of sources
- Spam campaigns — send millions of phishing emails
- Cryptocurrency mining — use victims' CPU/GPU power to mine crypto for the attacker
- Credential stuffing — test stolen username/password pairs against services
Example 5.8: Botnet
Mirai Botnet (2016): Infected 600,000 IoT devices (security cameras, home routers, DVRs) by exploiting default, unchanged passwords. Launched the then-largest DDoS attack ever at 1.2 Tbps against Dyn DNS, taking down Twitter, Spotify, Netflix, Reddit, and many other major services for millions of users.
5.9 Logic Bomb¶
Malicious code hidden inside an otherwise legitimate programme that remains dormant and activates only when a specific condition is met: a particular date, a specific event, a flag being set, or a trigger action.
Layman analogy
A time bomb hidden inside a building's heating system. It sits there doing nothing for months. On a specific date, or when the temperature reaches a specific value, it detonates.
Example 5.9: Logic Bomb
Stuxnet (2010): Reportedly contained logic that acted only on a very specific target configuration, the controllers of Iranian enrichment centrifuges. This precision meant that systems at other facilities appeared to operate normally.
5.10 Fileless Malware¶
Lives entirely in the computer's RAM memory or Windows registry — never writing a file to disk. Traditional antivirus software scans files on disk; fileless malware never creates any files, making it nearly completely invisible to file-based detection.
Layman analogy
A master thief who enters your home and completes the entire burglary without leaving a single fingerprint, footprint, or physical trace — because they never touch any solid surface and leave before anyone can see them.
5.11 Malware at a glance¶
The ten kinds of malware can be compared on how they spread and what they do.
| Type | How it spreads or arrives | Typical damage | Example from the chapter |
|---|---|---|---|
| Virus | Attaches to a file; needs a person to run it | Corrupts or deletes files, overwrites the boot sector | ILOVEYOU (2000) |
| Worm | Self-replicates across networks, no user action | Consumes bandwidth, drops payloads, opens backdoors | WannaCry (2017) |
| Trojan | Disguised as useful software; the user installs it | Backdoors, data theft, fetches more malware | Zeus |
| Ransomware | Phishing, exploit kits, RDP brute force, supply chain | Encrypts files, demands cryptocurrency | Colonial Pipeline (2021) |
| Spyware | Bundled software, browser extensions, phishing | Silently collects browsing, keystrokes, screenshots, camera | Pegasus |
| Keylogger | Malware, a hardware device or phishing | Records every keystroke | Olympic Vision |
| Adware | Free-software installers, fake browser updates | Intrusive ads, hijacked browser, may install more malware | Fireball (2017) |
| Botnet | Exploit kits, phishing or other malware | DDoS, spam, mining, credential stuffing | Mirai (2016) |
| Logic bomb | Inserted by insiders or other malware | Destructive payload at a set time or condition | Stuxnet |
| Fileless malware | Memory and registry only, nothing on disk | Evades file-based antivirus | (no single example named) |
5.12 Defence tips¶
- Use up-to-date antivirus/antimalware with real-time protection — but know it's not a silver bullet
- NEVER open unexpected email attachments or enable macros in Office documents from unknown senders
- Maintain regular, tested offline backups — the only true defence against ransomware is a clean backup
- Change ALL default passwords on every device, especially smart home (IoT) devices
- Use Endpoint Detection and Response (EDR) for behavioural monitoring that catches fileless malware
- Use application whitelisting to prevent unauthorised software from executing
5.13 Summary¶
- Malware types differ in how they spread (virus needs a person; worm needs no one; trojan relies on deception), how they hide (rootkit, fileless) and what they do (ransomware, spyware, keylogger, adware, botnet).
- Ransomware often steals data first (double extortion), so a clean offline backup is necessary but not always sufficient.
- A botnet is a network of infected machines under one command-and-control server; Mirai built one from default-password IoT devices.
- No single defence works: combine updated antivirus, EDR, whitelisting, tested offline backups and the removal of default passwords.
5.14 Exercises¶
-
State how a virus, a worm and a trojan each spread.
Answer
A virus attaches to a legitimate file and needs a person to run it. A worm replicates itself across networks without any user action. A trojan is disguised as useful software and relies on the user installing it; it does not self-replicate.
-
Why does double extortion mean that backups alone do not defeat modern ransomware?
Answer
The attacker steals the data before encrypting it and threatens to publish it. A backup lets you restore your files but does nothing about the leak, so you still face the threat of exposure.
-
Why does fileless malware evade traditional antivirus, and what detects it?
Answer
It lives in RAM or the registry and never writes a file to disk, whereas traditional antivirus scans files. Endpoint detection and response watches behaviour, such as unusual use of system tools, and can catch it.
-
List four uses of a botnet and say how Mirai recruited its bots.
Answer
DDoS attacks, spam and phishing campaigns, cryptocurrency mining and credential stuffing. Mirai recruited about 600,000 IoT devices (cameras, routers, DVRs) by trying default, unchanged passwords.
-
Classify each as virus, worm, trojan, botnet or ransomware: WannaCry, Zeus, Mirai, DarkSide at Colonial Pipeline.
Answer
WannaCry: worm (it spread through the SMB flaw EternalBlue with no user action). Zeus: trojan (banking credentials stolen by software disguised as legitimate). Mirai: botnet. DarkSide at Colonial Pipeline: ransomware.