Detection rules › Elastic

Potential Credentials Phishing via Osascript

Source
github.com/elastic/protections-artifacts

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

TacticTechniques
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.

FieldKindExcluded valuesSearch
process.command_linematch-e with timeout of 3600 secondsexcludes:process.command_line field:"process.command_line" value:"-e with timeout of 3600 seconds"
process.parent.executableeq/bin/bashexcludes:process.parent.executable field:"process.parent.executable" value:"/bin/bash"
user.ideq0excludes:user.id field:"user.id" value:"0"
process.command_linematchEncryption Key Escrowexcludes:process.command_line field:"process.command_line" value:"Encryption Key Escrow"
process.parent.executableeq/usr/bin/sudoexcludes:process.parent.executable field:"process.parent.executable" value:"/usr/bin/sudo"
process.Ext.effective_parent.executablewildcard/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/JamfManagementServiceexcludes:process.Ext.effective_parent.executable
process.parent.command_linestarts_withsudoexcludes:process.parent.command_line field:"process.parent.command_line" value:"sudo"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • exec
field:"EventType" kind:eq value:"exec"
process.argseq
  • -e
field:"process.args" kind:eq value:"-e"
process.command_linewildcard
  • *osascript*display*dialog*authenticate*
  • *osascript*display*dialog*passphrase*
  • *osascript*display*dialog*password*
  • *pass*display*dialog*
field:"CommandLine" kind:wildcard
process.nameeq
  • osascript
field:"process_name" kind:eq value:"osascript"