Detection rules › Elastic
Keystrokes Input Capture from a Managed Application
Identifies attempts to enumerate the state of keyboard keys and the call is coming from a suspicious Microsoft .NET application. Adversaries may log user keystrokes to intercept credentials or other information from the user as the user types them.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Collection |
Rule body
[rule]
description = """
Identifies attempts to enumerate the state of keyboard keys and the call is coming from a suspicious Microsoft .NET
application. Adversaries may log user keystrokes to intercept credentials or other information from the user as the user
types them.
"""
id = "92243752-7639-45c2-b416-6072b04d2320"
license = "Elastic License v2"
name = "Keystrokes Input Capture from a Managed Application"
os_list = ["windows"]
reference = [
"https://attack.mitre.org/techniques/T1056/001/",
"https://www.elastic.co/security-labs/protecting-your-devices-from-information-theft-keylogger-protection",
]
version = "1.0.7"
query = '''
sequence by process.entity_id with maxspan=1m
[process where event.action == "start" and
(process.Ext.relative_file_creation_time <= 500 or process.Ext.relative_file_name_modify_time <= 500) and
(process.code_signature.trusted == false or process.code_signature.exists == false) and
not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
not process.parent.executable : "C:\\Program Files\\Microsoft Visual Studio\\*\\Common?\\IDE\\devenv.exe"]
[api where
(
process.Ext.api.name : "GetAsyncKeyState" or
(process.Ext.api.name == "SetWindowsHookEx" and process.Ext.api.parameters.hook_type == "WH_KEYBOARD_LL")
) and
process.thread.Ext.call_stack_final_user_module.protection_provenance : "clr.dll" and
process.thread.Ext.call_stack_final_user_module.name : "Unbacked" and
not process.executable :
("?:\\Program Files (x86)\\*.exe",
"?:\\Program Files\\*.exe",
"C:\\Makino Client\\Product\\SystemConsole.exe")]
'''
min_endpoint_version = "8.10.0"
reputation = true
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1056"
name = "Input Capture"
reference = "https://attack.mitre.org/techniques/T1056/"
[[threat.technique.subtechnique]]
id = "T1056.001"
name = "Keylogging"
reference = "https://attack.mitre.org/techniques/T1056/001/"
[threat.tactic]
id = "TA0009"
name = "Collection"
reference = "https://attack.mitre.org/tactics/TA0009/"
[internal]
min_endpoint_version = "8.10.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 1m, correlated by process.entity_id.
Stage 1: process
[process where event.action == "start" and
(process.Ext.relative_file_creation_time <= 500 or process.Ext.relative_file_name_modify_time <= 500) and
(process.code_signature.trusted == false or process.code_signature.exists == false) and
not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
not process.parent.executable : "C:\\Program Files\\Microsoft Visual Studio\\*\\Common?\\IDE\\devenv.exe"]
Stage 2: api
[api where
(
process.Ext.api.name : "GetAsyncKeyState" or
(process.Ext.api.name == "SetWindowsHookEx" and process.Ext.api.parameters.hook_type == "WH_KEYBOARD_LL")
) and
process.thread.Ext.call_stack_final_user_module.protection_provenance : "clr.dll" and
process.thread.Ext.call_stack_final_user_module.name : "Unbacked" and
not process.executable :
("?:\\Program Files (x86)\\*.exe",
"?:\\Program Files\\*.exe",
"C:\\Makino Client\\Product\\SystemConsole.exe")]
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.parent.executable | wildcard | C:\Program Files\Microsoft Visual Studio\*\Common?\IDE\devenv.exe | excludes:process.parent.executable field:"process.parent.executable" value:"C:\Program Files\Microsoft Visual Studio\*\Common?\IDE\devenv.exe" |
user.id | eq | S-1-5-18, S-1-5-19, S-1-5-20 | excludes:user.id field:"user.id" value:"S-1-5-18" field:"user.id" value:"S-1-5-19" field:"user.id" value:"S-1-5-20" |
process.executable | wildcard | ?:\Program Files (x86)\*.exe, ?:\Program Files\*.exe, C:\Makino Client\Product\SystemConsole.exe | excludes:process.executable field:"process.executable" value:"?:\Program Files (x86)\*.exe" field:"process.executable" value:"?:\Program Files\*.exe" field:"process.executable" value:"C:\Makino Client\Product\SystemConsole.exe" |
Indicators
These rows show field, operator, and value matches.