// HackTheBox  ·  writeup

Operation Blackout 2025: Smoke & Mirrors

HackTheBox Very Easy EvtxECmdPython
DFIR

Scenario

In Smoke & Mirrors, players analyze the provided event logs and forensic artifacts to uncover how the attacker disabled or altered security features. They must identify the tools, commands, or scripts used to reduce visibility and reconstruct the methods the attacker used to operate undetected.

Executive Summary

An attacker with command execution on a Windows host spent a few minutes stripping its defenses before doing anything else. They switched off LSA protection through the registry, then used PowerShell to weaken Defender’s scanning preferences. A PowerShell script compiled with Add-Type patched the AMSI scan routine in memory, with the target function name built from split strings to dodge string matching. The host was then told to reboot into Safe Mode, where most security tooling does not load, and PowerShell’s history logging was turned off to leave less behind. All of it is visible in PowerShell script block logging and Sysmon process creation.

Artifacts

Timestamp note: The work files record times as HH:MM:SS only, with no date or timezone noted. The Forensic Timeline below is relative to a single day.

Defense Evasion

Q1 — The attacker disabled LSA protection on the compromised host by modifying a registry key. What is the full path of that registry key?

LSA protection is controlled by the RunAsPPL value under the LSA key in HKLM. Parse the whole log set to CSV and search for RunAsPPL. Both the PowerShell script block log (4104) and the Sysmon process creation event (Event ID 1) show a reg add setting RunAsPPL to 0, which turns the protection off. The key path in that command is the answer, so copy it as written, using the HKLM abbreviation.

EvtxECmd -d evidence --csv work/evtx
python3 -I -c "import csv,re,sys; [print(r) for r in csv.DictReader(open(sys.argv[1], encoding='utf-8-sig')) if re.search('RunAsPPL', str(r))]" work/evtx/<parsed>.csv

Tip: EvtxECmd may print an --icons error here. It still wrote the CSV, so check the output folder before assuming it failed.

Click flag to reveal HKLM\SYSTEM\CurrentControlSet\Control\LSA
Q2 — Which PowerShell command did the attacker first execute to disable Windows Defender?

Search the 4104 script block events for Set-MpPreference and take the earliest one, shortly after the LSA change. It sets three Defender preferences to $true at once: IOAV protection, email scanning and block-at-first-seen. The format hint matches that three-parameter shape. Later Set-MpPreference calls exist, so sort by time before picking.

python3 -I -c "import csv,re,sys; [print(r) for r in csv.DictReader(open(sys.argv[1], encoding='utf-8-sig')) if re.search('Set-MpPreference', str(r))]" work/evtx/<parsed>.csv
Click to reveal answer Set-MpPreference -DisableIOAVProtection $true -DisableEmailScanning $true -DisableBlockAtFirstSeen $true
Q3 — The attacker loaded an AMSI patch written in PowerShell. Which function in the DLL is being patched by the script to effectively disable AMSI?

Look at the 4104 events around the Defender changes for a script using Add-Type with a P/Invoke definition. It resolves a function in the AMSI DLL with GetProcAddress and overwrites it in memory. The function name is never written whole: it is assembled from split string pieces, so the patch target only appears once you read the concatenation.

python3 -I -c "import csv,re,sys; [print(r) for r in csv.DictReader(open(sys.argv[1], encoding='utf-8-sig')) if re.search('GetProcAddress|DllImport', str(r))]" work/evtx/<parsed>.csv

Gotcha: A plain search for the function name finds nothing because of the string splitting. Search for the API calls (GetProcAddress, DllImport) instead.

Click flag to reveal AmsiScanBuffer
Q4 — Which command did the attacker use to restart the machine in Safe Mode?

The Safe Mode switch is a boot configuration change, so it shows up as a process creation, not a script block. Sysmon Event ID 1 records bcdedit.exe with a safeboot setting shortly after the AMSI patch. The network variant keeps networking available in Safe Mode, which an attacker wants for remote access.

python3 -I -c "import csv,re,sys; [print(r) for r in csv.DictReader(open(sys.argv[1], encoding='utf-8-sig')) if re.search('bcdedit|safeboot', str(r), re.I)]" work/evtx/<parsed>.csv
Click to reveal answer bcdedit.exe /set safeboot network
Q5 — Which PowerShell command did the attacker use to disable PowerShell command history logging?

Seconds after the Safe Mode change, PowerShell’s own logs (4103 and 4104) record a Set-PSReadlineOption call. Setting the history save style to nothing stops PSReadLine writing the session to its history file, which removes a common source of command evidence on disk. The script block log still caught it.

python3 -I -c "import csv,re,sys; [print(r) for r in csv.DictReader(open(sys.argv[1], encoding='utf-8-sig')) if re.search('PSReadline', str(r), re.I)]" work/evtx/<parsed>.csv
Click flag to reveal Set-PSReadlineOption -HistorySaveStyle SaveNothing

Attack Summary

PhaseAction
Defense Evasionreg add sets RunAsPPL to 0, disabling LSA protection
Defense EvasionSet-MpPreference weakens Defender scanning options
Defense EvasionPowerShell Add-Type script patches the AMSI scan function in memory
Defense Evasionbcdedit configures the next boot into Safe Mode with networking
Defense EvasionSet-PSReadlineOption stops command history being saved

Forensic Timeline

Times are HH:MM:SS as recorded in the case notes. The date and timezone were not captured.

TimeEvent
06:28:47reg add sets RunAsPPL to 0 (PowerShell 4104 and Sysmon 1)
06:31:32First Set-MpPreference script block
06:37:47AMSI patch script block logged
06:38:35bcdedit.exe Safe Mode setting (Sysmon 1)
06:38:43History logging disabled (PowerShell 4103/4104)

IOCs

TypeValue
Registry valueHKLM\SYSTEM\CurrentControlSet\Control\LSA RunAsPPL = 0
CommandSet-MpPreference -DisableIOAVProtection $true -DisableEmailScanning $true -DisableBlockAtFirstSeen $true
Commandbcdedit.exe /set safeboot network
CommandSet-PSReadlineOption -HistorySaveStyle SaveNothing
Patched functionAmsiScanBuffer

MITRE ATT&CK

TechniqueIDDescription
Modify RegistryT1112RunAsPPL set to 0 to turn off LSA protection
Impair Defenses: Disable or Modify ToolsT1562.001Set-MpPreference changes and the in-memory AMSI patch
Impair Defenses: Safe Mode BootT1562.009bcdedit set to boot into Safe Mode with networking
Indicator Removal: Clear Command HistoryT1070.003PSReadLine history saving turned off
Command and Scripting Interpreter: PowerShellT1059.001Defender, AMSI and history changes all made from PowerShell

Defender Takeaways

Alert on RunAsPPL being set to 0. Turning off LSA protection is a precursor to credential theft from LSASS and has almost no legitimate reason to happen. A Sysmon registry rule or a process rule on reg add against the LSA key catches it. Here it appeared in both Sysmon and script block logs.

Treat Set-MpPreference with disable switches as high signal. Defender tamper protection and an alert on any -Disable* argument would have flagged the first change within minutes of the LSA edit.

String-splitting defeats keyword rules, not behavior rules. The AMSI target name was never written whole, so a rule for the function name alone missed it. Detect on the combination of Add-Type, GetProcAddress and the AMSI DLL in a script block instead.

Watch bcdedit with safeboot. A Safe Mode switch outside a maintenance window means security tooling will be absent on the next boot. Alert on bcdedit.exe with safeboot in the command line from Sysmon Event ID 1.

Forward PowerShell logs off the host. The attacker turned off history saving, but script block logging (4104) still recorded the command. Enabling it, and shipping it centrally, is what made this reconstruction possible.

Conclusion

The attacker removed LSA protection, Defender scanning, AMSI and local PowerShell history in about ten minutes, and queued a Safe Mode reboot to finish the job. None of it was hidden from script block logging and Sysmon, so the lesson is that evasion tooling is loud on the telemetry the attacker forgot to touch.