Challenge / Forensics

Red Failure

Red Failure is a sanitized challenge note from the local HTB archive, organized for quick review by category, difficulty, evidence flow, and reusable operator

MediumPublished 2024-07-09Sanitized local writeup

Scenario

Red Failure attack path

Red Failure is a sanitized challenge note from the local HTB archive, organized for quick review by category, difficulty, evidence flow, and reusable operator

Objective

Challenge walkthrough focused on Forensics evidence, validation, and reusable operator lessons.

Red Failure sanitized attack graph

Walkthrough flow

01

Reassemble HTTP responses from the PCAP to recover...

02

Deobfuscate the loader enough to recover the...

03

Use the DInjector encryptor format as advisory...

04

Decrypt the stage, then emulate the x86 additive-XOR...

05

Inspect the decoded stage for the persistence...

Source coverage

High source coverage

Status: complete. This article is generated from 4 sanitized Markdown sources and keeps raw flags, credentials, keys, cookies, and reusable secrets out of the rendered blog.

100% coverage
Evidence verdict

High confidence: the page is reconstructed from a primary walkthrough plus multiple supporting notes or evidence sources. Treat the chain as source-backed, while still checking the listed source files for sensitive values.

  • Forensics/Red-Failure/writeup.md
  • htb-challenge/Forensics/Red-Failure/notes.md
  • htb-challenge/Forensics/Red-Failure/memory-summary.md
  • htb-challenge/Forensics/Red-Failure/hypothesis-board.md

Technical Walkthrough

Writeup

Challenge

  • Name: Red-Failure
  • Category: Forensics
  • Difficulty: Medium
  • Mode: file

Summary

The capture shows a staged Windows payload delivery chain. A PowerShell loader

downloads a DInjector assembly and an encrypted shellcode blob, then runs the

blob with currentthread. Reconstructing the HTTP responses, recovering the

loader decryption material, decrypting the DInjector stage, and emulating the

x86 decoder reveals the abandoned persistence command. The flag is the secret

value set for the left-behind local administrator user.

Artifact Inventory

The provided archive extracts to files/extracted/capture.pcap. Local

reassembly recovered three HTTP objects under analysis/extracted-http/:

  • 4A7xH.ps1: obfuscated PowerShell loader.
  • user32.dll: .NET DInjector assembly loaded reflectively by the script.
  • 9tVI0: encrypted shellcode stage.

Analysis

analysis/pcap/http-ascii.txt and the reproducible extractor in

solve/solve.py show the HTTP transfer sequence from <TARGET>:80.

The loader constructs a command equivalent to a DInjector currentthread

execution path, with /sc pointing to /9tVI0, /dll set to

msvcp_win.dll, and decryption material assembled from string fragments.

Direct-source review of analysis/research/dinjector-encrypt.py matched the

local behavior: the encrypted stage is IV-prefixed AES-CBC using a SHA-256 hash

of the loader-supplied secret and PKCS7 padding. Decrypting 9tVI0 with the

recovered material produced an x86 encoded payload.

The first stage is an additive-XOR self-modifying decoder. It starts with a

mov esi, imm32 key, uses the 0x48 loop count, decodes from offset 0x19,

and turns the first decoded dword into a loop instruction. After 72 dwords are

decoded, the resulting stage contains the persistence command. The safe

redacted output is stored at analysis/extracted-http/9tVI0.stage2.redacted.txt.

The raw decoded shellcode is kept only in loot/.

Solve

Run:

bash
python3 Forensics/Red-Failure/solve/solve.py

The script:

  1. Parses the classic little-endian PCAP and reassembles TCP streams.
  2. Extracts HTTP response bodies into analysis/extracted-http/.
  3. Recovers the DInjector decryption material from the PowerShell loader.
  4. Decrypts 9tVI0 as IV-prefixed AES-CBC.
  5. Emulates the x86 decoder loop and searches the decoded stage for the flag.
  6. Writes the candidate to loot/flag-candidate.txt.

Flag

Raw flag is stored in loot/flag.txt and intentionally not reproduced here.

Lessons

  • For staged payload PCAPs, reconstruct the loader command before carving the

second stage; the command often contains the decryption material.

  • DInjector payloads can be validated from the loader arguments plus the

upstream encryptor format before attempting deeper shellcode analysis.

  • Keep decoded shellcode that contains embedded flags under loot/, and store

only redacted views under analysis/.

Source-Backed Dossier

The sections below are merged from companion Markdown notes for the same case. They are rendered after sanitization so the article stays precise without publishing raw flags, credentials, or target-specific secrets.

Notes

Scope

  • Challenge: Red-Failure
  • Category: Forensics
  • Difficulty: Medium
  • Mode: file
  • Remote instance: none
  • Start time: 2026-06-13T08:17:40Z
  • Operator: harness
  • State file: challenge-state.json

Harness Status

  • Current phase: see challenge-state.json
  • Next allowed actions: see next-action.json
  • Raw flags and sensitive material stay in loot/ only. Do not paste them here.

Artifact Inventory

FileSizeSHA256TypeNotes
files/a12c7364-45e9-41b7-8fe2-dcc40c3b7eb4.zip51188<hash redacted>Zip archive data, at least v2.0 to extract, compression method=deflatezip entries: 1 shown in artifact inventory JSON

Evidence Ledger

TimeActionOutput/FileFindingConfidenceNext
2026-06-13T08:17:40Zharness initchallenge-state.jsonWorkspace initialized with deterministic state fileHighInventory artifacts
2026-06-13T08:17:41Zartifact inventoryanalysis/artifact-inventory.json1 artifact(s) inventoriedHighBuild or update hypotheses
2026-06-13T08:18:01Zhypothesis recordedhypothesis-board.mdReconstruct application-layer artifacts from the PCAP and identify a leftover persistence mechanism or malicious artifact that encodes the flag.MediumExtract protocols, conversations, HTTP/DNS/TCP payload strings, and file transfers from capture.pcap before attempting any decoding.
2026-06-13T08:18:01Zresearch taskanalysis/research/task-20260613T081801999021Z-474315ef.mdResearch task created for advisory investigationMediumRecord research output
2026-06-13T08:18:02Zinstrumentation plananalysis/instrumentation-plan.mdRecover the flag by reconstructing malicious/persistence artifacts from capture.pcap.HighStop after two parsing branches produce no new protocol or payload evidence; record closed branches and reassess with RAG/local memory.
2026-06-13T08:18:30Zcheckpoint recordedanalysis/checkpoint-hypothesis_ready-20260613T081830912218Z-32f5267d.mdCheckpoint for <secret redacted>HighUse checkpoint to drive next decision
2026-06-13T08:18:49ZRAG queryanalysis/rag/rag-query-20260613T081830974192Z-9795cf15.txtRAG helper exited 0; output savedMediumRecord retrieval tag and validation
2026-06-13T08:19:16ZRAG recordanalysis/rag-records.mdRetrieved memory tagged GENERICMediumValidate or reject with live evidence
2026-06-13T08:26:46Zresearch recordanalysis/research/research-records.mdResearch tagged MATCHEDMediumValidate against current evidence
2026-06-13T08:26:56Zevaluatoranalysis/evaluator-20260613T082656459316Z-4fc80c2e.mdProceedHighCapture the validated flag candidate and complete the harness.
2026-06-13T08:26:56Zflag captureloot/flag.txtHTB-format flag captured; raw value kept in loot onlyHighWrite solution and run completion gate
2026-06-13T08:30:02Zcompletion gatechallenge-state.jsonCompletion gate passed; state marked COMPLETEHighOptional sanitized memory summary approval

Key Findings

  • The PCAP contained three HTTP-delivered artifacts from <TARGET>:80: a PowerShell loader (4A7xH.ps1), a .NET DInjector DLL (user32.dll), and an encrypted stage (9tVI0).
  • The PowerShell loader builds a DInjector currentthread command, recovers the stage decryption material through string formatting, downloads user32.dll, and invokes DInjector.Detonator.Boom.
  • Direct-source review of DInjector's encrypt.py matched the local artifact behavior: the stage is IV-prefixed AES-CBC using a SHA-256 hash of the loader-supplied secret and PKCS7-padded shellcode.
  • AES-CBC decryption produced an x86 encoded payload. The decoder stub self-modifies offset 0x19 into a loop instruction and decodes 72 dwords through the end of the shellcode.
  • The decoded stage contains the leftover persistence command: create a local user, set its secret value to the flag, and add that user to the local administrators group.
  • Raw decoded shellcode and raw flag material are stored only under loot/; analysis/extracted-http/9tVI0.stage2.redacted.txt contains the safe redacted view.

RAG / Advisory Memory

RAG output is advisory only. Record evaluated retrievals with:

bash
scripts/challenge_harness.py rag-record <workspace> --query "..." --tag MATCHED|PARTIAL|MISSING|<secret redacted>|GENERIC --validation "..."

Secrets/Flags

Raw flags and sensitive material stay in loot/ only. Use scripts/challenge_harness.py capture-flag to validate and record flag capture without printing the value.

Memory Summary

Metadata

  • Platform: HackTheBox Challenges
  • Category: Forensics
  • Challenge: Red-Failure
  • Difficulty: Medium
  • Source workspace: <local workspace>

Validated Solve Chain

Concepts only. Do not include raw flags, reusable credentials, tokens, cookies, private keys, or live secrets.

  1. Reassemble HTTP responses from the PCAP to recover the PowerShell loader, DInjector assembly, and encrypted stage.
  2. Deobfuscate the loader enough to recover the DInjector command and decryption material.
  3. Use the DInjector encryptor format as advisory support: IV-prefixed AES-CBC with a SHA-256-derived key and PKCS7 padding.
  4. Decrypt the stage, then emulate the x86 additive-XOR self-modifying decoder loop.
  5. Inspect the decoded stage for the persistence command; the flag is embedded as the secret value used in that command.

Reusable Lessons

  • Forensics payload captures often require chaining packet reconstruction, script deobfuscation, tool-format validation, and shellcode decoding.
  • DInjector-style encrypted stages should be checked for IV-prefixed AES-CBC when a loader supplies decryption material through /password or /p.
  • Shikata/SGN-style shellcode may decode by modifying the loop instruction itself; emulate the decoder loop instead of relying only on static strings.
  • Store raw decoded shellcode under loot/ if it contains flag material; keep redacted decoded views in analysis/.

Dead Ends

  • Direct strings on the encrypted stage and first decrypted stage did not expose the flag.
  • Treating 9tVI0 as the file-reported OpenPGP public key type was misleading; the local loader and DInjector context showed it was encrypted shellcode.

Tool Quirks

  • The local macOS environment lacked tshark, binwalk, exiftool, native .NET tooling, and a raw x86 disassembler.
  • A short local Capstone virtualenv was used for confirmation, then removed. The final solve script does not require Capstone.
  • tcpdump, Python PCAP parsing, and Python cryptography were sufficient for the final reproducible solve.

Evidence Paths

  • analysis/pcap/http-ascii.txt
  • analysis/extracted-http/4A7xH.ps1
  • analysis/extracted-http/user32.dll
  • analysis/extracted-http/9tVI0
  • analysis/extracted-http/9tVI0.decrypted.bin
  • analysis/extracted-http/9tVI0.stage2.redacted.txt
  • analysis/research/dinjector-encrypt.py
  • solve/solve.py
  • loot/flag.txt

Ingestion Decision

  • Proposed for LightRAG: yes
  • Requires user approval before ingestion: yes

Hypothesis Board

Keep no more than 3 active hypotheses on Easy/Medium and 5 on Hard unless the user explicitly asks for breadth.

RankPathEvidenceMissing ProofCheapest ValidationConfidenceStatus
1Reconstruct application-layer artifacts from the PCAP and identify a leftover persistence mechanism or malicious artifact that encodes the flag.The challenge scenario says engineers found leftover artifacts and asks to investigate a network capture for active persistence.Extract protocols, conversations, HTTP/DNS/TCP payload strings, and file transfers from capture.pcap before attempting any decoding.MediumActive

Closed Branches

BranchEvidence TestedFailure OutputReason ClosedRevisit Condition

Technical analogy

How to remember this solve

Think of the challenge as a small system with one rule that matters more than the rest. The solve is finding that rule, validating it, and using it carefully enough to reach the final proof.

For Red Failure, keep the mental model simple: identify the trusted assumption, prove it with the smallest safe test, then automate or repeat only the part that directly leads to the flag.