Skip to content
Adam Omar Saleh

TVX CTF 2026 placeholder badge (unofficial)TVX CTF 2026Forensics

Ghost in the Envars

A full physical memory dump from a compromised Windows 10 workstation. The task is to find the true persistent secret while ignoring noise planted for automated tools and AI assistants.

Competition
TVX CTF 2026 placeholder badge (unofficial)TVX CTF 2026
Category
ForensicsMedium · estimated
Source status
Flag recovered locally · platform unverified
Document
PDF edition7 min read

Brief

The challenge

Competition
TVX CTF 2026
Category
Digital Forensics (platform category: DFIR)
Difficulty
Medium — estimated, not an official rating
Points
100
Challenge author
malogus
Verification
Flag recovered locally; platform acceptance not documented

Difficulty: Medium (estimated). TVX CTF 2026 did not publish difficulty ratings; the challenge cards show only points and solve counts. A 6.4 GB Windows memory image with deliberate decoys aimed at automated tools. The real flag sits in the environment block of a process that had already exited, so standard plugin output alone is not enough and raw memory searching is needed.

01

Overview

Our SOC team detected suspicious activity on an employee's Windows 10 workstation. An incident responder managed to acquire a full physical memory dump before taking the system offline. Your mission is to perform in-depth memory analysis to recover the true persistent secret. Be careful: adversaries leave noise and obvious decoys for automated tools and AI assistants.

A full physical memory dump from a compromised Windows 10 workstation. The task is to find the true persistent secret while ignoring noise planted for automated tools and AI assistants.

Solution path in brief

Three planted artifacts sit in the dump:

ArtifactWhereValueRole
Hidden PowerShell -EncodedCommandwindows.cmdline (PIDs 7208, 7388)TVX{dont_use_ai_for_solving}Bait, labelled "AI Trap" by the setup script
SESSION_AUTH_TOKEN environment variableEnvironment block of svchost.exe PID 2468, which had already exitedTVX{m3m0ry_4rt_n0t_pr0mpt_2026}The flag: the "ghost" in the envars
HKLM\SOFTWARE\Challenge\AuthKeySOFTWARE hive, written by reg add in an admin cmd.exeK3rn3l_Auth_K3y_99Noise (not in flag format)
Text
raw grep → two TVX{} strings → cmdline shows bait → PSReadLine history shows setup script→ base64 flag placed into PEB of a spawned svchost → svchost exited (ghost) → env block residue in RAM

02

Initial investigation

Triage established the OS build and ran a first raw search for flag-shaped strings.

Triage

Shell
python vol.py windows.info

Windows 10 build 19041 x64, captured by VirtualBox (Elf64Layer). System time 2026-11-11 20:03:24 UTC.

A raw scan for the flag prefix (ASCII and UTF-16LE, plus the base64 of TVX{) with grep.py gives two distinct flags and one base64 blob:

Text
TVX{dont_use_ai_for_solving}TVX{m3m0ry_4rt_n0t_pr0mpt_2026}VFZYe20zbTByeV80cnRfbjB0X3ByMG1wdF8yMDI2fQ==   → TVX{m3m0ry_4rt_n0t_pr0mpt_2026}

03

Tools used

  • Volatility 3 (windows.info, windows.pstree, windows.cmdline, windows.envars, windows.filescan, windows.dumpfiles, windows.registry.*)

  • Python mmap search helpers (ctx.py, grep.py, hives.py)

  • regipy for registry hive parsing

04

Step-by-step process

Step 1: The bait in the command lines

windows.cmdline shows two hidden PowerShell processes, both children of the interactive PowerShell PID 6708:

Text
7208 powershell.exe -WindowStyle Hidden -EncodedCommand UwB0AGEAcgB0AC0AUwBsAGUAZQBwACAALQBTAGUAYwBvAG4AZABzACAAOAA2ADQAMAAwADsAIAAjACAAVABWAFgAewBkAG8AbgB0AF8AdQBzAGUAXwBhAGkAXwBmAG8AcgBfAHMAbwBsAHYAaQBuAGcAfQA=

Decoded (UTF-16LE base64): Start-Sleep -Seconds 86400; # TVX{dont_use_ai_for_solving}. The flag is only a comment inside a sleep command. Of all the artifacts this one is the most visible, and it's the decoy for automated tools.

Step 2: The setup script (PSReadLine history)

windows.filescan lists \Users\windows 10\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt. Dumping it with windows.dumpfiles --virtaddr 0xc482d538c840 gives the full setup script. Its comments are in Arabic:

PowerShell
# 1. إعداد المصيدة (Fake Flag / AI Trap)$baitCmd = "Start-Sleep -Seconds 86400; # TVX{dont_use_ai_for_solving}"$encodedBait = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($baitCmd))Start-Process powershell.exe -ArgumentList "-WindowStyle Hidden -EncodedCommand $encodedBait"​# 2. إعداد الفلاق الحقيقي داخل الرام (Real Flag)$realFlagBytes = [System.Convert]::FromBase64String("VFZYe20zbTByeV80cnRfbjB0X3ByMG1wdF8yMDI2fQ==")$realFlag = [System.Text.Encoding]::UTF8.GetString($realFlagBytes)# تشغيل عملية نظام بخلفية صامتة ووضع الفلاق داخل متغيرات البيئة (Process Environment Block)$psi = New-Object System.Diagnostics.ProcessStartInfo$psi.FileName = "$env:SystemRoot\System32\svchost.exe"$psi.Arguments = "-k netsvcs"$psi.EnvironmentVariables["SESSION_AUTH_TOKEN"] = $realFlag$psi.UseShellExecute = $false$proc = [System.Diagnostics.Process]::Start($psi)

The comments translate to "set up the trap" and "set up the real flag inside RAM … launch a silent system process and put the flag in its environment variables (Process Environment Block)".

Step 3: The ghost in the envars

windows.envars doesn't show SESSION_AUTH_TOKEN for any live process. That's because the svchost.exe -k netsvcs it was planted in wasn't started by the Service Control Manager, so it exited right away. windows.pstree still lists it as a terminated child of PowerShell 6708:

Text
**** 2468 | 6708 | svchost.exe | exited 2026-11-11 19:58:26 UTC

Its environment block is still in physical memory as a UTF-16 run of NAME=value pairs:

Python
...PSModulePath=C:\Users\windows 10\Documents\WindowsPowerShell\Modules;...PUBLIC=C:\Users\PublicSESSION_AUTH_TOKEN=TVX{m3m0ry_4rt_n0t_pr0mpt_2026}SystemDrive=C:SystemRoot=C:\Windows...

That's the "ghost in the envars": a flag living in the environment block of a process that no longer exists.

Step 4: Noise in the registry

The admin cmd.exe (PID 8032, conhost 6428) ran a single command, recovered from conhost memory and the console title:

Text
reg add "HKLM\SOFTWARE\Challenge" /v "AuthKey" /t REG_SZ /d "K3rn3l_Auth_K3y_99" /f

windows.registry.printkey --key Challenge on the SOFTWARE hive confirms it (last write 19:51:55 UTC). A full walk of the dumped SYSTEM, SOFTWARE and NTUSER hives (hives.py) found nothing else planted. Both Environment keys (HKCU and Session Manager\Environment) are stock. The value isn't in TVX{} format and nothing reads it, so it's a lure for anyone chasing "persistent" through the registry.

05

Commands and code

Tools / scripts

  • vol.py: a small wrapper that runs Volatility 3 on memory.raw.

  • grep.py, ctx.py, multi.py: raw ASCII/UTF-16 search and context dumps over the 6.4 GB image (mmap + regex).

  • hives.py: regipy walk over the dumped hives, looking for keys written in the attack window or matching suspicious keywords.

Full source: ctx.py: context around raw memory matches

Python
import mmap, re, sys​pat = sys.argv[1].encode()before = int(sys.argv[2]) if len(sys.argv) > 2 else 300after = int(sys.argv[3]) if len(sys.argv) > 3 else 300limit = int(sys.argv[4]) if len(sys.argv) > 4 else 20utf16 = b"".join(bytes([c, 0]) for c in pat)​​def clean(b):    if b.count(0) > len(b) // 3:        b = b.replace(b"\x00", b"")    return re.sub(rb"[^\x20-\x7e\n]", b".", b).decode()​​seen = set()with open("memory.raw", "rb") as f:    m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)    n = 0    for p in (pat, utf16):        for x in re.finditer(re.escape(p), m):            o = x.start()            mul = 2 if p is utf16 else 1            c = clean(m[max(0, o - before * mul):o + after * mul])            key = c[before // 2: before // 2 + 200]            if key in seen:                continue            seen.add(key)            print(f"===== {hex(o)} {'utf16' if p is utf16 else 'ascii'}")            print(c)            n += 1            if n >= limit:                sys.exit()

Full source: vol.py: Volatility 3 wrapper

Python
import sysfrom volatility3.cli import main​sys.argv = ["vol", "-q", "-f", "memory.raw"] + sys.argv[1:]main()

06

Technical explanation

When a process exits, its pages are not zeroed immediately, so its PEB and environment block can survive in physical memory. Plugins that walk the active process list never see such a process. Searching raw memory for flag-shaped strings (ASCII and UTF-16) finds the residue, and the context around it identifies the variable name and owner. The decoys are the opposite case: visible, “obvious” artifacts in command lines and the registry.

Key lessons

  • windows.envars only reads processes that are still alive. A short-lived child's environment block can survive in RAM after the process exits, so a raw UTF-16 search for NAME= pairs still finds it.

  • PSReadLine's ConsoleHost_history.txt is often still in the file cache, and it can hand you the attacker's whole script, comments included.

  • In a challenge that warns about decoys, sort the candidates by where they live and how they were planted, not just by whether they match the flag format.

07

Flag

Flag

TVX{m3m0ry_4rt_n0t_pr0mpt_2026}

Flag recovered locally · platform unverified

08

Verification status

Status: Flag recovered locally; platform acceptance not documented.

The flag string was located in the memory image and tied to the SESSION_AUTH_TOKEN environment variable of an exited svchost.exe. The setup script recovered from PSReadLine history explains both the bait and the real secret. Platform acceptance is not documented.

Source evidence in the archive: WRITEUP.md, ctx.py, grep.py, hives.py, cmdline.txt, envars.txt, hist.txt, grep_tvx.txt.

09

Conclusion

The challenge tests discipline more than tooling. Two flag-shaped strings appear early, and the setup script recovered from history explains which one is bait and why the real one only survives as residue.

Prepared by Adam Omar Saleh from the archived solve notes in ghost_in_the_envars/. Commands, code, output and screenshots are reproduced from the source; no results were added. Difficulty is an estimate.

PDF edition

Writeup PDF

Formatted edition of this walkthrough, built from my source notes · 5 pages.