CmdID

CmdID / Rules / macOS

Local System Accounts Discovery - MacOs

A Sigma rule for process creation on macOS, by Alejandro Ortuno, oscd.community.

low 1 ATT&CK technique 12 programs it names 28 everyday examples trip it

What it looks for

its detection, as SigmaHQ writes it
detection:
  selection_dscacheutil:
    CommandLine|contains|all:
      - '-q'
      - 'user'
    Image|endswith: '/dscacheutil'
  selection_dscl:
    CommandLine|contains|all:
      - 'list'
      - '/users'
    Image|endswith: '/dscl'
  selection_home_dir_listing:
    CommandLine|endswith:
      - '/Users'
      - '/Users'''
      - '/Users"'
    Image|endswith: '/ls'
  selection_id:
    Image|endswith: '/id'
  selection_logged_in_users:
    Image|endswith:
      - '/who'
      - '/w'
      - '/users'
      - '/last'
  selection_loginwindow_prefs:
    CommandLine|contains: 'com.apple.loginwindow'
    Image|endswith:
      - '/defaults'
      - '/plutil'
  selection_lsof:
    CommandLine|contains: '-u'
    Image|endswith: '/lsof'
  selection_passwd_sudo:
    CommandLine|contains:
      - '/etc/passwd'
      - '/etc/sudoers'
    Image|endswith:
      - '/cat'
      - '/awk'
      - '/grep'
  selection_root:
    CommandLine|contains: '''*:0:'''
  condition: 1 of selection*

The rule’s detection, its selections and fields in order of name. The whole rule, with its references and false positives, is on SigmaHQ, by Alejandro Ortuno, oscd.community, under the Detection Rule License 1.1. CmdID evaluates it on a command line alone: a test on what a command line cannot show, such as the parent process or the user, is not met.

Command lines that trip it

everyday examples from tldr-pages, CC BY 4.0, each read by CmdID

View last login information (e.g., username, terminal, boot time, kernel) of all users as read from /var/log/wtmp on the page for last

List login information of a specific user on the page for last

last usernameIdentify

Specify how many of the last logins to show on the page for last

last --limit login_countIdentify

Display current user's ID (UID), group ID (GID), and groups to which they belong on the page for id

Display the current user identity on the page for id

id --user --nameIdentify

Display the current user identity as a number on the page for id

id --userIdentify

Display the current primary group identity on the page for id

id --group --nameIdentify

Display the current primary group identity as a number on the page for id

id --groupIdentify

Display all groups the current user belongs to on the page for id

id --groups --nameIdentify

Display an arbitrary user's ID (UID), group ID (GID), and groups to which they belong on the page for id

id usernameIdentify

Skip name lookup and specify the UID number explicitly on the page for id

id +uid_numberIdentify

List files opened by the given user on the page for lsof

lsof -u usernameIdentify

And 16 more examples on CmdID’s program pages.

The commands documented for chown, last, lastb, setfacl, sg trip it too: each is on its program’s page, read by CmdID.

Programs and files it names

their pages here

ATT&CK

the techniques it is tagged with
T1087.001Account Discovery: Local Account