Lesson 1 of 3 Malicious Code and Activity

Malware Types

Malicious software comes in many forms, and recognising each type from its behaviour helps practitioners respond correctly. This lesson explains viruses, worms, trojans, rootkits, spyware, scareware, ransomware, backdoors and trapdoors, fileless malware, and the code and mobile code vulnerabilities malware exploits.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify malware types from their behaviour.
  • Explain rootkits, backdoors and trapdoors.
  • Explain fileless malware and living off the land.
  • Identify the vulnerabilities malware exploits.

What malware is

Malware (malicious software) is any software designed to harm systems, steal information, gain unauthorised access or otherwise act against the interests of its users. Malware is classified by how it spreads (its propagation), what it does (its payload) and how it hides. A single piece of malware often combines several types: a trojan may install a rootkit and a backdoor, then download ransomware.

Self-replicating and disguised malware

A virus attaches itself to a host, such as an executable file, a document macro or a disk boot sector, and spreads when the host is run or opened, usually through user action. Variants include macro viruses in office documents, boot sector viruses, polymorphic viruses that change their code with each infection to evade signatures, and multipartite viruses that use several infection methods.

A worm is self-propagating: it spreads across networks on its own by exploiting vulnerabilities or weak credentials, without needing a host file or user action, so it can spread extremely fast. WannaCry in 2017 combined a worm, which exploited a Windows SMB vulnerability, with ransomware.

A trojan (Trojan horse) disguises itself as legitimate or desirable software, such as a free utility, a game crack or a fake invoice attachment. It does not replicate; users install it themselves. A remote access trojan (RAT) gives the attacker remote control of the system.

Match the pairs

Malware types

Exam skills 7.1.1

Match each malware type with its description.

Log in to try this activity Interactive activities are free with an account.

Hiding, spying and extorting

A rootkit conceals its presence and that of other malware, and maintains privileged access. User-mode rootkits alter programs and libraries; kernel-mode rootkits modify the operating system kernel, so the system itself lies to security tools; bootkits and firmware rootkits infect the boot process or device firmware and can survive reinstalling the operating system. Rootkits are detected by scanning from outside the running system, integrity checking, secure and measured boot, and they are usually removed by rebuilding, sometimes including reflashing firmware.

Spyware collects information without consent: keyloggers record keystrokes, info-stealers harvest saved passwords, browser cookies and cryptocurrency wallets, and stalkerware tracks individuals. Adware displays unwanted advertising. Scareware displays fake security alerts ("your computer is infected, call this number") to frighten users into paying for useless software, installing malware or giving remote access.

Ransomware encrypts files or whole systems and demands payment for the decryption key. Modern ransomware groups first steal data and threaten to publish it (double extortion), may threaten DDoS or contact customers, and often operate as ransomware-as-a-service, with affiliates carrying out intrusions. Ransomware attacks availability and, with data theft, confidentiality.

Backdoors, trapdoors and fileless malware

A backdoor is a hidden method of bypassing normal authentication to access a system. Attackers install backdoors, such as web shells or extra accounts, to keep access after the initial compromise. A trapdoor, sometimes called a maintenance hook, is a hidden entry point written into software by its developers, for example for debugging, that was never removed. Both are found through code review, integrity monitoring and examination of unusual accounts and services. A logic bomb is malicious code that triggers when a condition is met, such as a date or a particular employee being removed from the payroll.

Fileless malware runs in memory and uses legitimate built-in tools, such as PowerShell, Windows Management Instrumentation (WMI), scripting engines and administrative utilities, an approach called living off the land. Because there may be no malicious file to scan and the tools are trusted, traditional antivirus often misses it. Detection relies on behaviour monitoring, script logging (such as PowerShell script block logging), EDR and restricting which tools users can run.

The following diagram traces a fileless malware attack chain and the controls that break it.

Fileless malware living off the land. A Word document launches PowerShell, which downloads and runs code in memory and connects to an external server, so disk scans find nothing. Blocking macros in internet documents, restricting PowerShell, enabling script block logging and EDR behaviour rules address it.
The scenario is illustrative.
True or false

Backdoors and fileless malware

Exam skills 7.1.1

Check facts about backdoors and fileless malware.

Log in to try this activity Interactive activities are free with an account.

Vulnerabilities that malware exploits

Malware usually needs a way in. The outline lists the main categories of vulnerability.

Application vulnerabilities
Flaws in installed software, such as browsers, document readers and server applications, exploited by malicious documents, websites or network requests.
Code vulnerabilities
Programming errors such as buffer overflows, injection flaws and insecure deserialisation, introduced during development.
Operating system vulnerabilities
Flaws in the OS kernel and services, often used for remote exploitation or privilege escalation.
Mobile code vulnerabilities
Weaknesses in code downloaded and run automatically, such as JavaScript in web pages, browser extensions, document macros and, historically, Java applets and ActiveX controls.
Mobile device vulnerabilities
Flaws in phone operating systems and apps, malicious apps from unofficial stores, and jailbroken or rooted devices that disable built-in protections.

Patching, secure development, disabling or restricting macros and mobile code, and allowing only trusted applications close most of these paths. The following table summarises the malware types.

TypeDefining behaviour
VirusAttaches to a host and spreads when the host runs
WormSpreads by itself across networks
TrojanDisguised as legitimate software
RootkitHides itself and keeps privileged access
SpywareCollects information without consent
ScarewareUses fake alerts to frighten users
RansomwareEncrypts or steals data for payment
Backdoor or trapdoorHidden way to bypass authentication
Fileless malwareRuns in memory using legitimate tools
Worked example

Name the malware

Within an hour, malware infects 2,000 servers across a company's network. No users opened files; the malware exploited an unpatched network service on each server. What type is it, and what does that mean for containment?

It is a worm: it propagates by itself through a network vulnerability without user action. Containment must be fast and network-wide: block the exploited service's port between segments, isolate infected hosts, and patch or disable the vulnerable service everywhere, because the worm will keep spreading to any unpatched system it can reach.

Worked example

Nothing on disk

EDR shows a Word document launching PowerShell, which downloads and runs code in memory and then connects to an external server. Antivirus scans of the disk find nothing. What is this, and which controls help?

This is fileless malware delivered by a malicious document, living off the land with PowerShell. Helpful controls are blocking macros from internet-sourced documents, restricting PowerShell (constrained language mode, allow listing), enabling script block logging, attack surface reduction rules that stop Office applications launching child processes, and EDR behaviour detection, which found it.

Check yourself

What is a logic bomb?

Show answer

Malicious code that triggers when a condition is met, such as a date or an event like a particular employee being removed from the payroll.

Exam Tips

Remember for the exam

  • Worms self-propagate; viruses need a host and usually user action; trojans are disguised.
  • Rootkits hide and may survive OS reinstalls; rebuild, including firmware if needed.
  • Fileless malware evades file scanning; behaviour-based detection and script controls help.