TryHackMe Summit: Climbing the Pyramid of Pain

TryHackMe Summit: Climbing the Pyramid of Pain

Six malware samples, six detections. Working up the Pyramid of Pain from hash blocks to Sigma rules that catch C2 beaconing and attacker recon.

Every time I blocked the tester’s malware, they changed it just enough to get around me.

I’d read about the Pyramid of Pain, but this room makes you actually climb it. From the bottom up, the levels are:

  1. Hash Values
  2. IP Addresses
  3. Domain Names
  4. Network/Host Artifacts
  5. Tools
  6. TTPs

Each question in this lab takes a look at each level of the pyramid of pain by simulating a Penetration Test. Each time I block something, I have to climb one level higher on the pyramid. The higher I go, the more it costs the attacker to work around my detection.

Sample 1: Hash Values

Sample 1 sandbox report

Sample 1 is about as simple as it gets. The sandbox flags it straight away as Metasploit (tagged Trojan.Metasploit.A) and shows it connecting to an unusual port. Under INFO it reads the machine GUID, the computer name and the supported languages, and checks LSA protection. That’s the malware fingerprinting the host. It’s worth noting now, because every sample from here on does the exact same recon, which tells me they’re all built from the same codebase.

IOCs:

  • MD5: cbda8ae000aa9cbe7c8b982bae006c2a
  • SHA1: 83d2791ca93e58688598485aa62597c0ebbf7610
  • SHA256: 9c550591a25c6228cb7d74d970d133d75c961ffed2ef7180144859cc09efca8c
  • Metasploit signature detection
  • Host recon: machine GUID, computer name, language check, LSA protection check

Triage: From what I’ve learned so far, a known-bad signature firing on an exe is about the easiest alert a SOC gets. I’d confirm the hash against threat intel, check which hosts have run that hash, and quarantine the file. Since the sample is the only thing we know about, the hash is the quickest thing to block:

Sample 1 hash blocked

The catch is that a hash only matches that exact file. Recompile it, or change a single byte, and the hash is completely different. That’s why it sits at the bottom of the pyramid, and sure enough, the next sample got around it.

Sample 2: IP Addresses

Sample 2 sandbox report

Sample 2 has a new hash, so my block from sample 1 doesn’t touch it. This time the report shows network activity: sample2.exe makes a GET to http://154.35.10.113:4444/uvLk8YI32. There’s no domain and no DNS request. It’s talking straight to a raw IP on port 4444, which is Metasploit’s default listener port. The other two connections go to 40.97.128.3 and 40.97.128.4 on port 443, which belong to Microsoft Corporation. That’s normal Windows background traffic, so I can rule it out.

IOCs:

  • C2 IP: 154.35.10.113 (Intrabuzz Hosting Limited)
  • Port 4444 (Metasploit default)
  • Random-looking URI: /uvLk8YI32
  • Direct-to-IP HTTP with no DNS lookup
  • Same host recon as sample 1

Triage: An outbound connection from a fresh exe to a hosting provider on port 4444 is a C2 callback. I’d search the firewall and proxy logs for any other internal hosts talking to 154.35.10.113, then block it. This matches the second step of our pyramid of pain, IP addresses, so I blocked it with an egress deny rule in the firewall tool:

Sample 2 firewall rule

An IP is a little more work for the attacker to change than a hash, but not much. Spinning up a new cloud server takes minutes.

Sample 3: Domain Names

Sample 3 sandbox report

Sample 3 changed its IP, which got it past my firewall rule. This time it uses a domain: it looks up emudyn.bresonicz.info, checks in on port 1337 (/kzn293la), and then downloads backdoor.exe over port 80. The backdoor then talks back to the same server. The sandbox flags “Downloads executable files from the Internet” under MALICIOUS. Again, the services.microsoft.com traffic is legitimate and can be ignored.

IOCs:

  • C2 domain: emudyn.bresonicz.info
  • C2 IP: 62.123.140.9 (Xplorlta Cloud Services)
  • Port 1337 check-in to a random URI: /kzn293la
  • Second-stage download: backdoor.exe
  • Same host recon as samples 1 and 2

Triage: An exe pulling down another exe is a dropper. I’d check the process tree (sample3.exe → backdoor.exe), find which hosts resolved emudyn.bresonicz.info in the DNS logs, and check whether backdoor.exe has run anywhere. Since the domain resolves to whatever IP the attacker points it at, a normal IP block won’t cut it. This would reflect the next tier of the pyramid of pain, Domain Names. I can block this at the DNS level, so that even if the intruder changes the IP address, the domain is still blocked:

Sample 3 DNS rule

Sample 4: Network/Host Artifacts

Sample 4 sandbox report

Looking at this, I can see that the same pattern is there for the download of backdoor.exe, just from a new domain: cranes0ft.iniware.xyz (with a zero in “soft”), on port 1337 again. I could block that domain too, but registering a new domain is cheap, and the tester has already shown they’ll just move. I needed something they couldn’t swap out so easily. We need to look at the next level of the pyramid of pain: Network/Host Artifacts.

The answer was in the Registry Activity section. sample4.exe writes DisableRealtimeMonitoring = 1 to HKLM\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection, which turns off Windows Defender’s real-time protection. The other two registry events are explorer.exe enabling balloon tips and notepad.exe reading the .txt file association. Those are normal Windows behaviour, so they’re noise.

IOCs:

  • Registry write: HKLM\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection\DisableRealtimeMonitoring = 1
  • C2 domain: cranes0ft.iniware.xyz (typosquat-style “s0ft”)
  • C2 IP: 102.23.20.118 (Xplorlta Cloud Services, same provider as sample 3)
  • Port 1337 check-in to a random URI: /ab9z83ja
  • Second-stage download: backdoor.exe

Triage: Defender being switched off by anything other than an admin or a management tool is a high-priority alert. It’s MITRE ATT&CK Defense Evasion (TA0005), and it usually means the attacker is clearing the way for the next stage. I’d check which process made the change and whether it was a legitimate admin action, then check Defender’s status across the fleet, and turn it back on. This one is a clear IOC that doesn’t depend on the attacker’s infrastructure at all, so I built a Sigma rule for it:

Sample 4 Sigma rule

This rule then generates into:

title: Modification of Windows Defender Real-Time Protection
id: windows_registry_defender_disable_realtime
description: |
  Detects modifications or creations of the Windows Defender Real-Time Protection DisableRealtimeMonitoring registry value.

references:
  - https://attack.mitre.org/tactics/TA0005/

tags:
  - attack.ta0005
  - sysmon

detection:
  selection:
    EventID: 4663
    ObjectType: Key
    ObjectName: 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection'
    NewValue: 'DisableRealtimeMonitoring=1'

  condition: selection

falsepositives:
  - Legitimate changes to Windows Defender settings.

level: high

Sample 5: Tools

This is where things start to get tricky. Looking at the sandbox report, sample5.exe does some recon on the host first: it reads the machine GUID, the computer name, the supported languages, and checks LSA protection. None of these is damning on its own, but together it’s fingerprinting the machine before calling home. It then reaches out to bababa10la.cn on an odd port (1382) and downloads beacon.bat.

Sample 5 sandbox report

From there, beacon.bat sends the same POST to /keep-alive?hostname=WK102 over and over, 400+ HTTP requests with only a single DNS lookup. That’s a C2 heartbeat: the infected host checking in with the attacker to say it’s still alive and ask for tasks. Interestingly, the sandbox flagged 0 threats. No signature caught it.

I already blocked hashes, IPs, domains and registry changes in the earlier samples, and the attacker can swap all of those cheaply. So this sample is the next tier of the pyramid of pain: Tools. Instead of blocking the indicator, I need to detect how the attacker’s tool behaves.

The outgoing connections log made that behavior obvious:

2023-08-15 09:00:00 | Source: 10.10.15.12 | Destination: 51.102.10.19 | Port: 443 | Size: 97 bytes
2023-08-15 09:23:45 | Source: 10.10.15.12 | Destination: 43.10.65.115 | Port: 443 | Size: 21541 bytes
2023-08-15 09:30:00 | Source: 10.10.15.12 | Destination: 51.102.10.19 | Port: 443 | Size: 97 bytes
2023-08-15 10:00:00 | Source: 10.10.15.12 | Destination: 51.102.10.19 | Port: 443 | Size: 97 bytes
2023-08-15 10:14:21 | Source: 10.10.15.12 | Destination: 87.32.56.124 | Port: 80  | Size: 1204 bytes
2023-08-15 10:30:00 | Source: 10.10.15.12 | Destination: 51.102.10.19 | Port: 443 | Size: 97 bytes
...
2023-08-15 21:00:00 | Source: 10.10.15.12 | Destination: 51.102.10.19 | Port: 443 | Size: 97 bytes

Traffic to 51.102.10.19 (the bababa10la.cn server) happens exactly every 30 minutes, from 09:00 to 21:00, and every connection is exactly 97 bytes. Everything else in the log has random timestamps, sizes ranging from 805 to 95,021 bytes, and destinations that each show up only once. That’s just normal background traffic. People are irregular and machines aren’t, so a fixed interval with a fixed payload size is the giveaway for beaconing.

IOCs:

  • Beacon: 97 bytes every 1800 seconds (30 minutes) to the same destination
  • Repeated POST /keep-alive?hostname=WK102, which sends the victim’s hostname to the attacker
  • C2 domain: bababa10la.cn (51.102.10.19, Xplorlta Cloud Services again)
  • Port 1382 check-in to a random URI: /zz89j3uf
  • Second-stage download: beacon.bat, a batch script making outbound web requests
  • Same host recon as every other sample, including the LSA protection check

Triage: I’d start with the process tree (sample5.exe → beacon.bat) to confirm where the traffic comes from. Then I’d search the network logs for the same pattern on other hosts, not just this IP, since the beacon is what stays the same. I’d isolate WK102 (10.10.15.12), and block the domain and IP as a stopgap. The LSA protection check is a hint that credential dumping could be next, so I’d also look for anything touching LSASS.

Since the attacker can rotate the IP and domain at will, I left those as wildcards and built the Sigma rule on the beacon’s behavior instead: a 97 byte payload every 1800 seconds, tagged as Command and Control (TA0011). To get around this, the attacker would have to rework the tool itself (add jitter, vary the payload size) rather than just spin up a new server.

Sample 5 Sigma rule

The rule generated:

title: Alert on Suspicious Beacon Network Connections
id: network_connections_criteria_sysmon
description: |
  Detects network connections with specific criteria in Sysmon logs: remote IP, remote port, size, and frequency.

references:
  - https://attack.mitre.org/tactics/TA0011/

tags:
  - attack.ta0011
  - sysmon

detection:
  selection:
    EventID: 3
    RemoteIP: '*'
    RemotePort: '*'
    Size: 97
    Frequency: 1800 seconds

  condition: selection

falsepositives:
  - Legitimate network traffic may match this criteria.

level: high

Sample 6: TTPs

Sample 6 sandbox report

This is the top of the pyramid: TTPs (Tactics, Techniques and Procedures). At this point I’ve blocked the tester’s files, servers, registry changes and beacon. The only thing left is the way they actually operate once they’re on a machine.

The network side looks familiar. sample6.exe checks in with contr0l2hax.info on an odd port (1499) and pulls a file from the same server, which is Xplorlta Cloud Services yet again. The interesting part is further down. sample6.exe is running out of C:\Users\admin\AppData\Local\Temp, launched by explorer.exe (so someone double-clicked it), and it spawns three cmd.exe processes. One of those drops a single text file: %temp%\exfiltr8.log.

The commands log shows what those cmd.exe processes ran:

dir c:\ >> %temp%\exfiltr8.log
dir "c:\Documents and Settings" >> %temp%\exfiltr8.log
dir "c:\Program Files\" >> %temp%\exfiltr8.log
dir d:\ >> %temp%\exfiltr8.log
net localgroup administrator >> %temp%\exfiltr8.log
ver >> %temp%\exfiltr8.log
systeminfo >> %temp%\exfiltr8.log
ipconfig /all >> %temp%\exfiltr8.log
netstat -ano >> %temp%\exfiltr8.log
net start >> %temp%\exfiltr8.log

Every one of these is a normal Windows command. An admin could run any of them on a normal day. What gives it away is the pattern. It’s a full sweep of the machine in one go:

  • dir on the drives and program folders: what’s on this box? (File and Directory Discovery)
  • net localgroup administrator: who has admin rights? (Permission Groups Discovery)
  • ver and systeminfo: what OS and patch level is it running? (System Information Discovery)
  • ipconfig /all: what network is it on? (Network Configuration Discovery)
  • netstat -ano: what is it connected to? (Network Connections Discovery)
  • net start: what services are running, like AV? (System Service Discovery)

And every result gets appended (>>) into the same file in the temp folder. That’s local data staging: gather everything into one place, then send it out in one go. The file name, exfiltr8.log, doesn’t exactly hide what it’s for.

Two small details I liked. “c:\Documents and Settings” hasn’t existed since Windows XP, and the local group is actually called “administrators”, so that command fails. This is a generic recon script the tester carries from job to job, not something written for this machine. That’s exactly why it’s worth detecting: it’s the same playbook every time.

IOCs:

  • Staging file: %temp%\exfiltr8.log, written by cmd.exe
  • A burst of discovery commands, each redirected to the same file
  • sample6.exe running from the user’s Temp folder and spawning cmd.exe
  • C2 domain: contr0l2hax.info (182.44.41.12, Xplorlta Cloud Services)
  • Port 1499 check-in to a random URI: /kwsx92la

Triage: I’d pull the process tree (explorer.exe → sample6.exe → cmd.exe) and the command-line logs (Sysmon Event ID 1) to see exactly what ran. Then I’d grab exfiltr8.log, if it’s still there, to see what the attacker learned about the machine. Most importantly, I’d check whether it was sent out: look for an outbound transfer from that host to contr0l2hax.info, or anywhere new, right after the file was written. If it was, this is no longer just an infection, it’s a data leak, and the host needs isolating.

The tester can change the hash, the IP, the domain, the registry trick and the beacon timing. Changing how they do recon and staging means changing their whole playbook. So I built the Sigma rule on the staging step: a Sysmon File Creation and Modification rule on %temp%\exfiltr8.log, tagged as Exfiltration (TA0010).

Sample 6 Sigma rule

The rule generated:

title: Alert on Potential Exfiltration through File Creation or Modification
id: sysmon_file_creation_modification_temp
description: |
  Detects file creation or modification events with specific criteria: file path and file name.

references:
  - https://attack.mitre.org/techniques/TA0010/

tags:
  - attack.ta0010
  - attack.exfiltration
  - attack.file_creation
  - attack.file_modification
  - sysmon

detection:
  selection:
    - EventID: 2
      TargetFilename: '*\\exfiltr8.log'
      TargetPath: '*\\AppData\\Local\\Temp\\*'

  condition: selection

falsepositives:
  - Legitimate use of file creation and modification in a user's temp folder.

level: high

Wrapping up

Summit is a good reminder of why the Pyramid of Pain is shaped the way it is. Blocking hashes, IPs and domains took a few seconds each, and the tester got around every one of them just as quickly. The rules that actually held were the ones built on behaviour: Defender being turned off, a machine-regular beacon, and a recon script staging its output. Those are the ones that make an attacker change how they work, not just what they work with.