Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 37 ยท Behavioural Indicators and YARA

Indicators of Compromise: Hashes, Domains and Artefacts

Learn what indicators of compromise are, the pyramid of pain, how to extract and defang hashes, domains and IPs, and practice with a runnable Python extractor.

Once you have analysed a sample you need to turn what you learned into something other people can use: a list of things to search for in logs, mail gateways, endpoints and network traffic. These are indicators of compromise (IOCs): observable artefacts that suggest a system was affected. A file hash, a domain name, an IP address, a registry key, a mutex name and a user-agent string are all indicators.

This lesson covers the types of indicators, why some are more valuable than others, and how to extract and handle them safely. The data is made up, with reserved example domains and documentation IP ranges, and the Python programs are stand-ins for the extraction scripts and triage tools you would run on real reports.

Types of indicators

File hashes Exact match for a file.
Network Domains, IPs, URLs, user agents.
Host artefacts Mutexes, registry keys, paths.
Patterns Strings and byte sequences.

Each has a different shelf life.

1 / 2

The pyramid of pain

David Bianco's Pyramid of Pain ranks indicators by how much it hurts an attacker when you detect them:

  1. Hash values (trivial): change one byte and the hash changes.
  2. IP addresses (easy): move to another server.
  3. Domain names (simple): register another one.
  4. Network and host artefacts (annoying): user-agent strings, mutex names, file paths, registry keys, URL patterns.
  5. Tools (challenging): detecting the attack tool itself, for example through YARA rules.
  6. Tactics, techniques and procedures (tough): detecting the behaviour, such as how an actor achieves persistence or moves laterally.

The lower levels are quick to collect and share but short-lived. The higher levels take more analysis but stay useful for months. That is why this track spends so much time on behavioural patterns and YARA after the basics.

Hashes

A cryptographic hash (SHA-256 is the standard today; MD5 and SHA-1 still appear in older feeds) is the identity of a file. Searching for a hash on a threat-intelligence service or in your endpoint logs tells you whether you have seen this exact file. Always record several hashes (MD5, SHA-1, SHA-256), the file name, size and type.

Hash matching has two weaknesses. A single changed byte creates a different hash, and polymorphic or per-victim-built samples have unique hashes. Fuzzy hashes (ssdeep, TLSH) and the imphash (a hash of the imported functions, in order) find similar files. The stand-in below shows both effects: the exact hash changes completely after a one-byte edit, while a toy "import hash" stays equal because the import list did not change.

Python Exact hashes versus an import-style hash

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Network indicators

Domains, IP addresses and URLs are the usual output of dynamic analysis. Record the full URL path and method, the port, the protocol and the user-agent, because a custom user-agent string is a high-value indicator that is hard to change. Note whether the domain was resolved by DNS or contacted by raw IP, and whether TLS certificates have unusual fields.

When you share indicators, defang them: write hxxp://example[.]invalid/a instead of http://example.invalid/a, and 192[.]0[.]2[.]10 instead of an IP. Defanging prevents an accidental click and stops chat tools from generating previews that contact the server. Refanging for use in a block list is done by a script.

Host indicators

On the endpoint, record file names and paths created, registry keys modified for persistence, mutex names (malware creates a named mutex to avoid running twice), scheduled tasks, services and named pipes. These come from your sandbox run and from the process-monitoring tools described in the dynamic analysis chapter. Mutex names are valuable because they are often hard-coded and unique to a family.

Extracting indicators with a script

Analysts rarely retype indicators. They paste a report into a script that pulls them out with regular expressions, classifies them and removes duplicates. The stand-in below does this on a made-up text. The report mentions hashes of different lengths, a defanged domain, an IP from the documentation range and a registry key.

Python Extract and classify indicators from a report

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check the result: the duplicate IP appears once, and the 64-, 40- and 32-character hex strings land in different buckets because the patterns use word boundaries and fixed lengths. Real extractors also validate IP octets (each at most 255), handle IPv6 and domains, and ignore benign domains (the vendor's own, microsoft.com) so they do not flood a block list. Libraries such as iocextract automate this, but the idea fits in a page.

Context, confidence and lifetime

An indicator without context is a liability. A single IP might belong to a shared hosting provider used by thousands of innocent sites, and blocking it causes outages. For each indicator keep:

  • Type and value, plus first seen and last seen dates.
  • Source: your sandbox, a partner report, a feed.
  • Confidence: observed in a verified malicious run, or only mentioned in a blog.
  • Relationship: which sample contacted it, in what role (download server, command-and-control).
  • Expiry or review date. Infrastructure is taken down and reassigned; old indicators produce false positives.

Formats for exchange such as STIX and MISP carry these fields, which is the subject of sharing intelligence safely.

Never paste live malicious URLs into tickets or chats. Defang them, and never test an indicator by visiting it from a normal browser: the site may attack you or alert the operator that someone is looking.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In the pyramid of pain, which indicator type is easiest for an attacker to change?

    Changing one byte of a file changes its hash, so hashes cost the attacker almost nothing to evade.
  2. 2. What does it mean to defang an indicator?

    Defanging prevents accidental visits and automatic link previews.
  3. 3. Which two hash values would NOT match exactly for slightly different builds but could still be linked?

    Fuzzy hashes such as ssdeep and TLSH, and the imphash, measure similarity instead of exact identity.
  4. 4. Why record the confidence and expiry of an indicator?

    Context lets others judge how much to trust an indicator and when to retire it.

Summary

  • IOCs include hashes, domains, IPs, URLs, user agents, mutexes, registry keys and file paths.
  • The pyramid of pain ranks them: hashes are cheap to evade, behaviours and TTPs are costly to change.
  • Record several hashes, plus fuzzy and import hashes to link similar files.
  • Defang network indicators before sharing and extract them with scripts, not by hand.
  • Always attach source, confidence, relationships and an expiry date.
  • The extractor above is a small stand-in for real tools.

Next: YARA Rule Basics