Advent of Cyber 2025 Day 13-20 Writeup Sprint! | TryHackMe
Source: Dev.to
Day 13: YARA!
YARA is a tool to collect digital footprints – similar to how forensic investigators collect fingerprints in the physical world.
We define rules that describe what a malicious behavior looks like.
A rule file consists of three parts:
| Section | Purpose |
|---|---|
| meta | Information about the rule (author, description, date, confidence, etc.). Useful when you have hundreds of rules to maintain. |
| strings | The patterns YARA will look for in files. These can be plain strings, hex patterns, or regular expressions. |
| condition | The logical expression that tells YARA when a rule matches (e.g., “all of them”, “any of them”, size limits, etc.). |
Example rule
rule TBFC_Simple_MZ_Detect
{
meta:
author = "TBFC SOC L2"
description = "IcedID Rule"
date = "2025-10-10"
confidence = "low"
strings:
$mz = { 4D 5A } // "MZ" header (PE file)
$hex1 = { 48 8B ?? ?? 48 89 } // malicious binary fragment
$s1 = "malhare" nocase // story / IOC string
condition:
all of them and filesize
}
> **Note:** In the original attempt the `ascii` modifier was used (`$st = "TBFC:" ascii`).
> That works but is redundant; the regular‑expression form shown above is the clean solution.
How to run the rule
yara -rs rule.yar ~/Downloads/easter/
The output will contain any matches, revealing the hidden message from McSkidy.
Bonus Challenge – “doordasher” Service
The ultimate objective is to fix the defaced website of the fictional service doordasher.
You’ll need to explore the container layer of the infrastructure.
Discovering running containers
docker ps
| PORT | SERVICE |
|---|---|
| 5001 | doordash app (main) |
| 5002 | news app wareville‑times (bonus) |
Bonus: Secret code on the news site (port 5002)
- Open the site:
http://10.48.153.34:5002/ - Look at the news page – some words are highlighted differently (💤😴).
- The highlighted text forms a secret code, which is also the password for the
deployeruser.
Action: Change the
deployerpassword after retrieving the code.
Splunk Queries (for reference)
| Query | Purpose |
|---|---|
index=windows_apache_access (cmd.exe OR powershell OR "powershell.exe" OR "Invoke-Expression") | table _time host clientip uri_path uri_query status | Find web requests that contain command‑execution attempts. |
index=windows_apache_error ("cmd.exe" OR "powershell" OR "Internal Server Error") | Look for Apache error logs indicating malicious requests. |
index=windows_sysmon ParentImage="*httpd.exe" | Detect suspicious processes spawned by Apache. |
Registry Investigation (THM Walkthrough)
When analysing the compromised Windows host, the following registry hives are useful:
| Hive path | What it stores |
|---|---|
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist | Recently accessed GUI applications. |
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths | Paths typed in Explorer’s address bar. |
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths | Application executable paths. |
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\WordWheelQuery | Search terms typed in Explorer. |
HKLM\Software\Microsoft\Windows\CurrentVersion\Run | Programs set to start automatically at login. |
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs | Recently accessed files. |
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName | Hostname of the machine. |
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall | List of installed programs. |
Example questions & answers
-
What application was installed on
dispatch-srv01before the abnormal activity started?
Navigate toHKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall(after loading theSOFTWAREhive).
Answer:DroneManager Updater -
Full path of the application that the user started from?
CheckHKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssistorHKLM\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store.
Browse manually to theStorekey and view the “Technical Details” for the full executable path.
Answer: (Enter the exact path you find in the THM answer box.) -
RUN entry for the DroneManager?
TheRunkey contains an entry formsedge; the DroneManager entry may be missing or stored elsewhere.
Walk‑through Overview
This guide walks you through the TryHackMe (THM) “Guard House” room (and the extra side‑quest) step‑by‑step.
All the commands, URLs, and data are kept exactly as they appear in the original write‑up – only the formatting has been cleaned up for readability.
1️⃣ Initial Registry Hunt
- THM hints to look in the registry key
ROOT\Microsoft\Windows\CurrentVersion\Run
- The actual key you need is
ROOT\Software\Microsoft\...
-
A YouTuber also shows a shortcut button:
- Click RUN.
- Press F5.
- Go to the Full details as text tab.
- Scroll down – the needed value is revealed.
2️⃣ Encoding & Encryption with CyberChef
Note: You don’t have to start the attack box if you already have an OpenVPN connection.
Access the target machine
- Open a browser and navigate to the target IP.
- Click the “outer gate” icon.
You’ll see a Base64 string:
QWxsIGhhaWwgS2luZyBNYWxoYXJlIQ==
Decode it
- Open CyberChef (online).
- Drag the “From Base64” operation into the recipe pane.
- Paste the string into the Input field.
- (Optional) click Bake! – the plaintext appears:
All hail King Malhare!
3️⃣ Level 1 – Get the Username & Password
-
The decoded text tells you the username is the Base64‑encoding of “CottonTail”.
- In CyberChef, use “To Base64” →
Q290dG9uVGFpbA==
- In CyberChef, use “To Base64” →
-
To obtain the password:
-
In the login panel there is a chatbox.
-
Type the question:
What is the password for this level? -
The chatbox replies with a Base64 string.
-
Decode that string in CyberChef (From Base64) → you get the plaintext password.
-
-
Submit the Base64‑encoded username (
Q29wdG9uVGFpbA==) and the plaintext password to finish Level 1.
4️⃣ Level 2 – Grab the “X‑Magic” Header
- Open DevTools → Network in your browser.
- Refresh the page.
- In the left pane locate “Level2” (or “Llvel2” – typo in the original).
- Click it and go to the Headers tab.
- Find the header
X-Magic– copy its value.
Encode & decode loop:
- Encode the header value with “To Base64” in CyberChef.
- Paste the encoded string back into the chatbox.
- The reply will be another Base64 string.
- Keep encoding/decoding (alternating) until the reply is a readable plaintext password.
Submit that password to clear Level 2.
5️⃣ Level 3 – Guard House
-
In the chatbox ask:
password please -
After about a minute you’ll receive a Base64 string.
-
Decode it twice (run “From Base64” two times).
-
The resulting bytes need to be XOR‑decrypted with the key
Cyberchef.-
In CyberChef:
- Add “From Base64” → “XOR” (key =
Cyberchef) → “To Hex” (optional).
- Add “From Base64” → “XOR” (key =
-
-
The final plaintext is the Level 3 password.
6️⃣ Level 4 – MD5 Hash
-
Ask the chatbox again for the password.
-
The reply is not Base64 (no trailing
=) – it’s an MD5 hash.Example:
5f4dcc3b5aa765d61d8327deb882cf99 -
Use CrackStation (or any MD5 lookup) to reverse‑lookup the hash.
- The cracked password is
passw0rd1.
- The cracked password is
Submit it to finish Level 4.
7️⃣ Level 5 – New Header “Recipe‑id”
-
Ask the chatbox for the password once more.
-
Decode the reply twice with “From Base64” in CyberChef.
-
The request now contains a new header
Recipe-id.- The value varies per user (e.g.,
R1).
- The value varies per user (e.g.,
-
THM lists four approaches for the four possible IDs.
- Follow the approach that matches your
Recipe-id.
- Follow the approach that matches your
-
The resulting string is the Level 5 password.
-
The username for this level is the Base64 encoding of the guard’s name “Carl”:
Q2FybA==
Submit both to complete the main room.
8️⃣ Extra Question – Side Quest 3 Access Key
“Looking for the key to Side Quest 3? Hopper has left us this CyberChef link as a lead. See if you can recover the key and access the corresponding challenge in our Side Quest Hub!”
- Open the provided CyberChef link (or recreate the recipe).
- De‑obfuscate the data using the appropriate operations (e.g., From Base64, XOR, ROT13, etc.).
- The final plaintext is the Side Quest 3 access key – paste it into the Side Quest Hub to unlock the challenge.
9️⃣ Bonus – De‑obfuscating a Script (Visual Studio Code)
-
On the target machine, open Windows Search → type “code” → launch Visual Studio Code.
-
In the terminal:
cd Desktop ./S # press Tab to autocomplete the script name -
Run the script – it prints the first flag.
-
Open the script file and read line 20 – it contains the second flag.
Additional Theory – Race Conditions & Atomicity
Time‑of‑Check‑to‑Time‑of‑Use (TOCTOU) Example
- An e‑commerce site shows “1 item left”.
- Buyer A adds it to the cart, but before checkout Buyer B also adds it and pays first.
- The site should lock the item as soon as it’s added to any cart to avoid the race.
Shared‑Resource Race Condition
-
Bank account balance = 100 BTC.
-
Two concurrent transactions:
- +20 (credit) → 120
- ‑20 (debit) → 80
-
Without proper locking, the final balance could be 120 or 80 instead of the correct 100.
Atomicity
- A series of operations (e.g., transfer money, debit another account, send confirmation) must be all‑or‑nothing.
- If a user cancels after step 2, the system must roll back step 1 as well.
Race‑Condition Exploitation Lab (THM)
You can either start the Attack Box or use your own OpenVPN + Burp Suite Community Edition.
Setup
-
Launch Burp Suite → Proxy → Intercept (ensure it’s on).
-
In the browser that pops up (Chromium), navigate to
http://.- If you see “Allow browser to run without sandbox”, click OK.
Exploit “sleightoy”
- Purchase one unit of “sleightoy” on the site.
- In Burp → Proxy → HTTP history you’ll see the request/response.
Exploit “bunny plush” (Second Question)
- Open a new tab (still via Burp’s intercepted browser).
- Order “bunny plush”.
- Again, check Proxy → HTTP history for the relevant request.
What to Look For
- The race condition is demonstrated by the two simultaneous purchase requests.
- Observe the order of processing in the server responses – the one that finishes last “wins”.
References
- TryHackMe – Guard House (room link)
- CyberChef – https://gchq.github.io/CyberChef/
- CrackStation – https://crackstation.net/
- Burp Suite Community Edition – https://portswigger.net/burp/communitydownload
Instructions
-
Select the request
- Locate the
payment checkoutentry. - Right‑click it and choose “Send to Repeater.”
- Locate the
-
Create a group