Detect AnyDesk --set-password in Defender (KQL)
Detects: a scripted AnyDesk unattended-access password, set by piping it into --set-password on the command line.
ATT&CK: T1219 Remote Access Tools
Works on: Microsoft Defender for Endpoint, KQL (DeviceProcessEvents)
Tested on: my lab, the unattended AnyDesk service install: six hits
Full write-up: 32 Ransomware Groups Abuse AnyDesk. Your EDR Sees a Legit Tool
Why this is the highest-fidelity AnyDesk tell
An operator who already holds local admin installs AnyDesk as a service and sets an unattended password, so they can come back with nobody clicking Accept. The DFIR Report’s “Navigating Through the Fog” documents the sequence, automated by a PowerShell script: the password goes in as echo Admin#123 | C:\ProgramData\anydesk.exe --set-password.
A person never produces that. The manual path is Settings > Access > Set password, which never touches the command line. So a piped --set-password is always something scripted, and it does not care about a rename, because it keys on the command line, not the file.
The query
Published verbatim from the newsletter issue.
DeviceProcessEvents
| where Timestamp > ago(1d)
| where ProcessCommandLine contains "--set-password"
or (InitiatingProcessCommandLine contains "set-password"
and InitiatingProcessCommandLine has "echo")
| project Timestamp, DeviceName, AccountName, FileName, FolderPath,
ProcessVersionInfoCompanyName, ProcessCommandLine,
InitiatingProcessFileName, InitiatingProcessCommandLine
| order by Timestamp asc

What it catches
Six hits in the lab, and the command line is the evidence: cmd.exe /c "echo Admin#123 | ...\AnyDesk.exe --set-password", the password sitting in plaintext.
Get the next detection in your inbox
One lab-proven detection per issue: the attacker command, the telemetry it leaves, and the KQL / ES|QL that catches it.
You confirm on Substack in one tap.
No spam. Unsubscribe anytime.
Tuning note
AnyDesk documents this same piped command for mass deployment, so baseline your own rollout before you alert on it:
- Sanctioned rollout: many hosts inside one change window, parented by your deployment agent.
- Operator: one or two hosts, parented by powershell.exe into cmd.exe.
- No AnyDesk in your estate: nothing to baseline. This is your smoking gun.
If you run SigmaHQ, its Remote Access Tool - AnyDesk Piped Password Via CLI rule fired on the same lab runs. It keys on scripted setup rather than anything a user clicks, so once your own deployment is excluded it belongs in the alert queue.
Did this query fire in your environment, or miss something? Email me what you saw: ayush@securityinbits.com (open in Gmail). I read every reply, and it decides what I test next.
Questions
Does renaming AnyDesk.exe hide the piped password?
No. The query keys on the command line, not the file, so a renamed binary still matches.
Can a legitimate admin trigger it?
Yes. AnyDesk documents the same piped command for mass deployment. A sanctioned rollout hits many hosts inside one change window, parented by your deployment agent; an operator hits one or two hosts, parented by powershell.exe into cmd.exe.
Why is a piped password such a strong tell?
Setting the password by hand is Settings > Access > Set password, which never touches the command line. A piped --set-password is always something scripted.