What Is Ransomware? How Attacks Work and How to Stop Them

Ransomware is malicious software that locks you out of your own files or computer and then demands payment to let you back in. Most ransomware encrypts files, scrambling them so they can only be read with a secret key that the attacker holds. The victim is then told to pay, usually in cryptocurrency, for the key.
It is one of the most damaging forms of cybercrime in the world today, and it affects everyone from home users to hospitals, schools, councils and global shipping companies. The UK's National Cyber Security Centre, the NCSC, describes it as a type of malware that prevents you from accessing your computer or the data stored on it, and warns that the data may be locked, stolen, deleted or encrypted. This guide explains how ransomware works, how attacks unfold, whether you should pay, and how to protect yourself.
What is ransomware?
Ransomware is a type of malware, which is short for malicious software. Where an ordinary computer virus might delete files or spy on you, ransomware is built around extortion. It takes something you need and charges you to get it back.
There are two main kinds. Crypto-ransomware encrypts files on a computer or across a whole network, so documents, spreadsheets, databases, photographs and emails become unreadable. Locker ransomware locks the user out of the device itself, so the screen cannot be used at all. In practice, modern attacks usually combine encryption with other threats, which is why the simple picture of a locked screen and a ransom note no longer tells the whole story.
The ransom note is the attacker's message telling the victim what has happened and how to make contact or pay. Victims are usually directed to an anonymous email address or web page and asked to pay in cryptocurrency, most often bitcoin, because it is harder to trace than a bank transfer. The amounts demanded from individuals are often a few hundred pounds or dollars. Demands on businesses and public bodies run into millions.
Ransomware is not a single program written by a single gang. It is now an industry, with developers selling ransomware kits, affiliates carrying out attacks, and brokers selling stolen access to networks. Understanding that business model is the key to understanding why the threat keeps growing.
How does a ransomware attack work?
A ransomware attack is rarely a single event. It is a campaign that unfolds over days or weeks, and the encryption that victims notice is usually the last step, not the first. The NCSC's guidance describes a recognisable sequence.
First comes initial access. Attackers gain a foothold through a phishing email, a stolen password, an exposed remote-access service, or a system that has not been updated. The NCSC's 2023 white paper on ransomware found that most incidents are not the result of sophisticated techniques, and most first break-ins are opportunistic: attackers use whatever weak spot they find.
Second, the attackers establish themselves inside the network. They create accounts or install remote access tools so their access survives a password change, then work towards administrator rights and map the network to find file servers, databases, backups and business-critical systems.
Third, they steal data. In many modern attacks the criminals copy sensitive information out of the network before they encrypt anything. This gives them a second form of leverage, and it is what makes today's attacks far more damaging than the early ones.
Fourth, they destroy the backups. Connected backups and snapshots are deleted or encrypted first, deliberately, to remove the victim's recovery option. This is why the NCSC stresses that backups must be kept offline or in a form that cannot be changed by an attacker.
Finally comes the encryption itself, usually carried out across the whole network at once, often out of hours to delay detection. Files lock, systems stop working, and the ransom note appears on infected screens.
Double extortion and ransomware as a service
Two developments have changed ransomware more than any other in recent years. The first is double extortion. In a double-extortion attack, criminals do not rely only on encryption. They also steal data and threaten to release it if the victim refuses to pay. Restoring files from backup solves the first problem and does nothing about the second: the victim's private records can still be published or sold. Some groups go further, threatening to contact customers, regulators or the media, which is sometimes called triple extortion. The NCSC notes that some groups now skip encryption altogether and only steal data and extort.
The second development is ransomware as a service. Under this model, a group offers an online portal where affiliates, effectively customers, can customise the ransomware and launch attacks, usually in exchange for a share of the ransom. The developers provide the malware and the payment infrastructure; the affiliates provide the targets. This has lowered the skill needed to carry out an attack and is a large part of the reason ransomware has become so common.
How does ransomware get in?
Almost every successful attack starts through one of a small number of routes, and closing those routes removes most of the risk.
Phishing emails are the most common entry point. A user receives an email with a malicious attachment, often a document with an embedded macro, or a link to a malicious page. Opening it downloads and runs the payload. The emails are often carefully written to look like invoices, delivery notices or messages from a senior colleague.
Stolen credentials are the second route. Usernames and passwords leak in data breaches, are guessed when they are weak, or are bought from brokers who specialise in selling access to corporate networks. If there is no second check on a login, a stolen password alone can be enough.
Exposed remote access is the third. Remote desktop services and virtual private networks left open to the internet, especially without multi-factor authentication, are a favourite target. The Colonial Pipeline attack in 2021 began with a single old VPN account whose password had leaked and which had no multi-factor authentication.
Unpatched software is the fourth. Attackers scan the internet for systems with known vulnerabilities and exploit them automatically. WannaCry in 2017 spread through Windows computers that had not received a security update that had been available for weeks.
Famous ransomware attacks
Three attacks explain how ransomware grew from a nuisance into a national security issue.
WannaCry, May 2017. On 12 May 2017, WannaCry spread around the world by exploiting a vulnerability in Microsoft Windows. Europol counted more than 200,000 infected computers in at least 150 countries within days. In England, the National Audit Office found that at least 81 of 236 NHS trusts were affected, and around 19,000 appointments were cancelled. Hospitals had to divert ambulances and cancel operations. The attackers demanded about 300 to 600 dollars in bitcoin per computer. The outbreak was slowed when a security researcher found a built-in kill switch in the code. No NHS organisation paid a ransom.
NotPetya, June 2017. Weeks later, NotPetya spread through a compromised update of Ukrainian tax software and hit companies around the world, including the shipping giant Maersk, where it affected about 45,000 computers in ten days. Unlike WannaCry, NotPetya appeared designed to destroy data rather than to collect ransoms, and many victims found that paying could not restore their files at all.
Colonial Pipeline, May 2021. The DarkSide group entered the largest fuel pipeline in the United States through a disused VPN account with an exposed password and no multi-factor authentication. Colonial shut its pipeline down for six days, disrupting fuel supplies across the east coast of the United States and triggering panic buying. The company paid a ransom of about 4.4 million dollars in bitcoin. The US Department of Justice later recovered about 2.3 million dollars of the payment. The attack showed that a billing-system compromise could halt physical infrastructure.
The scale of the problem is still growing. The NCSC's Annual Review, published on 3 November 2026, reported 1,831 cyber attack reports in the year to August 2026, of which 337 required support from its incident management team and 80 were assessed as nationally significant. The NCSC also notified around 8,500 organisations of activity suggesting a possible compromise. The government's Cyber Security Breaches Survey found that 1 percent of UK businesses experienced a ransomware attack in the last year, down from 3 percent in each of the two preceding years, but the NCSC warns that most successful compromises still involve known vulnerabilities in internet-facing systems, stolen credentials and social engineering.
Should you pay the ransom?
The official advice in the UK is clear. The NCSC and the National Crime Agency advise against paying, and law enforcement does not encourage, endorse or condone the payment of ransom demands. The NCSC gives several reasons. Payment does not guarantee a working decryption key, and decryption tools are frequently slow and incomplete. Payment does not prevent stolen data from being published or sold, and some organisations have been extorted a second time after paying. And payment funds crime, encouraging further attacks.
There is also a practical problem. If the attackers have stolen personal data, the incident is a personal data breach whether or not any money changes hands, and the Information Commissioner's Office, the UK data protection regulator, may need to be told. Paying quietly does not make the regulatory problem go away.
Some victims pay anyway, usually because they have no usable backups and face the collapse of their business. That is a decision for the victim, ideally taken with advice from law enforcement and from cyber incident specialists. But anyone considering it should understand that it is a gamble, not a purchase: there is no guarantee of getting the data back, and no guarantee the criminals will keep their word.
How to protect yourself against ransomware
The NCSC's guidance on mitigating malware and ransomware attacks sets out a defence in depth approach: layers of defence, with several mitigations at each layer, because there is no way to completely protect an organisation against infection. The most effective measures are not exotic.
Backups come first. Make regular backups of your most important files, keep copies offline and separate from your network, ideally offsite, and regularly test that you can restore from them. The 3-2-1 rule the NCSC describes means at least three copies of important data, on two different devices, with one copy offsite. An untested backup is an assumption, not a control, and ransomware actively targets backups to increase the likelihood of payment.
Multi-factor authentication comes second. Enable it on all remote access and cloud services, so a stolen password alone is not enough to get in. Remove or protect exposed remote desktop services, and use a virtual private network that meets NCSC recommendations for remote access.
Patching comes third. Apply security updates promptly, especially to internet-facing systems. WannaCry only succeeded because so many computers had missed an available update.
Training and filtering come fourth. Filter email attachments and block known malicious websites, and train staff to recognise phishing. Endpoint detection and response tools, monitored by people who can act on alerts, can catch an attack in the window between initial access and encryption, which is often days or weeks.
Finally, prepare for an incident before it happens. Have a rehearsed response plan, know who to call, and know how you would keep operating if your systems were unavailable. The NCSC provides a Small Business Guide to Response and Recovery for smaller organisations.
What to do if you are hit by ransomware
The NCSC's first advice is to disconnect infected computers, laptops and tablets from the network immediately, to stop the infection spreading. Do not turn the machines off before taking advice if you can avoid it, because that can destroy evidence, but do isolate them.
Report the crime. In the UK, the National Crime Agency encourages anyone who believes they have been the victim of online fraud to contact Action Fraud. If personal data has been stolen, consider whether the Information Commissioner's Office needs to be notified. Keep copies of the ransom note and of any communications with the attackers, and do not delete logs.
Do not pay in haste. Seek advice from law enforcement and from the NCSC's incident guidance first. If you have offline backups, restoring from them is usually faster and safer than negotiating with criminals, although you will still need to check that the attackers are fully removed from your systems before you restore, or they may simply encrypt the restored data again.
Frequently asked questions
Can ransomware infect a phone? Yes, although phones are less commonly targeted than computers. Mobile ransomware usually locks the screen and demands payment, often through a fake law enforcement message. Keeping your phone updated and installing apps only from official stores reduces the risk.
Is ransomware illegal? Yes. Creating it, spreading it and extorting money with it are criminal offences in the UK and in most other countries. Paying a ransom is not itself generally a criminal offence in the UK, but the NCSC and the National Crime Agency advise against it, and paying a sanctioned group or individual could breach sanctions law, so victims should take advice first.
Can antivirus stop ransomware? Antivirus helps, but it is not enough on its own. Modern ransomware often arrives through stolen credentials or unpatched systems rather than through a file that antivirus can catch. Backups, multi-factor authentication and patching matter at least as much.
What is the difference between ransomware and a virus? A virus is a type of malware that spreads by attaching itself to other files. Ransomware is a type of malware defined by its purpose: extortion. Some ransomware spreads like a virus, as WannaCry did, but many attacks are carried out by people working inside a network by hand.
How long does recovery from ransomware take? It varies enormously. A home user with good backups can recover in hours. A large organisation can take weeks or months, because every system must be checked, cleaned and rebuilt, and stolen data may have to be dealt with separately. The Colonial Pipeline shutdown lasted six days, but recovery and investigation continued long after the pipeline restarted.
Sources: National Cyber Security Centre, Mitigating malware and ransomware attacks; Guardey, 12 Ransomware Examples: Real Attacks and Their Lessons; NCSC Annual Review 2026.