// HackTheBox  ·  writeup

Origins

HackTheBox Very Easy tsharkWiresharkpdftotextPython
DFIR

Scenario

You are provided with a minimal PCAP file. Your goal is to find evidence of brute force and data exfiltration.

Executive Summary

A single external host brute-forced the FTP service on a backup server, then logged in with the credentials it found. Once inside, it downloaded files with RETR, each over its own passive-mode data connection. Because FTP is clear text, the capture alone held the file contents. One was a maintenance notice that carried the password for a separate backup SSH server, which turns one compromised service into a second one. The other was an inventory of cloud storage buckets with an internal mailbox address, useful material for follow-on social engineering.

Artifacts

Timestamp note: Wireshark’s frame.time kept displaying the capture in the +1000 local offset even with UTC time formatting selected. Convert by hand before submitting a YYYY-MM-DD hh:mm:ss answer.

Reconnaissance

Q1 — What is the attacker's IP address?

Start with a TCP conversation summary restricted to FTP. One external host is behind all the traffic to port 21 on the internal server 172.31.45.144, with a long run of short connections that point to guessing rather than a person typing.

tshark -r ftp.pcap -q -z conv,tcp
Click flag to reveal 15.206.185.207
Q2 — It's critical to get more knowledge about the attackers, even if it's low fidelity. Using the geolocation data of the IP address used by the attackers, what city do they belong to?

Look the Q1 address up in ipinfo.io. It resolves to AWS space in ap-south-1, and the city field gives the answer. Geolocation of cloud ranges is coarse, so treat the city as context and not as attribution.

Click to reveal answer Mumbai
Q3 — Which FTP application was used by the backup server? Enter the full name and version. (Format: Name Version)

The server announces itself in its 220 greeting at the start of every control connection, so the banner is the cheapest place to read the software and version.

tshark -r ftp.pcap -Y 'ftp.response.code == 220' -T fields -e ftp.response.arg
Click flag to reveal vsFTPd 3.0.5

Credential Access

Q4 — The attacker has started a brute force attack on the server. When did this attack start?

The brute force begins at the first USER command from the Q1 address. Pull it with its timestamp. Wireshark shows it as 14:12:54 with a +1000 offset, so subtract ten hours to get UTC.

tshark -r ftp.pcap -Y 'ftp.request.command == "USER"' -T fields -e frame.time -e ip.src -e ftp.request.arg

Gotcha: The displayed time stays in local time even with UTC formatting selected. Reporting 14:12:54 gives the right second on the wrong day-part.

Click to reveal answer 2024-05-03 04:12:54

Initial Access

Q5 — What are the correct credentials that gave the attacker access? (Format username:password)

Failed guesses end in 530. Filter for the single 230 Login successful reply, then read back to the USER and PASS commands on that same stream. The successful exchange sits in frames 399 to 409.

tshark -r ftp.pcap -Y 'ftp.response.code == 230 || ftp.request.command == "USER" || ftp.request.command == "PASS"' -T fields -e frame.number -e ftp.request.command -e ftp.request.arg -e ftp.response.code
Click flag to reveal forela-ftp:ftprocks69$

Exfiltration

Q6 — The attacker has exfiltrated files from the server. What is the FTP command used to download the remote files?

After the Q5 login, list the FTP commands on the control channel. The downloads are the retrieve command, seen in frames 462 and 492. The control channel only names the files. The content travels on separate data connections.

tshark -r ftp.pcap -Y 'ftp.request.command' -T fields -e frame.number -e ftp.request.command -e ftp.request.arg
Click to reveal answer RETR

Collection

Q7 — Attackers were able to compromise the credentials of a backup SSH server. What is the password for this SSH server?

Passive mode puts every transfer on its own port, announced in the 227 PASV reply. Read those replies to map ports to transfers, then dump the small data streams. The stream on port 9759 is a PDF, Maintenance-Notice.pdf. Carve it from the stream and run pdftotext; the notice contains the SSH backup server password.

tshark -r ftp.pcap -Y 'ftp.response.code == 227' -T fields -e frame.number -e ftp.response.arg
tshark -r ftp.pcap -q -z follow,tcp,raw,<stream-index>
pdftotext Maintenance-Notice.pdf -

Gotcha: The format hint is 15 characters. The asterisks around the password in the document are part of it, not PDF markup, and leaving them off is a wrong answer.

Click flag to reveal **B@ckup2024!**
Q8 — What is the s3 bucket URL for the data archive from 2023?

The second useful transfer is on port 23530: a plain text file, s3_buckets.txt. Follow that data stream and read it; the 2023 archive bucket is listed there.

tshark -r ftp.pcap -q -z follow,tcp,ascii,<stream-index>
Click to reveal answer https://2023-coldstorage.s3.amazonaws.com
Q9 — The scope of the incident is huge as Forela's s3 buckets were also compromised and several GB of data were stolen and leaked. It was also discovered that the attackers used social engineering to gain access to sensitive data and extort it. What is the internal email address used by the attacker in the phishing email to gain access to sensitive data stored on s3 buckets?

The same s3_buckets.txt from Q8 also holds an internal mailbox address. The PCAP does not contain the phishing email itself, so the link between that address and the phishing is the question’s premise, not something the capture shows.

Tip: No new artifact needed. Re-read the Q8 stream in full before hunting elsewhere.

Click flag to reveal [email protected]

Attack Summary

PhaseAction
Credential AccessFTP password guessing against vsFTPd from one external IP
Initial AccessSuccessful 230 login with the guessed credentials
ExfiltrationFiles pulled with RETR over passive-mode data connections
CollectionMaintenance-Notice.pdf and s3_buckets.txt taken from the FTP server
Credential AccessSSH backup server password recovered from the PDF

IOCs

TypeValue
IP (attacker)15.206.185[.]207
IP (victim FTP server)172.31.45[.]144
Accountforela-ftp
FileMaintenance-Notice.pdf
Files3_buckets.txt
Buckethxxps[://]2023-coldstorage[.]s3[.]amazonaws[.]com
Emailarchivebackups@forela[.]co[.]uk

MITRE ATT&CK

TechniqueIDDescription
Brute Force: Password GuessingT1110.001Repeated USER/PASS attempts against vsFTPd
Valid AccountsT1078Login as forela-ftp once the password was guessed
Data from Information RepositoriesT1213Download of s3_buckets.txt and Maintenance-Notice.pdf
Unsecured Credentials: Credentials In FilesT1552.001SSH backup server password stored in a PDF on the FTP server
Exfiltration Over Alternative ProtocolT1048Files pulled over FTP data connections

Defender Takeaways

Don’t expose plain FTP to the internet. Credentials and file contents crossed the wire in clear text, so a capture alone gave up the password and every file. Use SFTP or FTPS with key or certificate authentication.

Alert on repeated FTP login failures. A burst of failed USER/PASS pairs from one source ahead of a 230 is an easy detection. Lock out or rate limit the source after a handful of failures.

Don’t store credentials in documents on file servers. A maintenance notice carrying the SSH password turned one FTP compromise into a second server. Keep secrets in a vault and rotate anything that sat in a readable file.

Don’t keep cloud asset inventories next to the data. The bucket list and an internal mailbox address gave the attacker targets and a believable sender identity for follow-on social engineering.

Normalise timestamps before reporting. Packet tools can display capture time in the analyst’s local offset, which here shifted the attack start by ten hours.

Conclusion

A guessable FTP password gave the attacker the backup server, and its files gave them a second server’s credentials and a map of the cloud storage. Everything crossed the network in clear text, so the capture holds the whole story.