Ransomware: How It Works, How to Defend and How to Recover

Ransomware has become one of the most disruptive forms of cybercrime: hospitals, schools, factories and city governments have all had operations halted. It succeeds because it attacks availability and creates immediate pressure to pay. The good news is that ransomware is also one of the most preventable and recoverable threats, if you prepare in advance. This lesson explains how it works at a conceptual level and, more importantly, how to defend against it and recover.

What Is Ransomware?

Ransomware is malware that denies access to data or systems, typically by encrypting files, and demands payment for restoration. Modern attacks usually combine several pressures:

  • Encryption: files and servers become unusable.
  • Data theft (double extortion): data is copied out first, and the attacker threatens to publish it even if backups allow recovery.
  • Harassment and pressure: contacting customers or staff, or threatening denial-of-service attacks (sometimes called triple extortion).
  • Destruction of backups: attackers look for backup servers and snapshots first.

Many groups operate as ransomware-as-a-service (RaaS), in which developers lease their tools to “affiliates” who carry out intrusions and share the profits. That is why low-skilled criminals can launch serious attacks, and why defending against common techniques matters.

How a Typical Attack Unfolds (Conceptual)

StageWhat happensWhere defenders can interrupt
1. Initial accessPhishing, stolen credentials on exposed remote access, or an unpatched internet-facing systemMFA, patching, email security, closing unnecessary exposure
2. Foothold and discoveryThe attacker explores the network and identifies valuable systems and backupsEDR, network monitoring, honeypot accounts
3. Privilege escalation and lateral movementGains administrator rights and spreads to more machinesLeast privilege, tiered administration, segmentation
4. Data theftLarge volumes copied to attacker-controlled storageEgress monitoring, data loss prevention
5. Defence and backup sabotageSecurity tools disabled, backups deleted or encryptedTamper protection, immutable and offline backups
6. Encryption and ransom noteSystems encrypted, often at night or on weekendsRapid detection, isolation, tested recovery

Notice that encryption is the last step. Days or weeks of earlier activity usually precede it, which gives well-prepared defenders a window to detect and stop the attack.

Prevention: The High-Value Controls

  1. Multi-factor authentication on email, VPN, remote desktop and all administrator accounts.
  2. Patch internet-facing systems quickly, especially VPNs, firewalls and remote access gateways, and track the CISA Known Exploited Vulnerabilities list (see Vulnerability Management).
  3. Do not expose remote desktop or SMB to the internet; use a VPN or zero-trust gateway.
  4. Endpoint detection and response (EDR) on all endpoints and servers, monitored around the clock.
  5. Least privilege and tiered administration: no domain admin logins on ordinary workstations; use LAPS for unique local administrator passwords.
  6. Network segmentation so one infected machine cannot reach everything.
  7. Email and web filtering and blocking of risky attachment types and macros.
  8. Application allow-listing where practical.
  9. Security awareness and an easy way to report suspicious messages.
  10. Logging and alerting for mass file changes, disabled security tools and unusual administrator activity.

The Backup Rule: 3-2-1-1-0

Backups are your ultimate defence, but only if the attacker cannot destroy them and you know they work.

NumberMeaning
3Keep at least three copies of your data
2On two different types of storage
1One copy offsite
1One copy offline or immutable (cannot be changed or deleted, even by an administrator)
0Zero errors: regularly test restores

Practical points: protect backup consoles with separate credentials and MFA, keep them off the main domain where possible, encrypt backups, and define your recovery point objective (RPO), how much data you can afford to lose, and recovery time objective (RTO), how long you can be down. Document the order in which systems must be restored: identity services first, then core applications.

Practice: a simple, safe backup and restore test

# Create a folder with test data
mkdir -p ~/labdata && for i in 1 2 3; do echo "important file $i" > ~/labdata/file$i.txt; done

# Make an archive and record its checksum
tar -czf ~/backup-$(date +%F).tar.gz -C ~ labdata
sha256sum ~/backup-*.tar.gz > ~/backup.sha256

# Simulate data loss
rm -r ~/labdata

# Verify the backup and restore it
sha256sum -c ~/backup.sha256
tar -xzf ~/backup-*.tar.gz -C ~
ls ~/labdata

The point is the habit: a backup you have never restored is only a hope. Schedule restore tests and record how long they take.

Detecting Early Warning Signs

  • Unusual logins, especially administrator logins outside normal hours.
  • New or modified accounts and group memberships.
  • Security tools being stopped, uninstalled or reconfigured.
  • Backup jobs failing, backups deleted or unusual access to backup servers.
  • Large outbound data transfers to unfamiliar destinations.
  • Mass file renames or sudden file-modification spikes.
  • Remote administration tools appearing that the IT team did not install.

If Ransomware Hits: Response Outline

  1. Isolate: disconnect affected machines from the network (unplug cables, disable Wi-Fi); isolate network segments. Do not simply switch machines off if investigators want memory evidence, and follow your plan.
  2. Activate the incident response plan and team; see Incident Response. Use out-of-band communication, because email may be compromised.
  3. Preserve evidence: logs, ransom notes, sample encrypted files; keep a timeline.
  4. Assess scope: which systems, which data, whether data was stolen.
  5. Notify: legal counsel, insurers, leadership and, where required, regulators and law enforcement. In India, CERT-In expects reporting of cyber incidents within six hours of noticing them under its 2022 directions, and personal-data breaches have additional obligations; confirm current requirements with your legal team.
  6. Eradicate: remove attacker access (reset credentials, including privileged and service accounts; rebuild compromised systems from clean images) before restoring, or the attacker may encrypt again.
  7. Recover from clean, verified backups in priority order, monitoring closely.
  8. Review: perform a post-incident review and fix the root causes.

Should You Pay?

Law enforcement agencies generally advise against paying: payment funds criminals, does not guarantee working decryption or deletion of stolen data, and can mark you as a repeat target. Payments may also have legal and sanctions implications. The decision is ultimately for organisational leadership with legal advice, and it is far better never to need it. Good backups and rehearsed recovery plans remove most of the pressure.

Practice Exercises

  1. Draw the attack stages for a ransomware incident and, for each stage, name one preventive and one detective control.
  2. Write a one-page ransomware playbook for a small company: who decides, who is called, what is isolated first.
  3. Assess your own backup strategy against 3-2-1-1-0 and list the gaps.
  4. Run the backup-and-restore practice above and time it. What is your RTO for that data?
  5. Explain why double extortion makes backups necessary but not sufficient.

Mentor tip: Run a tabletop exercise once a year: gather the team around a table and walk through a ransomware scenario with no technology. You will find missing phone numbers, unclear authority and untested assumptions at almost no cost.

Educational use only: this lesson is for defence and recovery. Never create or distribute malware, and practise only on systems you own.

Key takeaways
  • Modern ransomware combines encryption with data theft and backup sabotage.
  • Encryption is the last stage; earlier detection gives a chance to stop the attack.
  • MFA, patching, least privilege, segmentation and EDR prevent most attacks.
  • Follow 3-2-1-1-0 backups, and test restores regularly.
  • Prepare and rehearse the response plan before an incident, including notification duties.

Related Lessons