Lavender
Lavender
Platform: Alfactf | Category: Forensics | Type: Challenge | Difficulty: Medium | OS: NA | Author: D3v0o0Nu11 | Date: 2026-04-26 | Status: Solved Techniques: adaptixc2_infrastructure_identification, hfl1_format_reversing, private_key_exfiltration, rsa_oaep_aes_gcm_decryption, sleuthkit_artifact_extraction, svcname_command_injection
Summary
Task: recover an encrypted flag from a split EnCase disk image containing ransomware artifacts and an AdaptixC2 agent. Solution: extract the evidence with Sleuth Kit, identify the HFL1 hybrid format and the AdaptixC2 endpoint, exploit svcname injection to steal the correct private key, then decrypt flag.txt.GSenc.
Recon
Port scan
bash read-only • copy allowednmap -p- -sV -sC <TARGET> --min-rate 1000 -Pn
| Port | Service | Version | Notes |
|---|---|---|---|
| <PORT> | <SVC> | <VER> | <notes> |
Enumeration highlights
- Event:
alfactf| ID:20260426_alfactf_lavender - Tags: command_injection, ext4, disk_forensics, sleuth_kit, ransomware, hybrid_encryption, aes_gcm, encase, rsa_oaep, adaptixc2
- Indicators: EnCase image split into CAFE.E01 and CAFE.E02, encrypted target file stored as flag.txt.GSenc, HFL1 magic in encrypted file header, agent.bin links the case to AdaptixC2, teamserver endpoint resolves to lab.gigashad.xyz:4321
- Source:
20260426_alfactf_lavender.md
Foothold
Vulnerability / Misconfiguration
- adaptixc2_infrastructure_identification
- hfl1_format_reversing
- private_key_exfiltration
- rsa_oaep_aes_gcm_decryption
- sleuthkit_artifact_extraction
bash read-only • copy allowed<command>
Exploitation
- See original writeup content for detailed exploitation.
Privilege Escalation
Enumeration
bash read-only • copy allowedsudo -l find / -perm -4000 2>/dev/null getcap -r / 2>/dev/null cat /etc/crontab ps aux
Exploitation
- N/A for challenge-type writeup; see exploitation above.
- Flag obtained via challenge solve.
bash read-only • copy allowed<command>
Flags
| Flag | Location | Value |
|---|---|---|
| flag | REDACTED |
Key Takeaways / Lessons
- adaptixc2_infrastructure_identification
- hfl1_format_reversing
- private_key_exfiltration
- rsa_oaep_aes_gcm_decryption
- sleuthkit_artifact_extraction
- svcname_command_injection
- Tags: command_injection, ext4, disk_forensics, sleuth_kit, ransomware, hybrid_encryption, aes_gcm, encase, rsa_oaep, adaptixc2
Original Writeup
<details><summary>Click to expand original content</summary>Original task name: Хак на лавандовом
Category: forensics
Status: solved
Flag: alfa{REDACTED}
Summary
The challenge starts with a split EnCase disk image and ends with decrypting a ransomware-encrypted flag. The successful path is: extract the interesting files from CAFE.E01 / CAFE.E02 with Sleuth Kit, recognize the HFL1 / GS-encrypt hybrid format, identify the attacker infrastructure as AdaptixC2 at lab.gigashad.xyz:4321, exploit the svcname injection in AdaptixC2 v0.1, recover /DECRYPTION_KEYS/Northwind_Coffee_Roasters/private.pem, and decrypt flag.txt.GSenc with decrypt.py.
Stage 1: Extract artifacts from CAFE.E01 / CAFE.E02
After unpacking the archive, the main evidence is a split EnCase image:
CAFE.E01CAFE.E02
The useful filesystem is accessible with Sleuth Kit at offset 2048. A quick recursive listing is enough to identify the important files:
bash read-only • copy allowedfls -o 2048 -r "CAFE.E01" | rg "flag\.txt\.GSenc|GS-encrypt|agent\.bin|journal"
The relevant artifacts are:
flag.txt.GSencGS-encryptagent.bin- journal files with execution traces
The encrypted flag can then be extracted directly by inode:
bash read-only • copy allowedicat -o 2048 "CAFE.E01" 913947 > "flag.txt.GSenc"
This establishes that the target is not plain text inside the image: the real task is to recover the decryption key.
Stage 2: Understand the HFL1 / GS-encrypt format
Reversing GS-encrypt shows that the encrypted file uses a hybrid scheme. The flag.txt.GSenc header starts with HFL1, and the format stores a wrapped symmetric key plus the data needed for AES-GCM decryption.
The structure is:
text read-only • copy allowedmagic[4] = "HFL1" version u8 keyAlgo u8 dataAlgo u8 wrappedKeyLen u16 BE nonceLen u16 BE ciphertextLen u32 BE wrappedKey[wrappedKeyLen] nonce[nonceLen] ciphertext[ciphertextLen]
The values observed during decryption are:
text read-only • copy allowedversion=1 keyAlgo=1 dataAlgo=1 wrapped=256 nonce=12 ct=51
This corresponds to:
- RSA-OAEP-SHA256 for key wrapping
- AES-256-GCM for file encryption
So the remaining requirement is the correct RSA private key for the victim.
Stage 3: Identify AdaptixC2 and the endpoint
The extracted agent.bin links the incident to AdaptixC2. The reproduced analysis identifies the relevant teamserver as:
text read-only • copy allowedlab.gigashad.xyz:4321
The version matters: this is AdaptixC2 v0.1, which is vulnerable in the agent generation flow. That turns the investigation from passive forensics into active key recovery.
Stage 4: Exploit svcname injection in AdaptixC2 v0.1
The vulnerable behavior is in the agent generation endpoint, where svcname is passed into a shell command. Because the value is not safely handled, it is possible to break out of the intended context and execute arbitrary commands.
The payload concept is:
text read-only • copy allowed'; (CMD) 1>&2; false; #
This works because it:
- breaks the quoted
svcnamevalue, - runs attacker-controlled shell code,
- redirects output into the error path so it can be read back.
The first useful probe is to verify command execution and inspect the directory that stores decryption keys:
bash read-only • copy allowedpython3 "alfactf2026-writeups/lavender/artifacts/exploit.py" "id; uname -a; pwd; ls -la /DECRYPTION_KEYS"
That confirms both RCE and the presence of the key store.
Stage 5: Extract the correct private key
The needed key is the one for Northwind Coffee Roasters. It can be exfiltrated directly from the server with:
bash read-only • copy allowedpython3 "alfactf2026-writeups/lavender/artifacts/exploit.py" "cat /DECRYPTION_KEYS/Northwind_Coffee_Roasters/private.pem; echo __END__"
The recovered key is saved locally as private.pem. This is the critical bridge between the disk image and the attacker infrastructure: the encrypted file from the image can now be decrypted with the private key stolen from the C2 environment.
Stage 6: Decrypt flag.txt.GSenc
With both files available locally:
flag.txt.GSencprivate.pem
the final step is:
bash read-only • copy allowedpython3 "alfactf2026-writeups/lavender/artifacts/decrypt.py" "flag.txt.GSenc" "private.pem"
The script parses the HFL1 envelope, unwraps the symmetric key with RSA-OAEP, and decrypts the ciphertext with AES-GCM.
The plaintext is:
text read-only • copy allowedalfa{REDACTED}
Final Flag
text read-only • copy allowedalfa{REDACTED}
Notes
- The writeup was normalized to the local house format used in this repository.
- The solution flow is fully consistent with the extracted disk artifacts and the reproduced AdaptixC2 exploitation path.
signed by XESXOR