Investigating Ransomware in Splunk: Queries for Each Stage
TL;DR · the short version
A defender's walk through a ransomware intrusion in Splunk, stage by stage, from the encrypting process back to the way in: ransom notes and recovery inhibition, LSASS access, WMI spread, new accounts and local group changes, discovery bursts, masquerading binaries and web shells on Exchange or IIS. Each stage has the Sysmon or Windows event to look for and a Splunk query to adapt.
Ransomware is the last step of an intrusion, not the first. By the time files are encrypted, the attacker has usually got in, looked around, made sure they can come back, stolen credentials and spread. A good investigation works backwards from the encryption to the way in, and every one of those steps leaves an event you can search. This guide gives the event to look for and a Splunk query to start from at each stage. If you would rather check an export without a SIEM, the Ransomware Precursor Log Analyzer runs the same checks in your browser.
Before you search
- Widen the time range. Splunk defaults to a short window. Start well before the encryption day: in the Conti case Sophos describes, ransomware came five days after the first access.
- Know your sources. The queries assume Sysmon and Windows Security events with the usual field names (
EventCode,Image,ParentImage,CommandLine,TargetImage,TargetFilename). Replaceindex=*with your real indexes once you know where the events live; searching every index on a large estate is slow. - Preserve first. Export what you find before anyone reimages a host.
The Sysmon events that matter
| Event | What Microsoft says it records | Why it matters here |
|---|---|---|
| Sysmon 1 | Process creation, with extended information | Commands, parents, binaries in odd paths |
| Sysmon 3 / 22 | Network connections (off by default) / DNS queries | Callbacks, tunnels, exfiltration |
| Sysmon 8 | A process creates a thread in another process | Injection |
| Sysmon 10 | A process opens another process; detects tools that read LSASS memory | Credential theft |
| Sysmon 11 | A file is created or overwritten | Web shells, dropped tools, ransom notes |
| Security 4720 / 4732 | A user account was created / a member was added to a security-enabled local group | Persistence through accounts |
Descriptions from Microsoft's Sysmon page and its 4720 and 4732 references.
1. Impact: ransom notes and recovery inhibition
Start where the damage is. One process creating the same note name in many folders points you at the encryptor, and its path tells you a lot: an executable named like a Windows tool but running from a user folder is a red flag.
index=* EventCode=11 (TargetFilename="*readme*" OR TargetFilename="*decrypt*" OR TargetFilename="*restore*")
| stats dc(TargetFilename) AS notes values(host) AS hosts BY Image
| where notes > 20 | sort - notes
index=* EventCode=1 (CommandLine="*vssadmin*delete*shadows*" OR CommandLine="*shadowcopy*delete*" OR CommandLine="*bcdedit*recoveryenabled*" OR CommandLine="*wbadmin*delete*")
| table _time host User ParentImage CommandLine
Take the encryptor's hash from the Hashes field and look it up in your threat intelligence or a reputation service. Look the hash up; do not upload a file from a victim's network to a public service.
2. Masquerading binaries
index=* EventCode=1 (Image="*\\cmd.exe" OR Image="*\\svchost.exe" OR Image="*\\rundll32.exe" OR Image="*\\lsass.exe" OR Image="*\\powershell.exe")
NOT (Image="C:\\Windows\\System32\\*" OR Image="C:\\Windows\\SysWOW64\\*" OR Image="C:\\Windows\\WinSxS\\*")
| stats count earliest(_time) AS first BY host Image | convert ctime(first)
3. Credential theft: LSASS access
Microsoft says Sysmon Event 10 detects tools that read LSASS memory. Some legitimate processes open lsass.exe (antivirus, some system services), so list the sources and look at anything new.
index=* (EventCode=10 OR EventCode=8) TargetImage="*\\lsass.exe"
| stats count values(GrantedAccess) AS access BY host SourceImage
| sort - count
index=* EventCode=1 (CommandLine="*comsvcs*MiniDump*" OR CommandLine="*procdump*lsass*" OR CommandLine="*reg*save*HKLM\\SAM*")
| table _time host User CommandLine
The fix after an LSASS read is wide: reset the passwords of every account that signed in to that host, and of service accounts used there. Two Microsoft controls make the next attempt harder: LSA protection, which Microsoft says blocks untrusted LSA code injection and process memory dumping, and the Protected Users group, which stops credentials of its members being cached at sign-in.
Useful next, if this was relevant to you
4. Spread: WMI, services and PsExec
Microsoft documents unsecapp.exe as the separate process WMI uses to receive asynchronous callbacks. It is legitimate. A command shell or an unknown executable whose parent is unsecapp.exe or wmiprvse.exe, on many hosts in a short window, is a strong sign of remote execution through WMI.
index=* EventCode=1 (ParentImage="*\\wmiprvse.exe" OR ParentImage="*\\unsecapp.exe")
| stats dc(host) AS hosts values(host) AS host_list BY Image CommandLine
| sort - hosts
index=* EventCode=1 (CommandLine="*wmic*/node:*process*call*create*" OR CommandLine="*Win32_Process*Create*" OR Image="*\\PSEXESVC.exe" OR CommandLine="*sc*\\\\*create*")
| table _time host User ParentImage CommandLine
5. Persistence: new accounts and local groups
Adding a user to Remote Desktop Users or Administrators on one machine gives the attacker a way back in even if other credentials are reset. net1.exe does the same job as net.exe, so search for both.
index=* (EventCode=4720 OR EventCode=4732)
OR (EventCode=1 (Image="*\\net.exe" OR Image="*\\net1.exe") CommandLine="*/add*")
| table _time host EventCode User CommandLine
6. Discovery bursts
One built-in command is noise; several in a few minutes from one host or account is someone finding their way around.
index=* EventCode=1 (Image="*\\whoami.exe" OR Image="*\\net.exe" OR Image="*\\net1.exe" OR Image="*\\nltest.exe" OR Image="*\\ipconfig.exe" OR Image="*\\systeminfo.exe" OR Image="*\\quser.exe")
| bin _time span=10m
| stats dc(Image) AS tools values(CommandLine) AS commands BY host User _time
| where tools >= 3
7. The way in: web shells on Exchange and IIS
Exchange servers have long been a favourite way in. CISA's August 2021 alert names the three ProxyShell flaws (CVE-2021-34473, CVE-2021-34523 and CVE-2021-31207) and says Microsoft's May 2021 security update fixes all three. Sophos describes Conti affiliates exploiting ProxyShell, creating a mailbox for "administrator" and assigning it new roles, setting up a web shell in under a minute and a backup one three minutes later; it says about 1 TB was taken within 48 hours and the ransomware was deployed after five days.
index=* EventCode=11 (TargetFilename="*.aspx" OR TargetFilename="*.ashx" OR TargetFilename="*.asmx")
(TargetFilename="*\\inetpub\\*" OR TargetFilename="*\\FrontEnd\\HttpProxy\\*" OR TargetFilename="*\\aspnet_client\\*")
| table _time host Image TargetFilename
index=* EventCode=1 ParentImage="*\\w3wp.exe" (Image="*\\cmd.exe" OR Image="*\\powershell.exe")
| table _time host User CommandLine
On Exchange, also review the admin audit log for mailbox, role-assignment and mailbox-export cmdlets you did not run (PlayCISO guidance). Then patch, remove the web shells, and assume every credential the server could reach is exposed.
Put it on one timeline
Write each finding as a row: time, host, account, what happened, the event and the query that found it. Read it top to bottom from the first web shell to the ransom notes, and the gaps tell you which logs you were missing. Practise exactly this on a fictional case in the Intrusion Investigation Lab, or download synthetic Sysmon and Windows logs from the Sample Library to try these queries in your own Splunk.
Frequently asked questions
How do you investigate ransomware in Splunk?
Widen the time range well beyond the encryption day, then work backwards by stage: find the encrypting process and its ransom notes, the credential theft (process access to lsass.exe), the spread (WMI, PsExec, services), the persistence (new users, local group changes) and the way in (web shells, exposed services). Each stage has a Sysmon or Windows event you can search for.
Which Sysmon events matter most for ransomware?
Event ID 1 (process creation) for commands and parents, 11 (file create) for web shells and ransom notes, 10 (process access) for reads of lsass.exe memory, 8 (CreateRemoteThread) for injection, and 3 and 22 for network connections and DNS queries. Add Windows Security 4720 (user created) and 4732 (member added to a local group).
What does Sysmon Event ID 10 on lsass.exe mean?
A process opened lsass.exe. Microsoft says this event detects tools that read LSASS memory, which is how attackers steal credentials. Antivirus and some system processes open it legitimately, so baseline the normal source processes and look at the rest.
Why is unsecapp.exe in a ransomware investigation?
Microsoft documents unsecapp.exe as the separate process WMI uses to receive asynchronous callbacks. It is legitimate, but when it or wmiprvse.exe is the parent of a command shell or an unknown executable on many hosts at once, that is a strong sign of remote execution through WMI.
Did Conti use ProxyShell?
Yes, per Sophos: Conti affiliates exploited ProxyShell on Exchange, set up a web shell in under a minute, added a backup web shell three minutes later, exfiltrated about 1 TB within 48 hours and deployed Conti after five days. CISA lists the three ProxyShell CVEs and says the May 2021 Exchange update fixes all three.
Can I check my own logs without Splunk?
Yes. Export Sysmon or Security events and paste or drop them into the Ransomware Precursor Log Analyzer, which runs in your browser and flags each stage with the matching hunt query for Splunk and Microsoft Sentinel.
Sources
- Microsoft Learn: Sysmon (event descriptions)
- Microsoft Learn: Event 4720 and Event 4732
- CISA: Urgent: Protect Against Active Exploitation of ProxyShell Vulnerabilities (21 Aug 2021)
- Sophos: Conti affiliates use ProxyShell Exchange exploit in ransomware attacks (Sept 2021)
- Microsoft Learn: Setting Security on an Asynchronous Call (unsecapp.exe)
- Microsoft Learn: Configure added LSA protection and Protected Users security group
Spotted an error? Report an error. A person reads every message.