Detection rules › Elastic
Potential Credentials Phishing via Osascript
Identifies the use of osascript to execute scripts via standard input that may prompt a user with a rogue dialog for credentials.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Credential Access |
Telemetry coverage
Rule body
[rule]
description = """
Identifies the use of osascript to execute scripts via standard input that may prompt a user with a rogue dialog for
credentials.
"""
id = "318d3d9d-ba60-40e3-bc8c-3d3304209a3c"
license = "Elastic License v2"
name = "Potential Credentials Phishing via Osascript"
os_list = ["macos"]
reference = [
"https://github.com/EmpireProject/EmPyre/blob/master/lib/modules/collection/osx/prompt.py",
"https://ss64.com/osx/osascript.html",
"https://www.elastic.co/security-labs/beyond-the-wail",
]
version = "1.0.37"
query = '''
process where event.action == "exec" and
process.name == "osascript" and process.args == "-e" and process.command_line like~ ("*osascript*display*dialog*password*",
"*osascript*display*dialog*passphrase*",
"*osascript*display*dialog*authenticate*",
"*pass*display*dialog*") and
not (process.parent.executable == "/usr/bin/sudo" and process.command_line like~ "*Encryption Key Escrow*") and
not (process.command_line like~ "*-e with timeout of 3600 seconds*" and user.id == 0 and process.parent.executable == "/bin/bash") and
not process.parent.command_line like "sudo*" and
not process.Ext.effective_parent.executable like~
("/usr/local/jamf/*",
"/Library/Intune/Microsoft Intune Agent.app/Contents/MacOS/IntuneMdmDaemon",
"/Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM",
"/Applications/NinjaRMMAgent/programfiles/ninjarmm-macagent",
"/Applications/Karabiner-Elements.app/Contents/MacOS/Karabiner-Elements",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfDaemon.app/Contents/MacOS/JamfDaemon",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfManagementService.app/Contents/MacOS/JamfManagementService")
'''
min_endpoint_version = "8.8.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0
[[actions]]
action = "kill_process"
field = "process.parent.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.002"
name = "GUI Input Capture"
reference = "https://attack.mitre.org/techniques/T1056/002/"
[threat.tactic]
id = "TA0006"
name = "Credential Access"
reference = "https://attack.mitre.org/tactics/TA0006/"
[internal]
min_endpoint_version = "8.8.0"
Stages and Predicates
Stage 1: process
process where event.action == "exec" and
process.name == "osascript" and process.args == "-e" and process.command_line like~ ("*osascript*display*dialog*password*",
"*osascript*display*dialog*passphrase*",
"*osascript*display*dialog*authenticate*",
"*pass*display*dialog*") and
not (process.parent.executable == "/usr/bin/sudo" and process.command_line like~ "*Encryption Key Escrow*") and
not (process.command_line like~ "*-e with timeout of 3600 seconds*" and user.id == 0 and process.parent.executable == "/bin/bash") and
not process.parent.command_line like "sudo*" and
not process.Ext.effective_parent.executable like~
("/usr/local/jamf/*",
"/Library/Intune/Microsoft Intune Agent.app/Contents/MacOS/IntuneMdmDaemon",
"/Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM",
"/Applications/NinjaRMMAgent/programfiles/ninjarmm-macagent",
"/Applications/Karabiner-Elements.app/Contents/MacOS/Karabiner-Elements",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfDaemon.app/Contents/MacOS/JamfDaemon",
"/Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfManagementService.app/Contents/MacOS/JamfManagementService")
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.command_line | match | -e with timeout of 3600 seconds | excludes:process.command_line field:"process.command_line" value:"-e with timeout of 3600 seconds" |
process.parent.executable | eq | /bin/bash | excludes:process.parent.executable field:"process.parent.executable" value:"/bin/bash" |
user.id | eq | 0 | excludes:user.id field:"user.id" value:"0" |
process.command_line | match | Encryption Key Escrow | excludes:process.command_line field:"process.command_line" value:"Encryption Key Escrow" |
process.parent.executable | eq | /usr/bin/sudo | excludes:process.parent.executable field:"process.parent.executable" value:"/usr/bin/sudo" |
process.Ext.effective_parent.executable | wildcard | /usr/local/jamf/*, /Library/Intune/Microsoft Intune Agent.app/Contents/MacOS/IntuneMdmDaemon, /Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM, /Applications/NinjaRMMAgent/programfiles/ninjarmm-macagent, /Applications/Karabiner-Elements.app/Contents/MacOS/Karabiner-Elements, /Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfDaemon.app/Contents/MacOS/JamfDaemon, /Library/Application Support/JAMF/Jamf.app/Contents/MacOS/JamfManagementService.app/Contents/MacOS/JamfManagementService | excludes:process.Ext.effective_parent.executable |
process.parent.command_line | starts_with | sudo | excludes:process.parent.command_line field:"process.parent.command_line" value:"sudo" |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"exec" |
process.args | eq |
| field:"process.args" kind:eq value:"-e" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard |
process.name | eq |
| field:"process_name" kind:eq value:"osascript" |