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

Ransomware is one of the most damaging cyber threats a business can face. Within a few hours it can lock the files on every computer and server in an office, stop production, sales and payroll, and leave the owner with a very expensive decision.
The good news is that most attacks follow the same pattern and exploit the same weaknesses. A small set of well-chosen defences stops the majority of them, and good backups turn a disaster into an inconvenience. This guide explains what ransomware is, how an attack unfolds, how to prevent one, and exactly what to do if you are hit.
What is ransomware?
Ransomware is malicious software that blocks access to your data, usually by encrypting it, and then demands a payment (the ransom), normally in cryptocurrency, in exchange for the key that unlocks it.
The encryption it uses is the same strong cryptography that protects online banking. Without the attacker's key the files cannot realistically be recovered, which is why prevention and backups matter so much.
The main forms you will hear about:
- Crypto ransomware encrypts documents, databases, images and backups, renames them with a new extension and leaves a ransom note. This is the most common type.
- Locker ransomware locks the whole screen or device instead of encrypting individual files.
- Double extortion: attackers first steal a copy of your data and then encrypt it. If you restore from backup and refuse to pay, they threaten to publish or sell what they stole. Most large ransomware groups now work this way.
- Ransomware-as-a-Service (RaaS): developers rent their ransomware to "affiliates" who carry out the attacks and share the profit. This business model is a big reason attacks are so common: an attacker no longer needs to write any malware.
Famous attacks and what they teach
WannaCry (May 2017) spread by itself from computer to computer through a flaw in the old Windows file-sharing protocol SMBv1. Microsoft had released the fix (MS17-010) two months earlier. WannaCry hit more than 200,000 computers in around 150 countries, including hospitals in the UK's National Health Service. Lesson: install security updates quickly and switch off outdated protocols.
NotPetya (June 2017) arrived through a hijacked update of a Ukrainian accounting program and spread around the world within hours. The shipping company Maersk had to reinstall thousands of servers and PCs. Its recovery reportedly depended on one domain controller in Ghana that had been offline during the attack because of a power cut. NotPetya was built to destroy, so paying the ransom brought nothing back. Lesson: keep an offline copy of your critical systems and have a plan to rebuild.
Colonial Pipeline (May 2021): attackers logged in with the password of an old VPN account that had no multi-factor authentication. The company shut down the largest fuel pipeline in the United States for several days and paid a ransom of about 4.4 million US dollars. Lesson: turn on MFA for every remote access account and remove accounts nobody uses.
How a ransomware attack unfolds
Modern attacks are usually run by people at a keyboard, not just by automatic malware. After getting in, attackers can spend days or even weeks exploring the network before they encrypt anything. Every stage is a chance to detect and stop them.
- Initial access. The most common ways in are:
- phishing emails with malicious attachments or links
- Remote Desktop (RDP) exposed to the internet, with weak or reused passwords
- unpatched VPN gateways, firewalls and servers that face the internet
- stolen or leaked passwords on accounts without MFA
- cracked software and fake downloads
- Foothold. The attacker installs malware or a legitimate remote-access tool so they can come back at any time.
- Privilege escalation. They collect administrator passwords, often from the memory of computers where an admin has logged in.
- Lateral movement. With admin rights they move to file servers, database servers and domain controllers.
- Backup destruction. They delete Windows shadow copies and any backup they can reach: NAS devices, mapped drives, connected USB disks and backup servers.
- Data theft. They copy valuable data out of the network to use for double extortion.
- Encryption. Often launched at night, at the weekend or during a holiday, when nobody is watching. The ransom note appears on every screen.
Warning signs that an attack may be in progress:
- Antivirus or EDR is suddenly disabled, or it reports hacking tools
- New administrator accounts that nobody in IT created
- Logins at unusual hours or from unexpected countries
- Large uploads to unknown destinations
- Shadow copies deleted, and heavy disk activity on servers at odd times
- Files suddenly renamed with a strange extension
How to prevent a ransomware attack
No single product stops ransomware. The goal is several layers, so an attacker who gets past one is caught by the next. These ten measures give the most protection for the effort.
1. Backups that ransomware cannot reach
Backups are the defence that still works after everything else has failed, but only if the attacker cannot delete or encrypt them. Follow the 3-2-1-1-0 rule:
- 3 copies of your data: the original plus two backups
- on 2 different types of storage, for example a NAS and cloud storage
- 1 copy off-site, so a fire or theft cannot take everything
- 1 copy offline or immutable (it cannot be changed or deleted until a set date)
- 0 errors when you test a restore
Some things feel like backups but are not:
- A mapped network drive or an always-connected USB disk is encrypted along with everything else.
- A folder that simply syncs to the cloud uploads the encrypted files too, unless the service keeps older versions long enough to roll back.
- A backup system that uses the same administrator password as the rest of the network falls as soon as the attacker steals that password. Give backups their own accounts, protected with MFA.
Back up databases properly rather than copying live database files. For SQL Server, for example:
BACKUP DATABASE [HRMS]
TO DISK = N'D:\Backup\HRMS_full.bak'
WITH CHECKSUM, INIT;
-- Confirms the backup file is complete and readable
RESTORE VERIFYONLY FROM DISK = N'D:\Backup\HRMS_full.bak' WITH CHECKSUM;
VERIFYONLY checks that the file is readable, but only a real restore proves you can recover. Every few months, restore a server or a database to a test machine and time how long it takes. That number is how long your business would be down.
2. Patch quickly, starting with internet-facing systems
- Turn on automatic updates for Windows, browsers, Microsoft Office and PDF readers.
- Update internet-facing devices first: VPN gateways, firewalls, routers, email servers and remote access tools. Attackers start scanning the internet for a newly published vulnerability within days.
- Use CISA's Known Exploited Vulnerabilities catalog to see which vulnerabilities are being used in real attacks, and fix those first.
- Replace systems that no longer receive security updates. Windows 7 and Windows Server 2012 are long out of support, and Windows 10 reached end of support in October 2025 (after that, only paid Extended Security Updates).
3. Turn on multi-factor authentication (MFA)
A stolen password is worthless if the attacker also needs a code from your phone. Turn on MFA for:
- email (Microsoft 365, Google Workspace)
- VPN and any other remote access
- administrator accounts
- the backup system and cloud services
An authenticator app or a hardware security key is stronger than SMS codes.
4. Never expose Remote Desktop to the internet
RDP open to the internet is attacked constantly by automated password-guessing. Reach internal computers through a VPN with MFA instead. On a MikroTik router you can list every port forward and look for port 3389:
/ip firewall nat print where action=dst-nat
My guide to MikroTik critical settings covers closing the router itself and setting up the firewall.
5. Stop phishing: filtering, settings and training
- Train staff to recognise phishing: urgent payment requests, unexpected invoices, attachments nobody asked for, and sender addresses that look almost right. Make "report it, don't click it" the rule, and thank people who report.
- Show file extensions so that
invoice.pdf.execannot hide as a PDF:
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name HideFileExt -Value 0
- Keep Office macros blocked. Microsoft Office now blocks macros in files downloaded from the internet by default. Never tell users to click Enable Content on an emailed document.
- Protect your email domain with SPF, DKIM and DMARC records, which make it much harder for attackers to send email pretending to be you.
6. Least privilege: nobody works as an administrator
- Staff use standard user accounts for daily work. IT staff use a separate admin account only when they need it.
- Give every PC a different local administrator password. Windows LAPS, built into Windows since the April 2023 updates, does this automatically.
- Do not log in to ordinary PCs with domain administrator accounts. Wherever an admin logs in, an attacker can steal those credentials.
7. Endpoint protection with tamper protection
Use a modern antivirus or EDR (endpoint detection and response) product that watches behaviour, not just known files, and turn on tamper protection so attackers cannot simply switch it off. Microsoft Defender, built into Windows, includes Controlled folder access, which stops untrusted programs from changing files in protected folders such as Documents and Desktop.
# Run PowerShell as administrator
# Check that Microsoft Defender is running and up to date
Get-MpComputerStatus | Select-Object AMServiceEnabled, RealTimeProtectionEnabled, IsTamperProtected, AntivirusSignatureLastUpdated
# Try Controlled folder access in audit mode first (logs what it would block)
Set-MpPreference -EnableControlledFolderAccess AuditMode
# Then turn it on, and allow any trusted program that needs to write to protected folders
Set-MpPreference -EnableControlledFolderAccess Enabled
Add-MpPreference -ControlledFolderAccessAllowedApplications "C:\Program Files\YourApp\YourApp.exe"
8. Segment the network
In a flat network every computer can reach every other one, so one infected PC can reach every server. Split the network into separate VLANs, for example servers, office PCs, CCTV and other devices, and guest Wi-Fi, and allow only the traffic each group needs. Office PCs may need to reach the HRMS web server on port 443, but not the server's file shares or Remote Desktop.
Turn off SMBv1, the old protocol WannaCry used:
Get-SmbServerConfiguration | Select-Object EnableSMB1Protocol
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
9. Watch for the warning signs
Attackers make noise before they encrypt. Collect logs in one place if you can, and at least check regularly for these Windows security events:
| Event ID | What it means |
|---|---|
| 4720 | A user account was created |
| 4728 / 4732 | Someone was added to a security group, such as Administrators |
| 1102 | The security audit log was cleared |
Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 4720, 4728, 4732, 1102 } -MaxEvents 20
On a domain, run this on the domain controllers. Any result you cannot explain deserves a closer look.
10. Prepare an incident response plan
Decide now, while everything works, who does what during an attack:
- who can decide to disconnect systems or shut down the network
- whom to call: IT partner, management, legal adviser, insurer, bank
- a printed contact list, because email and shared files may be unavailable
- where the backups, installation media and licence keys are
Walk through the plan once a year with the people involved. A 30-minute tabletop exercise reveals most of the gaps.
What to do if ransomware hits
- Isolate. Unplug network cables and turn off Wi-Fi on affected computers. Disconnect shared storage. Do not wipe or reinstall anything yet. Power a machine off only if you cannot disconnect it, because shutting down destroys evidence in memory.
- Preserve evidence. Photograph the ransom note and the renamed files. Keep logs, and keep the affected disks for investigation.
- Identify and scope. Find out which systems are affected and which ransomware family you are dealing with. ID Ransomware identifies the family from the ransom note or an encrypted file. The No More Ransom project, run by Europol, police forces and security companies, publishes free decryptors for some families.
- Report. Inform management, your IT partner and, if you have one, your insurer. Report the attack to the police and to your national CERT. In Bangladesh that is BGD e-GOV CIRT. If personal data was stolen, you may also have legal duties to inform the people affected.
- Reset credentials from a clean device: administrator, email, VPN and backup accounts first, then everyone else.
- Rebuild and restore. Reinstall affected systems from clean installation media, then restore data from backups you have checked are clean. Restoring onto a system the attacker still controls only leads to a second attack.
- Review and harden. Find out how the attacker got in and close that entry point before you reconnect everything. Then update your plan with what you learned.
CISA's #StopRansomware guide has a detailed response checklist that is worth reading before you need it.
Should you pay the ransom?
Law enforcement agencies such as the FBI advise against paying. There is no guarantee that you will receive a working key; decryption is often slow and incomplete; stolen data may be leaked anyway; and paying marks you as a victim who pays. Check No More Ransom for a free decryptor first. If a business is ever considering payment, that decision belongs to management, with legal advice, and never under the attacker's time pressure. The best way to avoid facing that decision is a tested, offline backup.
Ransomware prevention checklist
- Offline or immutable backups, following the 3-2-1-1-0 rule
- Restore tests every few months, with the recovery time written down
- Automatic updates, and internet-facing devices patched first
- No unsupported operating systems on the network
- MFA on email, VPN, remote access, admin accounts and backups
- No Remote Desktop open to the internet
- Phishing training, visible file extensions and Office macros kept blocked
- Standard user accounts for daily work and unique local admin passwords (LAPS)
- EDR or antivirus with tamper protection, plus Controlled folder access
- Network segmented into VLANs, and SMBv1 switched off
- Alerts on new admin accounts and cleared logs
- A printed incident response plan, practised once a year
Frequently asked questions
Can antivirus alone stop ransomware? No. Antivirus catches many known threats, but human-operated attacks often use legitimate admin tools and switch off security software before encrypting. Antivirus is one layer; backups, MFA, patching and segmentation are the others.
Can ransomware reach files in OneDrive or Google Drive? Yes, if they are synced to an infected computer: the encrypted versions sync to the cloud. Both services keep older versions of files, and Microsoft 365 subscribers can restore their entire OneDrive to an earlier point in the last 30 days. Check your service's version history settings, and do not rely on sync as your only backup.
Are Mac and Linux computers safe? They are attacked less often than Windows PCs, but not safe. Ransomware groups increasingly target Linux servers and virtualisation hosts such as VMware ESXi, because encrypting one host takes down every virtual machine on it.
Is a small business really a target? Yes. Many attacks are opportunistic: automated tools scan the whole internet for open Remote Desktop, weak passwords and unpatched devices, and attack whatever they find. Small businesses often have weaker defences and no offline backups, which makes them attractive.
Summary
- Ransomware encrypts your data, and often steals it, to force you to pay.
- Most attacks start with phishing, exposed Remote Desktop, unpatched internet-facing systems or stolen passwords.
- Attackers usually spend time inside the network first, which gives you chances to catch them.
- The strongest defences are offline or immutable backups, MFA, fast patching, least privilege, segmentation and endpoint protection with tamper protection.
- If you are hit: isolate, preserve evidence, report, rebuild from clean backups, and close the door the attacker used.
Want a practical security review of your office network, servers or backups? Get in touch.





