// HackTheBox  ·  writeup

Hijacked

HackTheBox Medium Volatility3strings7-ZipJohn the RipperHashcat
DFIR

Scenario

In this Sherlock, players are expected to utilize different forensic tools on a memory image from a compromised workstation to analyze a full cyber attack and obtain necessary information.

Executive Summary

A user at Forela read a phishing email in a Firefox webmail tab. The sender posed as a colleague and attached a password-protected zip with a second protected zip inside it, with both passwords given in the message body. Opening the archive with WinRAR dropped an HTA whose embedded PowerShell was an Empire stager, which gave the attacker a foothold over the first C2. For privilege escalation a DLL from the user’s Temp folder was injected into a svchost service process, which spawned a rundll32 that beaconed to a second C2. The attacker then used certutil to pull a batch script that harvested office documents and archived them with a password, installed TeamViewer for persistence and created a local backdoor account. The tradecraft and regional targeting point to a known China-nexus group.

Artifacts

Tool note: strings in both ASCII and UTF-16LE (-el) was the most productive tool on this image. The phishing email, the certutil URL, the batch stager and the RAR password all surfaced there before any plugin found them.

Initial Access

Q2 — There is no evidence of an email client being used. Which application did Happy Grunwald use to read the emails?

No mail client in the process list, so the mail was read in a browser. strings over the dump shows Zoho Mail URLs (mail.zoho.eu) in the memory of the firefox.exe profile, which names the browser.

strings -a -n8 Dump.mem > s8.txt; strings -a -n8 -el Dump.mem > s16.txt; grep -a 'mail.zoho' s8.txt s16.txt | head
Click flag to reveal firefox
Q3 — Happy told the security team that the email was from a System Administrator, so he immediately opened the attachment. What is the email address that sent the phishing email?

With the webmail identified in Q2, search the UTF-16 strings for the Zoho message rendering. The sender sits in browser memory as a display name plus address.

grep -a 'forela.co.uk' s16.txt | grep -ai 'alonzo'
Click flag to reveal [email protected]
Q4 — What was the subject/topic of the phishing email?

The subject sits in the same Zoho message fragment recovered for Q3. Read the lines around the sender hit in s16.txt.

grep -a -B3 -A8 '[email protected]' s16.txt | head -40
Click to reveal answer Meeting with The New Operations team
Q8 — What's the name of the malicious attachment that led to the initial infection?

The WinRAR command line in the process list references the downloaded archive in the user’s Downloads folder, and the Zoho message lists the same name as its attachment.

vol -f Dump.mem windows.cmdline | grep -i winrar
Click to reveal answer SystemHealthCheck.zip
Q10 — To bypass email filters the attacker password protected the both of the zip files and provided the passwords to Happy. You are given the malicious attachment, but sadly Happy doesn't remember the passwords. Recover the passwords and provide them in the order given by the attacker, separated by a comma and a space.

The email body is still in browser memory, so searching the strings for zip near pass recovers the wording the attacker used. The passwords are confirmed by extraction: the outer First.zip opens with the first, the nested Second.zip with the second. zip2john plus rockyou is the fallback if the body had not survived.

grep -aiE '(zip|archive).{0,25}pass' s8.txt s16.txt
7z x -pforela1234 First.zip && 7z x -pforela123 Second.zip

Gotcha: unzip fails on these archives because they use AES encryption (method 99). Use 7z.

Click to reveal answer forela1234, forela123
Q9 — What's the name of the malicious stager file that established C2 communication, giving the attacker a foothold?

Extracting the nested archives from Q10 yields a single file, an HTA. Its body is a PowerShell launcher with -enc, identical to the command line of the powershell.exe process found in Q1.

ls -la; head -c 600 SystemHealthCheck.hta
Click flag to reveal SystemHealthCheck.hta
Q11 — Submit the MD5 hash of the stager file you retrieved.

Hash the HTA extracted from the two zips in Q10.

md5sum SystemHealthCheck.hta
Click flag to reveal dd46189c153f8e3f4d34868df3f6511f
Q5 — Happy was going through a document at the time of the incident. What's the full path of the document?

Word was open when the image was taken. The command line of WINWORD.EXE (PID 9888) carries the document path as its argument.

vol -f Dump.mem windows.cmdline | grep -i winword
Click flag to reveal C:\Users\happy.grunwald\Documents\C-level\Budget-Plan_Pakistan.docx
Q6 — Recover the document and find the Topic/heading of the document.

Find the docx in filescan, carve it with dumpfiles using the virtual address, then unzip the docx and read the first heading out of word/document.xml.

vol -f Dump.mem -o dump windows.dumpfiles --virtaddr <docx offset>
unzip b.docx -d docx && python3 -I -c "import re,sys;print(re.findall(r'<w:t[^>]*>([^<]+)', open(sys.argv[1],encoding='utf8').read())[:5])" docx/word/document.xml
Click to reveal answer Budget plan For 2023-Asia Expansion
Q7 — What's the expected date of start of business in Pakistan?

The last paragraph of the document recovered in Q6 states that the Pakistan operation will be fully under way by a specific date. Print the document text and read it from the end.

python3 -I -c "import re,sys;print(re.findall(r'<w:t[^>]*>([^<]+)', open(sys.argv[1],encoding='utf8').read())[-3:])" docx/word/document.xml
Click flag to reveal 2023-09-15

Execution

Q1 — What is the PID of the malicious process that gave the threat actor initial access?

Walk the process list after WinRAR opened the archive. A powershell.exe started right after it, with -noP -sta -w 1 -enc and a long base64 blob, the shape of an Empire launcher. That blob matches the one inside the HTA from Q9.

vol -f Dump.mem windows.pslist > pslist.txt; vol -f Dump.mem windows.cmdline > cmdline.txt; grep -i 'powershell' cmdline.txt
Click flag to reveal 9620

Command and Control

Q12 — Which C2 Framework was used by the attacker?

Decode the -enc argument from PID 9620 (UTF-16LE base64). The script is an RC4-decrypting launcher that sets a Cookie header and requests /news.php, the default Empire stager layout.

grep 9620 cmdline.txt | grep -oE '[A-Za-z0-9+/=]{200,}' | base64 -d | iconv -f utf-16le -t utf-8 > ps_dec.txt
Click to reveal answer Empire
Q16 — The attacker connected to 2 different C2 addresses. What was the C2 IP and port number pair which facilitated initial remote access to the threat actor?

The decoded stager from Q12 holds the server address as a second base64 string. netscan confirms it: the connection is owned by the PowerShell process 9620.

vol -f Dump.mem windows.netscan | grep -E '9620|powershell'
Click to reveal answer 43.204.228.96:24
Q17 — Hunt for the second C2 Address to which connection was made by a LOLBIN after escalating privileges.

After the escalation in Q13 the svchost process has a rundll32.exe child (PID 3932). Rundll32 is the LOLBin, and netscan shows it connected out on port 4444 to a different address from Q16.

vol -f Dump.mem windows.netscan | grep 3932
Click flag to reveal 13.233.33.88:4444
Q18 — The attacker directly downloaded a script from a web server. What is the full URL from where it was downloaded?

Command lines that never reached the process list still sit in memory. Searching the strings for certutil finds a -urlcache -f download of a batch file from a third address.

grep -aE 'certutil|net user' s8.txt s16.txt
Click to reveal answer http://13.127.18.201/SystemIntegrityCheck.bat

Privilege Escalation

Q13 — What is the PID of the process the threat actor abused for privilege escalation?

Look for a service host that is the parent of the second-stage rundll32 (PID 3932). It is an svchost.exe started with -k UnistackSvcGroup, a service group that is not part of a stock Windows install, and it has a user-writable DLL loaded.

vol -f Dump.mem windows.pslist | grep -E 'svchost|rundll32'
Click flag to reveal 4352
Q14 — What is the path of the malicious file that resulted in privilege escalation?

List the DLLs loaded in the service host from Q13. Every other module comes from System32; one comes from the user’s Temp folder.

vol -f Dump.mem windows.dlllist --pid 4352
Click flag to reveal C:\Users\happy.grunwald\AppData\Local\Temp\Winsrvc.dll
Q15 — What is the Mitre sub-technique ID with which the attacker escalated their privileges?

A DLL from a user-writable Temp path loaded into a privileged svchost process, with a child beacon appearing from it, is DLL injection under Process Injection. This was reasoned from the module list in Q14 rather than read from a single artifact, and HTB accepted it.

Gotcha: UnistackSvcGroup is a known DLL search-order hijacking target (HackTricks writable SYSTEM PATH DLL hijacking), which pulls you toward the T1574.x family. None of those fit: the evidence shows a DLL placed in Temp and loaded into a running service process, not a missing-DLL lookup being satisfied.

Click flag to reveal T1055.001

Collection

Q19 — The threat actor that performed the attack is known for automating the collection of documents and files from compromised systems. The threat actor named their operation against Forela "PK-OPR24." Our reverse engineer said that she found this string commented on multiple occurrences in the analysis of the malicious stager. Reverse the script and provide the file extensions that it collects, in the order they are presented in the code.

The downloaded batch script from Q18 is still in memory in readable form. Search for the operation tag and the LootDocs staging folder, then read the for /r loops that copy files by extension in the order they appear.

grep -anE 'PK-OPR24|LootDocs' s8.txt s16.txt
Click flag to reveal docx, docm, pdf, xls, txt, ppt, xlsx, pptx
Q20 — The threat actor archived the collected data using tools like WinRAR, RAR, etc., before exfiltrating it. What is the password with which the TA archived the collected data?

The same script archives the staging folder with Rar.exe a. The -p switch carries the password in clear on the command line.

grep -aE 'Rar\.exe' s8.txt s16.txt
Click to reveal answer rwajnkhgbdtyalmd

Persistence

Q21 — The threat actor is known to set up and use Remote Access tools. Which tool did the attacker set up for Persistence?

The process list contains TeamViewer_Service and TeamViewer.exe, and the strings show bitsadmin and certutil downloads around the install. TeamViewer is not part of the victim’s normal software, so it is the attacker’s remote access channel.

vol -f Dump.mem windows.pslist | grep -i teamviewer
Click flag to reveal Teamviewer
Q22 — The threat actor created a backdoor user to establish a backup persistence mechanism. What are the credentials of this account?

The account creation command never turned up in the strings, so go to the SAM. hashdump lists the local accounts, and RID 1003 is helpdesk, which is not a normal user on this host. Crack its NT hash against rockyou to get the password.

vol -f Dump.mem windows.hashdump
hashcat -m 1000 nt.txt /usr/share/dict/rockyou.txt
Click to reveal answer helpdesk:BILA@hud

Attribution

Q23 — What Threat Actor seems to be in question? External Research is required, so keep in mind things like some of the techniques you identified so far, the Region in which they operate, etc.

This was reasoned, not read from an artifact. The combination that pointed to this group was a document-harvesting script tagged with a Pakistan-themed operation name, a lure about South Asian expansion, Empire for the foothold and a remote access tool for persistence, plus the character-count mask on the answer.

Tip: Nothing in the memory image names the actor. Take the operation tag, the targeting region and the document-collection tooling to threat-intel reports and match on those.

Click flag to reveal Mustang Panda

Attack Summary

PhaseAction
Initial AccessPhishing email in Zoho webmail (Firefox) with a nested password-protected zip, passwords in the body
ExecutionWinRAR opens the archive; the HTA runs an encoded PowerShell Empire stager (PID 9620)
Command and ControlStager beacons to the first C2 over a non-standard port
Privilege EscalationWinsrvc.dll from Temp injected into an svchost service group process
Command and Controlrundll32 child of that service connects to a second C2 on port 4444
Command and Controlcertutil downloads a batch script from a third host
CollectionScript harvests eight document extensions into a staging folder
CollectionStaged data archived with Rar.exe using a password
PersistenceTeamViewer installed for remote access
PersistenceLocal account helpdesk created as a backup

IOCs

TypeValue
Emailalonzo.spire@forela[.]co[.]uk
FileSystemHealthCheck.zip (outer, nested First.zip / Second.zip)
FileSystemHealthCheck.hta (MD5 dd46189c153f8e3f4d34868df3f6511f)
FileC:\Users\happy.grunwald\AppData\Local\Temp\Winsrvc.dll
C243.204.228[.]96:24
C213.233.33[.]88:4444
URLhxxp[://]13[.]127[.]18[.]201/SystemIntegrityCheck[.]bat
Passwordszips forela1234, forela123; RAR rwajnkhgbdtyalmd
Accounthelpdesk (RID 1003)
ToolTeamViewer

MITRE ATT&CK

TechniqueIDDescription
Phishing: Spearphishing AttachmentT1566.001Password-protected zip delivered through webmail
User Execution: Malicious FileT1204.002User opened the archive and ran the HTA
Command and Scripting Interpreter: PowerShellT1059.001Encoded Empire stager launched from the HTA
Process Injection: Dynamic-link Library InjectionT1055.001Winsrvc.dll loaded into a privileged svchost
Ingress Tool TransferT1105certutil -urlcache -f fetched the batch script
Automated CollectionT1119Batch script harvested documents by extension
Archive Collected Data: Archive via UtilityT1560.001Rar.exe with a password
Remote Access SoftwareT1219TeamViewer for persistent access
Create Account: Local AccountT1136.001helpdesk backdoor user

Defender Takeaways

Nested, password-protected archives defeat mail scanning by design. Giving the passwords in the same message is a strong lure signal. Block or quarantine encrypted archives from external and look-alike senders, and flag a user opening an archive in WinRAR and a script host spawning PowerShell seconds later.

Encoded PowerShell with -noP -sta -w 1 -enc is a detection primitive on its own. The Empire launcher left its full command line in memory and in the process tree. Script block logging and command line auditing would have caught it at the first stage.

A DLL in a user Temp folder loaded by svchost should never happen. Alert on image loads into service hosts from user-writable paths, and on service groups that are not in a baseline. The -k UnistackSvcGroup group name alone was a lead.

certutil with -urlcache and Rar.exe with -p are cheap to detect. Both leave their secrets (a URL and a password) in command lines. Alert on LOLBin downloads and on unapproved archivers running on user machines.

Unapproved remote access tools and new local accounts need an inventory check. TeamViewer on a workstation outside the software list, and a helpdesk account with a weak, crackable password, were both persistence the attacker could use after the C2 was burned.

Conclusion

The attacker went from one phishing click to SYSTEM-level reach, document theft and two independent persistence routes, and almost every step was a built-in or commodity tool. A single memory image still held the email, the stager, both C2s and the archive password, which is why volatile evidence should be collected before the host is cleaned.