• Foundation
  • About 15 min
  • 5 practice questions

How common cyber attacks work: malware, ransomware, DDoS and injection

Describe in plain words how viruses, worms, trojans, spyware, ransomware, denial of service attacks and SQL injection work, and what each one damages.

If something looks wrong, please tell us.

To understand cyber security policy you need a working idea of what attackers actually do. You do not need to write code. You need to know, in one or two sentences, how each common attack works and which security goal it hits. This lesson covers attacks on machines and systems; the next covers attacks that trick people.

Malware: harmful software

Malware (malicious software) is any program written to harm, spy on or take control of a device. The main families differ in how they spread and what they do.

Main malware families
TypeHow it spreads or worksRemember it as
VirusAttaches itself to a file or program and spreads when that file is run or sharedNeeds a host file and usually a user action
WormCopies itself across networks on its own, exploiting flaws, without needing a host fileSelf-spreading
TrojanPretends to be useful software but hides a harmful functionDisguise
Spyware and keyloggersSecretly record activity or keystrokes, such as passwordsSilent watcher
RansomwareEncrypts (locks) files and demands payment for the key; many gangs also threaten to leak copied dataDigital kidnapping
Botnet malwareTurns infected devices into a network of 'bots' controlled remotelyZombie army

Denial of service and DDoS

A denial of service (DoS) attack overwhelms a website or server with so many requests that genuine users cannot get through. When the flood comes from thousands of devices at once - often a botnet of infected computers, cameras or routers - it is a distributed denial of service (DDoS) attack. Nothing is usually stolen; the target is availability. Because the traffic comes from so many places, simply blocking one address does not stop it.

SQL injection: the idea

Many websites store information in databases and use a language called SQL to fetch it. If a website places whatever a visitor types directly into its database commands without checking it, an attacker can type specially crafted text that the database treats as a command. This is SQL injection. It can expose or alter records the attacker should never see. The defence is a design principle: never trust user input - check it and keep it separate from commands.

Zero-day vulnerabilities

A vulnerability is a flaw in software that an attacker can use. A zero-day is a flaw that the software's maker does not yet know about, so no fix (patch) exists. Zero-days are prized by skilled attackers, including state-backed groups. Known flaws, by contrast, are fixed by patches - which is why updating software promptly matters so much.

Worked example 1: identify the attack

Suppose an office finds that a program downloaded as a 'free PDF converter' has been sending staff passwords to an outside server. Working: it pretended to be useful (a trojan) and recorded passwords (spyware or keylogger behaviour). The goal hit is confidentiality. Remedy: remove it, change all passwords from a clean device, and allow software only from trusted sources.

Worked example 2: virus or worm?

Suppose a malicious program spreads overnight to hundreds of computers in a network that nobody used, by exploiting an unpatched flaw. Working: it needed no user to open a file and no host program, and it copied itself across the network. It is a worm, not a virus. Lesson: unpatched systems let worms spread without any human mistake.

Virus needs a host, worm spreads itself, trojan wears a disguise, ransomware locks and extorts, DDoS floods, SQL injection smuggles commands through input boxes.

Key takeaways

  • Malware is any harmful software; its families differ in how they spread and what they do.
  • DDoS attacks use many devices, often a botnet, to block access.
  • SQL injection exploits websites that do not check user input.
  • A zero-day has no patch yet; known flaws are closed by updating.

Check your understanding

  1. 1. Malicious software that spreads across a network by itself, without attaching to a host file or needing a user to open anything, is a:

    1. Virus
    2. Trojan
    3. Worm
    4. Keylogger
    Show answer

    Answer: C. A worm is self-replicating and spreads across networks on its own. A virus needs a host file, a trojan relies on disguise and a keylogger records keystrokes.

  2. 2. A program that looks like a useful free game but secretly opens a back door for attackers is called a:

    1. Trojan
    2. Worm
    3. Botnet
    4. Firewall
    Show answer

    Answer: A. Disguise as something useful is the defining feature of a trojan. A firewall is a defence, not an attack.

  3. 3. In a DDoS attack, the word 'distributed' means that:

    1. The stolen data is distributed on the internet
    2. The attack traffic comes from many devices at the same time
    3. The attacker distributes the ransom among gang members
    4. The malware is distributed through pen drives only
    Show answer

    Answer: B. Distributed denial of service uses many devices, often a botnet, to flood a target. That is why blocking a single source does not stop it.

  4. 4. SQL injection becomes possible mainly when a website:

    1. Uses a very long domain name
    2. Has too many visitors at once
    3. Is hosted outside the country
    4. Places user-typed text directly into its database commands without checking it
    Show answer

    Answer: D. SQL injection exploits unchecked input that the database treats as commands. Checking input and keeping it separate from commands is the defence.

  5. 5. A 'zero-day' vulnerability is one that:

    1. Is fixed on the same day it is reported
    2. Affects a computer for zero days because it is harmless
    3. Is not yet known to the software's maker, so no patch exists
    4. Can only be used on the first day of a month
    Show answer

    Answer: C. Zero-day means the vendor has had zero days to fix it - there is no patch, which makes such flaws valuable to attackers.

Privacy · Terms · Refunds · Delivery