// HackTheBox  ·  writeup

Compromised_Network_Printer

HackTheBox Easy tshark
DFIR

Scenario

Analyze the compromised network printer as a DFIR analyst.

Executive Summary

An internal host port-scanned a network printer and found its raw print port open. The attacker then spoke PJL directly to the printer over that port, fingerprinted the model, and used the file system commands to walk the printer’s storage. A queued print job tied to a suspected insider was downloaded, and a backup directory on the device turned out to hold an RDP file and an admin PowerShell script. The RDP file gave away the address of an internal jumphost, so a printer with no authentication on its job port became a map to the next hop.

Artifacts

Tip: The printer session is plain text over TCP. Following the stream or dumping the payload as ASCII reads like a console log, so there is no need to carve anything.

Discovery

Q1 — Identify the port scan activity performed by the attacker on the network. What was the NAT IP Address(Internal IP Address) assigned to the machine being used by the attacker on the internal network?

Start with the TCP conversation table. One internal host sends short, one-way SYN probes to a single target (the printer) across many ports, with almost no data exchanged on most of them. That pattern is a SYN scan, and the source of those probes is the attacker’s machine.

tshark -r capture.pcap -q -z conv,tcp
Click flag to reveal 172.31.35.23
Q2 — Which ports were open on the network printer? Identify the port used for printer exploitation.

From Q1 the scan target is the printer. Open ports are the ones that completed the handshake, and only one of them goes on to carry a long session with real payload. That is the raw print port, and its stream is the PJL traffic used in the rest of the case.

tshark -r capture.pcap -q -z conv,tcp -Y 'ip.addr==172.31.40.241'
Click to reveal answer 9100

Execution

Q3 — Based on the abused port number, which printer language/method was being abused by the attacker for unattended malicious activity on the network printer?

Port 9100 is the JetDirect raw print service, and anything sent to it goes straight to the printer’s job interpreter. Following the stream shows lines starting with @PJL, including FSDIRLIST and FSUPLOAD, which list and read files on the printer’s own storage. That is Printer Job Language.

tshark -r capture.pcap -q -z follow,tcp,ascii,0
Click flag to reveal PJL
Q4 — Which Printer Name/Model was attacked?

The attacker’s first PJL commands identify the device. The @PJL INFO ID request gets the model string back in the response from the printer, so read the server side of the 9100 stream.

tshark -r capture.pcap -Y 'tcp.port==9100 && data' -T fields -e data | xxd -r -p

Gotcha: The format hint (** ******** *** ******) is four words, so the answer is the whole model string as the printer reports it, including the pro and dn parts, not just “HP LaserJet”.

Click to reveal answer HP LaserJet pro 4001dn

Collection

Q5 — The attacker has discovered a scheduled print job that is associated with an employee who is suspected of being an insider threat. What is the full path of the print job file?

Later in the same PJL session the attacker lists the saved-jobs area of the printer and then runs FSUPLOAD against one file in it, pulling the content back over the connection. The path in that command is the answer. Printer volumes are addressed with a 0: prefix.

tshark -r capture.pcap -Y 'tcp.port==9100 && data' -T fields -e data | xxd -r -p | grep -a 'FSUPLOAD'
Click flag to reveal 0:/saveDevice/SavedJobs/InProgress/scheduled.ps
Q6 — What is the name of the targeted organization?

The file pulled in Q5 comes back in the stream as plain text, and it is a layoff notice. The organization named in that document is the target. The answer is read from the file body in the upload response.

tshark -r capture.pcap -q -z follow,tcp,ascii,0
Click to reveal answer LetsDefend Corp Company

Credential Access

Q7 — The attacker found information about RDP within the internal network. What is the directory path where this sensitive information was located?

Further along the stream the attacker runs FSDIRLIST on a backup directory. The listing returns an RDP connection file, internal.rdp, next to an admin PowerShell script. The directory in that FSDIRLIST command is the answer, and it starts with a slash rather than a volume prefix.

tshark -r capture.pcap -Y 'tcp.port==9100 && data' -T fields -e data | xxd -r -p | grep -a -A5 'FSDIRLIST'
Click flag to reveal /backup/jumphost/2023
Q8 — What is the IP address of the Jumphost?

From Q7, the attacker reads internal.rdp from that directory. RDP files store the target in the full address field, and that value is the jumphost.

tshark -r capture.pcap -Y 'tcp.port==9100 && data' -T fields -e data | xxd -r -p | grep -a 'full address'
Click to reveal answer 172.31.23.97
Q9 — What is the filename of the PowerShell script used by admins which was also found by the attacker?

The same Q7 directory listing shows a second file beside the RDP file, with a .ps1 extension. That is the admin script.

tshark -r capture.pcap -Y 'tcp.port==9100 && data' -T fields -e data | xxd -r -p | grep -a '\.ps1'
Click flag to reveal remote-service.ps1

Attack Summary

PhaseAction
DiscoverySYN scan of the printer from an internal host
DiscoveryRaw print port found open and used for the rest of the intrusion
ExecutionPJL commands sent directly to the printer, model identified
DiscoveryPrinter file system listed with FSDIRLIST
CollectionScheduled print job pulled from the saved-jobs folder with FSUPLOAD
Credential AccessBackup directory listed, exposing an RDP file and an admin PowerShell script
Credential AccessRDP file read, revealing the jumphost address

IOCs

TypeValue
IP (attacker host)172.31.35[.]23
IP (printer, scan target)172.31.40[.]241
IP (jumphost)172.31.23[.]97
Port9100/tcp
Printer path0:/saveDevice/SavedJobs/InProgress/scheduled.ps
Directory/backup/jumphost/2023
Fileinternal.rdp, remote-service.ps1

MITRE ATT&CK

TechniqueIDDescription
Network Service DiscoveryT1046SYN scan of the printer to find open ports
File and Directory DiscoveryT1083FSDIRLIST walk of the printer storage
Data from Local SystemT1005FSUPLOAD of the scheduled print job
Unsecured Credentials: Credentials In FilesT1552.001RDP file and admin script read from a backup folder, exposing the jumphost

Defender Takeaways

Port 9100 should not be reachable from user and server segments. Raw JetDirect has no authentication, so anyone who can connect can run PJL. Restrict it to the print server and put printers in their own VLAN.

Disable PJL file system access and clear stored jobs. The attacker listed and downloaded files from the printer because the file system commands were enabled. Turn off remote file access on the device and avoid leaving sensitive jobs saved on it.

Do not keep infrastructure notes on printers. An RDP file and an admin script in a backup folder gave away the jumphost with one read. Keep connection files and admin scripts off devices that are not hardened for secrets.

Alert on a single host sweeping ports on an internal device. The SYN scan was a clear precursor to the session. Flow data showing one internal source probing many ports on a printer is cheap to detect.

Conclusion

The attacker reached the printer’s job port from inside the network and used it to read stored files, including a sensitive print job and the address of the jumphost. The printer was the foothold and the data store, and none of it needed a credential.