Skip to content

From a Mach-O File to IOCs: MISP, STIX 2.1 and a YARA Draft

Which indicators a Mach-O file gives up, how Mach-O Parser filters the background noise, and how to export them to CSV, MISP, STIX 2.1 and a YARA draft.

Published on 6 min read

TL;DR. A Mach-O sample yields two families of indicators:

  • what it talks to and touches: URLs, domains, IPs, host:port pairs, user agents, file paths, wallet addresses, from its strings, Base64-decoded text and stack strings;
  • who it is: file hashes, the cdhash of each slice, the Team ID and the symhash.

Mach-O Parser extracts both, marks the background noise, and exports the rest as a CSV file, a defanged text list, a MISP event or a STIX 2.1 bundle. It also drafts a YARA rule from the same material and runs it against the batch, so you can test it before it leaves the browser.

Where the indicators come from

SourceGives
Strings (ASCII / UTF-8 and UTF-16)URLs, domains, IPs, e-mail addresses, user agents, paths, wallet addresses
Base64 text, decodedThe same, hidden one layer down
Stack strings (after code analysis)The same, for text that never existed as a string
The code signatureTeam ID, cdhash of every CodeDirectory
The fileMD5, SHA-1, SHA-256, symhash of each slice

Objective-C and Swift metadata strings (class names, selectors, type encodings) are skipped. They are full of dotted names that look like domains and are not. Stack strings join the list once the Code analysis has run for that file. See capabilities and stack strings.

Separating signal from noise

Most of what looks like an indicator in a binary is not one. The extraction is deliberately conservative:

  • Well-known infrastructure is marked, not dropped: Apple's own domains, certificate authorities, OCSP and CRL hosts, XML and plist schemas, and big platform domains. The IOCs tab hides them behind Show well-known (Apple, PKI, system paths), and the exports leave them out unless they are shown.
  • Private, loopback and multicast addresses are marked the same way.
  • Version numbers are not IPs. 1.2.3.4 next to the word "version" is ignored.
  • Identifiers are not hosts. Reverse-DNS names such as com.apple.security.cs.allow-jit look like domain names and are skipped. So are file names whose extension happens to be a top-level domain (.app, .sh, .zip).
  • System paths are context. /usr/lib/… and /System/… are kept but marked; paths in user folders, /tmp, /Library/LaunchAgents and the like are indicators.
  • Paths keep their spaces. macOS is full of names like Application Support and Login Data. A path continues past a space when the next word is capitalised and either leads to another / or ends the path, so cp /tmp/aa /tmp/bb still gives two paths.

The updater sample shows a typical result:

  • a curl … | sh URL on a documentation IP address (192.0.2.44), and that IP;
  • an https://updates.example.invalid/… URL and its domain;
  • a Safari user agent;
  • the LaunchAgent it would write, both as an absolute path and with ~;
  • the path of its own binary, $HOME/Library/Application Support/.updater/updater;
  • its /Users/Shared/.updater search path;
  • two cdhashes (one per slice), the symhash and the file hashes.

There is no Team ID: the signature is ad hoc. The one well-known URL, Apple's property-list DTD, is marked and stays out of the exports.

Exports

CSV has one line per indicator, with its type, value, defanged value, source, file offset, the well-known mark, the file it came from and that file's SHA-256. It is the format for a spreadsheet, a ticket or a quick grep across many files.

Defanged text list groups the indicators by type, made safe to paste into chat and reports: hxxp[://]192[.]0[.]2[.]44/u/stage2, updates[.]example[.]invalid.

MISP event (JSON) is an unpublished event with one attribute per indicator, ready to import:

IndicatorMISP typeCategoryto_ids
URL, domain, IPurl, domain, ip-dstNetwork activityyes
Host and portip-dst|port or hostname|portNetwork activityyes
User agentuser-agentNetwork activityno
PathfilenameArtifacts droppedno
cdhashcdhashPayload deliveryyes
MD5, SHA-1, SHA-256md5, sha1, sha256Payload deliveryyes
Team ID, symhashtext (with a comment saying which)Payload deliveryno

Every attribute's comment records where it was found and in which file. Well-known indicators never get to_ids.

STIX 2.1 bundle has one indicator object per indicator, with a STIX pattern: [url:value = '…'], [ipv4-addr:value = '…'], [file:hashes.'SHA-256' = '…'], [file:name = '…'] for a path, network-traffic patterns for host:port pairs and user agents. Types with no standard STIX cyber-observable, such as the Team ID, the cdhash and the symhash, are left out rather than invented.

For the batch as a whole, the Export menu adds the inventory, the full JSON report and an ATT&CK Navigator layer. The layer combines the techniques found in each file's structure and strings with those found in its code.

A YARA draft you can test immediately

The Draft a YARA rule button in a file's IOCs tab writes a rule in the spirit of yarGen, without a goodware database:

  • up to twelve of the file's most distinctive strings, network indicators and paths first, then commands and long specific text;
  • strong strings become $ioc*, weaker ones $s*, each with a comment saying why it was picked;
  • a condition that checks for a Mach-O or universal header (0xFEEDFACF, 0xFEEDFACE, or CA FE BA BE read as 0xBEBAFECA), bounds the file size, and requires two strong strings or several weaker ones.

The draft for the updater, with its meta block shortened:

rule updater_draft
{
    meta:
        description = "Draft rule for updater; review and test before use"
    strings:
        $ioc1 = "https://updates.example.invalid/api/check" ascii // url
        $ioc2 = "http://192.0.2.44/u/stage2" ascii // url
        $s3 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15" ascii // useragent
        $s4 = "osascript -e 'display dialog \"macOS needs your password to continue\" default answer \"\" with hidden answer'" ascii // command
        $s5 = "Library/Application Support/Google/Chrome/Default/Login Data" ascii // browser
        $s6 = "security find-generic-password -s 'Chrome Safe Storage' -w" ascii // command
        $s7 = "/Users/alice/Library/LaunchAgents/com.apple.softwareupdate.agent.plist" ascii // path
        $s8 = "~/Library/LaunchAgents/com.apple.softwareupdate.agent.plist" ascii // path
        $s9 = "$HOME/Library/Application Support/.updater/updater" ascii // path
        $s10 = "/Users/Shared/.updater" ascii // path
        $s11 = "Hello from a harmless Mach-O Parser sample (updater)." ascii // string
        $s12 = "@rpath/libhelper.dylib" ascii // string
    condition:
        // Mach-O (32/64-bit) or universal binary
        (uint32(0) == 0xfeedfacf or uint32(0) == 0xfeedface or uint32(0) == 0xbebafeca) and
        filesize < 192KB and
        (
            2 of ($ioc*) or
            4 of ($s*)
        )
}

The draft goes straight into the YARA rules panel, where it runs on every loaded file at once, children extracted from droppers included. Matches open in the hex view at the matching bytes. A rule can also start from bytes selected in the hex view, for code or data that has no string. Then do what no draft can: run it over clean software, and drop the strings that match legitimate programs. In this draft, the browser user agent appears in countless programs. Only then deploy it.

Before you share

  1. Review every indicator. Text matching finds what is in the file, not what the file does.
  2. Keep the well-known ones out unless you have a reason to include them.
  3. Share the SHA-256 and the cdhash of each slice, and the Team ID when there is one: see symhash, cdhash and Team ID.
  4. Defang anything that goes into a document or a chat.
  5. Say what each indicator is evidence of. A URL found in a string is not proof the program contacted it.

Frequently asked questions

Are all the URLs and IP addresses found in a binary malicious?

No. Extraction is text matching: a binary contains its vendor's update servers, certificate authorities' URLs, XML schemas and plenty of harmless addresses. Mach-O Parser marks the well-known ones (Apple, PKI, schemas, private and loopback addresses) and leaves them out of exports by default, but every remaining indicator still needs a human look before it goes into a blocking list.

Which hashes should I share for a Mac sample?

The SHA-256 of the file, plus the cdhash of each slice and the Team ID if there is one. The SHA-256 is what everyone looks up first. The cdhashes still match when the same code is distributed as a thin file instead of a universal one, and they are what macOS security tools key on.

Can I use the YARA draft in production?

Not as is. The draft picks the file's most distinctive strings and adds a Mach-O header check and a size bound, but it has never seen your goodware. Test it against the loaded batch and a set of clean files, remove strings that also match legitimate software, then deploy it.