// HackTheBox  ·  writeup

Jugglin

HackTheBox Medium unzipstringsgrepsedAPI Monitor
DFIR

Scenario

Jugglin is a medium difficulty Sherlock where you are tasked with analysing provided .apmx64 files within API monitor to confirm the actions taken by an attacker and insider threat within the Forela organsiation.

Using the API Monitor:

We are well-acquainted with opening PCAP and .EVTX files, but what are .apmx64? The .apmx64 file extension is associated with API Monitor, a software used to monitor and control API calls made by applications and services.

To commence your analysis, follow the steps provided below:

Executive Summary

An insider on an employee workstation opened a Kali WSL console, ran an identity check, and read two notes that named the Win32 and Rtl string-conversion APIs a defender would need to hook to see WSL activity. The insider then called Windows PowerShell from inside the Linux shell to push data to an external host over HTTP. A second capture shows an attacker in a WSL session trying a credential-dumping tool that was not installed, pulling it from the same external host, and running it to print a domain user’s hash. Because WSL keeps Linux tooling outside the usual Windows process and command-line telemetry, the captures show this activity as console I/O and string-conversion API calls rather than ordinary child processes.

Artifacts

Tip: API Monitor is the intended viewer, but the per-process data blobs are raw captured memory. Running strings over them in both ASCII and UTF-16LE recovers the console text (typed commands, file contents, command output) much faster than clicking through the Summary window.

Format note: Several answers carry a character mask (* for unknown characters, letters fixed). It is a useful sanity check on long names such as the API functions.

Execution

Q3 — Which Linux distribution the insider was interacting with?

Unzip the employee capture and pull ASCII and UTF-16LE strings from every process blob. The WSL console buffer repeats the shell prompt many times, and the user@host part of that prompt names the distribution.

unzip Employee.apmx64 -d work/x/employee
strings -n6 work/x/employee/process/*/data > work/x/employee.txt; strings -n6 -el work/x/employee/process/*/data >> work/x/employee.txt
grep -E '@MSI' work/x/employee.txt | sort | uniq -c | sort -rn | head
Click flag to reveal kali
Q1 — What was the initial command executed by the insider?

From Q3 the console is the Kali prompt, so read the strings around the first occurrence of that prompt. The first thing typed at it is the identity check people run on a fresh shell.

grep -n -m5 -A3 'kali@' work/x/employee.txt

Gotcha: The prompt text is printed before the command. Take what was typed after the prompt, not the prompt itself.

Click flag to reveal whoami
Q9 — Which command executed by the attacker resulted in a 'not found' response?

Unzip the attacker capture, build its strings file the same way, and search for the shell’s error text. Bash names the missing binary in the message, and the attacker then goes and downloads that same binary in Q10.

unzip Attacker.apmx64 -d work/x/attacker
grep -a 'command not found' work/x/attacker.txt
Click flag to reveal lsassy

Collection

Q4 — Which file did the insider access in order to read its contents?

The Kali console buffer from Q1 continues with a directory listing and then a cat of a text file in the home directory.

grep -n -B2 -A4 'cat ' work/x/employee.txt | head -40
Click to reveal answer flag.txt
Q5 — Submit the first flag.

The output of the cat in Q4 is the flag. It is written in leetspeak and spells out an Rtl conversion function, which becomes the lead for Q2.

grep -n -A2 'cat flag.txt' work/x/employee.txt
Click flag to reveal HOOK_tH1$_apI_R7lUNIcoDet0utf8N
Q8 — The insider has also accessed 'confidential.txt'. Please provide the second flag for submission.

Search the same console text for the second file name. Its contents open with a sentence about tracking Windows tools and end with the second flag, which names a different Rtl function from the one in Q5.

grep -n -B2 -A6 'confidential.txt' work/x/employee.txt
Click flag to reveal H0ok_ThIS_@PI_rtlutf8TounICOD3N
Q2 — Which string function can be intercepted to monitor keystrokes by an insider?

This one was reasoned rather than read straight from an artifact. The Q5 flag names RtlUnicodeToUTF8N, the conversion that console input takes on its way into a WSL process, and the answer wants two functions. The second is the Win32 counterpart for the same conversion, WideCharToMultiByte. The evidence pointing here is the flag text plus the two-API format.

Gotcha: The mask gives no letter hints, and plausible pairings built from MultiByteToWideChar and WideCharToMultiByte are wrong. Anchor on the Rtl name from the flag and add its Win32 counterpart.

Click to reveal answer RtlUnicodeToUTF8N, WideCharToMultiByte

Exfiltration

Q6 — Which PowerShell module did the insider utilize to extract data from their machine?

The insider calls Windows PowerShell from inside the WSL console, which is itself the evasion. Search for powershell.exe and read the full command line: a -c one-liner posting to the external host 3.6.165.8. The cmdlet in that line is the answer.

grep -a 'powershell.exe' work/x/employee.txt
Click to reveal answer Invoke-WebRequest

Defense Evasion

Q7 — Which string function can be intercepted to monitor the usage of Windows tools via WSL by an insider?

The note in confidential.txt from Q8 is headed by the tracking-Windows-tools line, and the second flag spells the function in leetspeak. It is the opposite conversion direction from the Q2 function. This was read from the note’s wording, not from a traced call in the capture.

grep -n -i 'windows tools' work/x/employee.txt

Gotcha: RtlUnicodeToUTF8N fits the mask and is the function from the first flag, but it is the wrong direction. Tool invocation from WSL converts UTF-8 to UTF-16, so the name starts RtlUTF8.

Click flag to reveal RtlUTF8ToUnicodeN
Q12 — When an attacker utilizes WSL2, which WIN32 API would you intercept to monitor its behavior?

No capture in this case shows this call directly, so the answer comes from WSL2’s architecture plus the nine-letter mask ending in e. WSL2 runs Linux in a lightweight VM, and traffic between the Windows side and the Linux side moves over pipe and socket handles. The Win32 call that writes to those handles is WriteFile. This is reasoned from reference knowledge, not read from an artifact.

Click to reveal answer WriteFile

Command and Control

Q10 — Which link was utilized to download the 'lsassy' binary?

From Q9 the missing tool is lsassy. In the attacker capture, the wget that follows the error pulls it from the same host the insider’s PowerShell talked to in Q6.

grep -a 'wget' work/x/attacker.txt
Click to reveal answer http://3.6.165.8/lsassy

Credential Access

Q11 — What is the SHA1 hash of victim 'user' ?

After the download, lsassy output is echoed into the attacker console. It prints a [SHA1] tag beside each recovered credential, and the value on the line for the user account is the answer.

grep -a '\[SHA1\]' work/x/attacker.txt
Click flag to reveal e8f97fba9104d1ea5047948e6dfb67facd9f5b73

Attack Summary

PhaseAction
ExecutionInsider opens a Kali WSL console and runs an identity check first
CollectionInsider reads a flag file and a note listing the string APIs to hook
Defense EvasionWindows tools are driven from WSL so activity appears as console I/O and string conversion calls
ExfiltrationInsider calls PowerShell from the WSL shell to send data to an external host over HTTP
ExecutionAttacker session runs lsassy, which is not installed
Command and ControlAttacker fetches lsassy from the external host with wget
Credential Accesslsassy output exposes the SHA1 hash of the user account

IOCs

TypeValue
IP3.6.165[.]8
URLhxxp[://]3[.]6[.]165[.]8/lsassy
Toollsassy
Hash (SHA1, account user)e8f97fba9104d1ea5047948e6dfb67facd9f5b73

MITRE ATT&CK

TechniqueIDDescription
Command and Scripting Interpreter: Unix ShellT1059.004Commands run in a Kali WSL console
Command and Scripting Interpreter: PowerShellT1059.001powershell.exe -c launched from WSL
Indirect Command ExecutionT1202Windows tools run through WSL rather than directly
Input CaptureT1056Keystroke monitoring discussed as hooks on string conversion APIs
Exfiltration Over Alternative ProtocolT1048Data sent to an external host with Invoke-WebRequest
Ingress Tool TransferT1105lsassy downloaded with wget
OS Credential Dumping: LSASS MemoryT1003.001lsassy used to pull credentials from a host

Defender Takeaways

WSL hides Linux tooling from standard Windows process telemetry. The insider and the attacker both ran commands inside a Linux console, so the evidence is console text and API calls rather than process trees. Monitor wsl.exe, bash.exe and the WSL host processes, and alert when they spawn powershell.exe or other Windows binaries.

String conversion APIs are a usable hook point. The notes in this case point at the UTF-16/UTF-8 conversions as the choke point where typed input and Windows tool output cross the WSL boundary. API-level capture of those calls exposes command text that command-line logging never sees.

Treat outbound HTTP to a bare IP from a WSL-launched PowerShell as exfiltration. The Invoke-WebRequest call and the lsassy download both went to the same address. A single egress rule on that host would have tied the insider and the attacker together.

Watch for credential-dumping tools arriving on any endpoint. lsassy is a known LSASS dumper and printed credential hashes straight into a console. Blocking downloads of such tools and alerting on LSASS access closes the step before hashes are printed.

Conclusion

An insider and an attacker both used WSL to keep their commands out of normal Windows telemetry, and the attacker ended by printing a user’s hash with a freshly downloaded lsassy. The case shows that WSL activity has to be monitored at the API or console level, because the process tree will not tell the story.