// HackTheBox  ·  writeup

OpTinselTrace-4

HackTheBox Easy tshark7-Zip
DFIR

Scenario

Printers are important in Santa’s workshops, but we haven’t really tried to secure them! The Grinch and his team of elite hackers may try and use this against us! Please investigate using the packet capture provided! The printer server IP Address is 192.168.68.128

Executive Summary

One internal host flooded a network printer with traffic after scanning it, and found only the raw print port open. Over that port the attacker spoke PJL, the printer’s own control language, to read the device identity and browse and download files from its internal file system. That gave them confidential print material, including a list of children, a staff dismissal notice and a scheduled job, and, most importantly, an SSH private key stored on the printer. The key’s comment named a separate critical server that was supposed to accept key-only SSH, which is how the printer compromise became a lateral move. The attacker also tried to delete a file from the printer before leaving.

Artifacts

Timestamp note: tshark prints capture times in the local zone of the capture (+11:00). Q10 asks for UTC, so subtract 11 hours.

Discovery

Q1 — The performance of the network printer server has become sluggish, causing interruptions in the workflow at the North Pole workshop. Santa has directed us to generate a support request and examine the network data to pinpoint the source of the issue. He suspects that the Grinch and his group may be involved in this situation. Could you verify if there is an IP Address that is sending an excessive amount of traffic to the printer server?

The zip is AES encrypted (method 99), so plain unzip fails. Extract it with 7-Zip and HTB’s standard archive password, then pull the IP conversation table. Only one host talks to the printer at 192.168.68.128, and it dominates the byte count.

7z x -phacktheblue evidence.zip -owork/pcap
tshark -r work/pcap/capture.pcap -q -z conv,ip
Click flag to reveal 172.17.79.133
Q2 — Bytesparkle being the technical Lead, found traces of port scanning from the same IP identified in previous attack. Which port was then targeted for initial compromise of the printer?

From Q1 the scanner is known. A scan leaves a burst of SYNs to many ports, but only open ports answer with SYN/ACK. Filter for SYN/ACK from the printer and one port stands out, and it is also the one carrying the long PJL streams in the protocol hierarchy.

tshark -r work/pcap/capture.pcap -Y 'ip.src==192.168.68.128 && tcp.flags.syn==1 && tcp.flags.ack==1' -T fields -e tcp.srcport | sort | uniq -c
Click to reveal answer 9100
Q3 — What is the full name of printer running on the server?

Follow the TCP streams to port 9100. The attacker’s PJL @PJL INFO ID request is answered with the printer’s model string.

tshark -r work/pcap/capture.pcap -q -z follow,tcp,ascii,0

Hint: The format mask (********* ** ******** ****n) is the shape of the model string, including the vendor prefix the workshop gave it.

Click flag to reveal NorthPole HP LaserJet 4200n

Collection

Q4 — Grinch intercepted a list of nice and naughty children created by Santa. What was name of the second child on the nice list?

PJL has file-system commands (FSDIRLIST, FSUPLOAD, FSDELETE). Walk the port 9100 streams for FSUPLOAD calls and look for the nice-kids path. The upload of Nice-kids/list1.txt returns the list, and the second entry is the answer.

tshark -r work/pcap/capture.pcap -q -z follow,tcp,ascii,28
Click to reveal answer Douglas Price
Q5 — The Grinch obtained a print job instruction file intended for a printer used by an employee named Elfin. It appears that Santa and the North Pole management team have made the decision to dismiss Elfin. Could you please provide the word for word rationale behind the decision to terminate Elfin's employment?

The job file is a PCL document, Personal-Notice-Employee43.pcl, uploaded in one of the later streams. The reason is plain text inside the PCL body, so follow that stream and copy the sentence exactly, spacing and the odd space before the comma included.

tshark -r work/pcap/capture.pcap -q -z follow,tcp,ascii,46

Gotcha: The format asks for the full string, so partial quotes fail. Copy it exactly as printed, including its spelling and punctuation.

Click flag to reveal The addressed employee is confirmed to be working with grinch and team. According to Clause 69 , This calls for an immediate expulsion.
Q6 — What was the name of the scheduled print job?

A second uploaded file sits under ScheduledJobs/ as Announcment-25Dec.ps. Inside it, the @PJL JOB NAME line carries the job name.

tshark -r work/pcap/capture.pcap -q -z follow,tcp,ascii,71

Gotcha: Two strings are tempting here: the file name and the JOB NAME value. The question asks for the job, so use the JOB NAME value.

Click to reveal answer MerryChristmas+BonusAnnouncment

Credential Access

Q7 — Amidst our ongoing analysis of the current packet capture, the situation has escalated alarmingly. Our security system has detected signs of post-exploitation activities on a highly critical server, which was supposed to be secure with SSH key-only access. This development has raised serious concerns within the security team. While Bytesparkle is investigating the breach, he speculated that this security incident might be connected to the earlier printer issue. Could you determine and provide the complete path of the file on the printer server that enabled the Grinch to laterally move to this critical server?

A key-only SSH server falls to a stolen private key. Search the PJL traffic for key material and follow the stream that holds it. The FSUPLOAD request names the full path, and the response body is an RSA private key.

tshark -r work/pcap/capture.pcap -q -z follow,tcp,ascii,46
Click flag to reveal /Administration/securitykeys/ssh_systems/id_rsa
Q8 — What is size of this file in bytes?

The directory listing the attacker requested before the download reports each file’s size. The FSDIRLIST response for the ssh_systems folder lists id_rsa with its SIZE= value.

tshark -r work/pcap/capture.pcap -q -z follow,tcp,ascii,46 | grep -a 'SIZE='
Click to reveal answer 1914

Lateral Movement

Q9 — What was the hostname of the other compromised critical server?

The server name is in the stolen key itself. Dump the key from the stream and read its trailing comment, which labels it as a backup key for the target host. This was reasoned from that comment rather than read from an observed SSH login, since the capture only shows the key leaving the printer.

grep -a -i -E 'BEGIN|backup key' work/pcap/capture.txt
Click flag to reveal christmas.gifts

Defense Evasion

Q10 — When did the Grinch attempt to delete a file from the printer? (UTC)

Filter for the PJL FSDELETE command and take the frame’s capture time. It is frame 3676 at 23:18:14 on the capture’s +11:00 clock, which is 12:18:14 UTC.

tshark -r work/pcap/capture.pcap -Y 'frame.number==3676' -T fields -e frame.time

Gotcha: tshark shows local time. Submitting the printed 23:18:14 is wrong; the answer needs the 11 hour shift back to UTC.

Click to reveal answer 2023-12-08 12:18:14

Attack Summary

PhaseAction
DiscoveryInternal host 172.17.79.133 floods and port-scans the printer
Initial AccessRaw print service on port 9100 used to issue PJL commands
Discovery@PJL INFO ID reveals the printer model
CollectionFSUPLOAD pulls the nice list, a dismissal notice and a scheduled job file
Credential AccessSSH private key downloaded from the printer’s file system
Lateral MovementKey used toward the key-only server named in its comment
Defense EvasionFSDELETE attempted against a file on the printer

IOCs

TypeValue
IP (attacker)172.17[.]79[.]133
IP (printer)192.168.68[.]128
Port9100/tcp
File (stolen key)/Administration/securitykeys/ssh_systems/id_rsa
FilePersonal-Notice-Employee43.pcl
FileScheduledJobs/Announcment-25Dec.ps
Hostname (target)christmas[.]gifts

MITRE ATT&CK

TechniqueIDDescription
Network Service DiscoveryT1046Port scan of the printer
Exploit Public-Facing ApplicationT1190Unauthenticated PJL access over port 9100
Data from Local SystemT1005FSUPLOAD of print jobs and lists from the printer file system
Unsecured Credentials: Private KeysT1552.004SSH private key stored on the printer
Remote Services: SSHT1021.004Stolen key aimed at a key-only server
Indicator Removal: File DeletionT1070.004FSDELETE against a printer file

Defender Takeaways

Raw port 9100 should not be reachable from general user networks. Any host that can reach it can run PJL file-system commands with no authentication. Restrict it to the print server, and disable PJL file-system access in the printer configuration.

Never store SSH keys on a printer. A key in a device’s file share is a credential an attacker can read with one PJL command. Keep keys off appliances, and rotate any key that has been on one.

Key-only SSH is only as strong as the key’s storage. The critical server’s hardening was bypassed by the key, not by guessing a password. Bind keys to source addresses and alert on key use from unexpected hosts.

Treat printers as monitored assets. A single host with a scan followed by a long 9100 stream is visible in flow data. Alert on high byte counts to printers from a non-print-server source.

Conclusion

The Grinch turned an unmanaged printer into a file server, took an SSH key from it and aimed it at a server that was supposed to be safe behind key-only authentication. The printer’s unauthenticated control language was the whole breach; the hardened server never had a chance once its key was lying on the device.