Ransomware is not one click and "boom". It is five steps that usually play out over a week, and at every step there is a chance to catch it. In this video I rebuild all five steps in a lab (a made-up company, contoso.com), explain each hard word in plain language, run one KQL query to see each step in Microsoft Sentinel, and give one setting that stops it.
No real victim is named, and nothing on screen is an attack how-to: the only code shown is detection queries you run against your own logs.
The five steps
- Password spraying — the attacker tries one common password across many accounts (not many passwords on one account). Each account fails only once, so nobody is locked out and nobody is alerted. One account with no MFA is enough. Microsoft's 2025 Digital Defense Report says more than 97% of identity attacks are password attacks, and MFA blocks more than 99% of them.
- Privilege escalation — a normal account cannot open anything important, so the attacker climbs to admin rights. In the lab the weak spot is an admin who signed in to a shared machine and never signed out, leaving a usable sign-in behind. Two mistakes: an admin account used on a shared machine, and admin rights left on 24/7 with no approval.
- Lateral movement — with admin rights the attacker moves sideways from machine to machine, heading for the backup server. If the backups survive, the victim does not need to pay, so this is the most important place to defend: split the network and limit admin accounts.
- Data theft (double extortion) — before locking anything, the attacker copies data out and later threatens to publish it. This is why backups alone are not enough: a backup restores your files, but it does not un-leak your data.
- The ransom note — at the end of the week the encryption runs on the servers at once. By then it is too late; the value is in the four earlier steps.
Should you pay?
According to the Sophos State of Ransomware 2025 report, among organizations that were encrypted and paid, only part paid the full amount demanded, and the average recovery cost, excluding the ransom, was about $1.53M. Paying does not guarantee your data back and does not delete the copy the attacker already took. Preventing it up front is cheaper.
See each step with KQL
Run these in Microsoft Sentinel (Logs). Lab names (contoso.com); swap in your own accounts. These are illustrative detection queries — tune the thresholds and table names to your tenant. Microsoft's own password-spray classification page is linked in the sources.
// Step 1 - password spraying: one client, many accounts, many countries, one hour
SigninLogs
| where TimeGenerated between (ago(1h) .. now())
| where ResultType != "0"
| summarize Accounts = dcount(UserPrincipalName),
Countries = dcount(Location), IPs = dcount(IPAddress)
by UserAgent
| top 10 by Accounts
// Steps 2-3 - one account suddenly touching many servers
DeviceLogonEvents
| where Timestamp between (ago(1h) .. now())
| where AccountName == "sales.user"
| summarize Servers = dcount(DeviceName) by bin(Timestamp, 1h)
| order by Servers desc
// Step 4 - data leaving the network
CloudAppEvents
| where Timestamp between (ago(1d) .. now())
| where ActionType == "FileUploaded"
| summarize GB = sum(tolong(RawEventData.FileSizeBytes)) / 1e9
by bin(Timestamp, 1h)
| order by GB desc
In Microsoft Defender, these separate alerts are stitched into a single incident in time order, so an analyst opens one incident and sees the whole story: spray → account taken → lateral movement → data theft.
Five settings that stop the whole chain
- MFA for everyone — best of all a phishing-resistant passkey. One setting removes the password as a target.
- Limit failed sign-ins and turn on the password-spray alert in Microsoft Entra.
- No 24/7 admin — use Privileged Identity Management: admin for one hour, with a reason.
- Split the network and block admin logins on normal machines — this is what stops lateral movement.
- Keep backups out of reach, test restoring them, and label/control important data against leaks.
The attacker needs you to fail at only one step. You only need to break one step and the chain falls apart.
Sources (Microsoft and others)
- Microsoft — What is ransomware? (human-operated): https://learn.microsoft.com/en-us/security/ransomware/human-operated-ransomware
- Microsoft Defender XDR — Classify a password spray alert (KQL): https://learn.microsoft.com/en-us/defender-xdr/alert-classification-password-spray-attack
- Microsoft — Password spray investigation playbook: https://learn.microsoft.com/en-us/security/compass/incident-response-playbook-password-spray
- Microsoft Entra — Privileged Identity Management: https://learn.microsoft.com/en-us/entra/id-governance/privileged-identity-management/pim-configure
- Microsoft Digital Defense Report 2025 (identity/extortion figures): https://news.microsoft.com/source/asia/2025/10/17/digital-defence-report-2025
- Sophos — The State of Ransomware 2025: https://www.sophos.com/en-us/blog/the-state-of-ransomware-2025
Lab data only (contoso.com). Figures are from the sources above; no dollar ransom amounts are invented.
Thanks for reading! I'm Cuong, and on CD Security Lab I rebuild real Microsoft security cases in a safe lab and explain them simply. Follow along:
- ▶️ YouTube (daily Shorts + explainers): CD Security Lab
- 💼 LinkedIn: Cuong Do
- 📘 Facebook: CD Security Lab
- 📸 Instagram: @cdsecuritylab
- 📝 More posts like this: Dev.to
Got a question about your own tenant? Drop it in the comments.
Top comments (0)