Stage 6 of 9 · about 14–20 hours · intermediate · checked 2026-11-26

Cloud, identity, network and Linux/macOS hunts

Goal. By the end you can hunt for common abuse of identities and cloud services, find leads in network data, and run basic persistence and execution hunts on Linux and macOS.

Why it matters#

An attacker with a valid password or a stolen token may never touch a Windows endpoint. They sign in, add a credential, grant an application access and copy data, all through interfaces your organisation provides. Endpoint-only hunting cannot see any of that. Servers running Linux and laptops running macOS are often watched even less.

What you will learn#

Identity#

An identity provider (Microsoft Entra ID, Okta, Google Workspace and others) checks who is signing in. It records sign-ins and, separately, changes made to accounts and applications.

A session token is what you receive after signing in, so that you are not asked again for a while. Whoever holds it may be treated as you, even without the password or second factor.

Behaviour Hunt for Harmless look-alikes
Password spraying (T1110.003): few passwords against many accounts One source failing against many accounts, then any success Misconfigured service, shared office address
Repeated multi-factor prompts (T1621) Many prompts or denials for one user, then approval Bad phone signal, a confused user
Stolen session cookie (T1539) One session seen from two very different networks or devices VPNs, mobile networks
Malicious application consent (T1528) A new third-party app granted mail or file access Newly adopted tools
Added application credential (T1098.001) A new secret or certificate on an existing app Planned secret rotation
New role for an account (T1098.003) Privileged role granted outside the usual process Staff moves
Mail forwarding rule (T1114.003) Rules that send mail outside the organisation Personal habits that policy may forbid

Password spraying in Microsoft Sentinel:

KQL
SigninLogs
| where TimeGenerated > ago(7d)
| summarize FailedAccounts = dcountif(UserPrincipalName, ResultType == "50126"),
            Failed = countif(ResultType == "50126"),
            Succeeded = make_set_if(UserPrincipalName, ResultType == "0")
  by IPAddress, bin(TimeGenerated, 1d)
| where FailedAccounts >= 15
| order by FailedAccounts desc

Illustrative: test it in your lab before relying on it. It misses spraying spread across many source addresses. For that, stack failures by user agent, network owner or timing instead. Check non-interactive and service sign-in logs too, which are stored separately.

For application changes, search the directory audit log for operations such as Consent to application, Add service principal credentials and Add app role assignment to service principal.

Cloud control plane#

The control plane is the set of management actions: creating users, changing permissions, starting servers. Each large provider records them (AWS CloudTrail, Azure Activity log, Google Cloud Audit Logs). The data plane is access to the contents, such as reading a file from storage, and is often not logged unless you turn it on.

Good hunts:

  • First-seen action per identity. A build account that has only ever deployed now lists users and creates access keys.
  • Bursts of discovery. Many List and Describe calls, often with access-denied errors.
  • Logging changes (T1685.002): a trail stopped or a diagnostic setting removed.
  • Exposure. Storage or snapshots made public or shared with an unknown account (T1530 covers reading cloud storage).
SPL
index=aws sourcetype="aws:cloudtrail"
  eventName IN ("StopLogging","DeleteTrail","UpdateTrail","CreateAccessKey","AttachUserPolicy","PutUserPolicy")
| stats count, min(_time) AS first_seen, values(sourceIPAddress) AS sources, values(errorCode) AS errors
  BY userIdentity.arn, eventName
| convert ctime(first_seen)

Illustrative: test it in your lab before relying on it. Join the results to change records before calling anything suspicious.

Cloud logs can arrive minutes or hours late, and a role may be assumed in a chain, so follow the session back to the original identity.

Network#

Network data tells you who talked to whom, even for devices that cannot run an agent. Most traffic is encrypted, so you usually work from metadata: addresses, ports, sizes, timing, names and certificate details. Zeek is a free tool that turns traffic into readable logs of this kind.

Behaviour Hunt for
Command and control over web (T1071.001) Beacons (stage 4), rare destinations, newly seen domains
DNS tunnelling (T1071.004) Very many long, unique subdomains under one domain
Generated domain names (T1568.002) Many failed lookups for random-looking names
Data leaving Unusual upload volume per host, especially to new destinations
Internal scanning One host contacting many hosts or ports it never has
SPL
index=dns earliest=-1d
| rex field=query "^(?<sub>.+)\.(?<domain>[^.]+\.[^.]+)$"
| eval sublen=len(sub)
| stats dc(sub) AS unique_subs, avg(sublen) AS avg_len, dc(src_ip) AS clients BY domain
| where unique_subs>500 AND avg_len>30

Illustrative: test it in your lab before relying on it. The domain split is wrong for endings such as co.uk, content delivery and security products generate similar patterns, and encrypted DNS to an outside resolver bypasses your logs entirely.

TLS fingerprints such as JA4 summarise how a client starts an encrypted connection. A rare fingerprint is a lead about the software in use, not proof of anything, because many programs share one.

Linux and macOS#

The ideas from stage 5 carry over: process trees, new persistence, unusual parents.

Area Linux macOS
Data auditd, systemd journal, Sysmon for Linux, EDR Unified log, Endpoint Security events through EDR
Persistence Cron, systemd services, shell configuration, SSH authorised keys Launch agents, launch daemons, login items
Execution A web server process starting a shell (web shell) A script interpreter started by a downloaded application
Credentials Reads of /etc/shadow and private keys Keychain access by unusual tools

osquery lets you ask many hosts the same question in SQL, which suits stacking persistence:

Text
SELECT name, path, program, program_arguments, run_at_load FROM launchd WHERE program_arguments != '';
SELECT command, path FROM crontab;

Illustrative: test it in your lab before relying on it. This is a snapshot: persistence that was added and removed between two runs will not appear.

Do this#

  1. Hunt spraying in test data (2 hours). Use a lab tenant or sample sign-in logs. Record what one address and many addresses look like.
  2. Review application consents (2 hours). In a test tenant, grant a harmless app a low permission and find both the grant and who made it.
  3. Cloud first-seen (3 hours). In a free-tier or lab account you own, list each identity's actions over two weeks and explain the new ones. Watch for charges.
  4. Zeek on a capture (3 hours). Run Zeek on traffic from your own lab and stack destinations.
  5. Persistence snapshot (2 hours). On a Linux or macOS machine you own, list persistence and account for every entry.

Resources#

Free first

Paid or needs an account

  • A cloud account for practice (free account; usage beyond free limits is paid).

Checkpoint#

You are ready to move on when you can:

Go deeper (optional)#

0 / 4 checkpoints ticked

View this page on GitHub

9 lines · 59 stages · 77 pages 0 of 59 stages done