.. / osascript
Star

osascript is a native macOS binary that executes OSA language scripts - AppleScript and JavaScript. To execute, it is possible to pass a script file or pipe standard input. Scripts can be plain text or compiled scripts. An adversary may use osascript for c2 communication or post-exploitation objectives.


Paths:

Resources:

    Execution

  1. osascript making network connections

  2. This query detects any instance of osascript making a network connection.

    Adversaries may use this technique for C2 comms via HTTP or HTTPS. Due to osascript limitations, a valid certificate needs to be presented by the C2 server for successful HTTPS C2 comms.

    Execute:
    Detect:
    Respond:
    1. View the cmdline of osascript execution. This may provide helpful details about the src of execution.
    2. View the process' parent name and parent cmdline information.
    3. Check for any network connections, file writes, process creates of the osascript process and its parent.
    Privileges required: User or Root
    MITRE ATT&CK®: T1059.007


  3. osascript executing JavaScript

  4. This query will detect any instance of osascript executing JavaScript.

    Adversaries may use this for C2 comms. Apfell is a popular red team C2 agent that leverages this technique by default.

    Execute:
    Detect:
    Respond:
    1. View the cmdline of osascript execution. This may provide helpful details about the src of execution.
    2. View the process' parent name and parent cmdline information.
    3. Check for any network connections, file writes, process creates of the osascript process and its parent.
    Privileges required: User or Root
    MITRE ATT&CK®: T1059.007


  5. osascript shelling out

  6. This query will detect any instance of osascript running some binary, consistent with a C2 shelling out.

    Adversaries may use this for post-exploitation objectives, such as credential access by generating a prompt to ask a user for their password.

    Execute:
    Detect:
    Respond:
    1. View the cmdline of osascript execution. If a true positive, this may provide exactly what the attacker is attempting to achieve.
    2. View the cmdline of the target process. This will be the process launched by osascript. Is the cmdline suspicious?
    Privileges required: User or Root
    MITRE ATT&CK®: T1059


  7. osascript executing AppleScript

  8. This query detect any instance of osascript executing AppleScript.

    Adversaries may use this for post-exploitation objectives, such as credential access by generating a prompt to ask a user for their password.

    Execute:
    Detect:
    Respond:
    1. View the cmdline of osascript execution. If a true positive, this may provide exactly what the attacker is attempting to achieve.
    2. View the process' parent information. Is the binary suspicious? Typically osascript post-exploitation execution's will be the result of an adversary "shelling out" from their C2.
    Privileges required: User or Root
    MITRE ATT&CK®: T1059.002


    Credential Access

  9. osascript prompting for password

  10. This query is meant to detect credential access post-exploitation techniques.

    Adversaries may use this for post-exploitation objectives, such as credential access by generating a prompt to ask a user for their password.

    Execute:
    Detect:
    Respond:
    1. View the cmdline of osascript execution. If a true positive, this may provide exactly what the attacker is attempting to achieve.
    2. View the process' parent information. Is the binary suspicious? Typically osascript post-exploitation execution's will be the result of an adversary "shelling out" from their C2.
    3. Does it make sense the parent process is asking the user for their password?
    Privileges required: User or Root
    MITRE ATT&CK®: T1059.002