Hacktricks-skills pjl-printer-pentest
Pentest network printers via PJL (Printer Job Language) on port 9100/tcp. Use this skill whenever the user mentions printer security, port 9100, JetDirect, AppSocket, PJL commands, printer enumeration, printer exploitation, PRET tool, or any printer-related security testing. This includes tasks like enumerating printer info, accessing printer filesystems, uploading/downloading files, or exploiting printer vulnerabilities like TrueType VM bugs.
git clone https://github.com/abelrguezr/hacktricks-skills
skills/network-services-pentesting/9100-pjl/SKILL.MDPJL Printer Pentesting (Port 9100/tcp)
A skill for security testing network printers via the Printer Job Language (PJL) protocol on port 9100/tcp.
Overview
Port 9100/tcp (JetDirect/AppSocket) is the default raw printing protocol used by CUPS and Windows printing architecture. Unlike LPD, IPP, or SMB, it provides a bidirectional channel that gives direct access to results of PJL, PostScript, or PCL commands. This makes it ideal for security analysis and exploitation.
Key characteristics:
- Default port: 9100/tcp
- Bidirectional communication (sends direct feedback including status and error messages)
- Supported by almost any network printer
- Used as the channel for security analysis with PRET and PFT
Quick Start
Basic Connection
nc -vn <IP> 9100
Automated Enumeration
Use the bundled script for quick enumeration:
./scripts/pjl-enumerate.sh <IP>
Enumeration
Manual PJL Commands
Connect to port 9100 and send these commands:
| Command | Purpose |
|---|---|
| Printer status (sleep, online, etc.) |
| Brand and version information |
| Product information |
| Environment variables |
| Filesystem information |
| Timeout variables |
| Ready message |
| List directory contents |
| Initialize filesystem |
| Upload a file |
| Download a file |
| Delete a file |
Automated Tools
Nmap:
nmap -sV --script pjl-ready-message -p 9100 <IP>
Metasploit modules:
use auxiliary/scanner/printer/printer_env_vars use auxiliary/scanner/printer/printer_list_dir use auxiliary/scanner/printer/printer_list_volumes use auxiliary/scanner/printer/printer_ready_message use auxiliary/scanner/printer/printer_version_info use auxiliary/scanner/printer/printer_download_file use auxiliary/scanner/printer/printer_upload_file use auxiliary/scanner/printer/printer_delete_file
File Operations
Use the bundled script for filesystem operations:
./scripts/pjl-file-ops.sh <IP> <operation> [args]
Operations:
- List directory contentslist
- Upload a fileupload <local_file> <remote_path>
- Download a filedownload <remote_path> <local_file>
- Delete a filedelete <remote_path>
Exploitation
PRET Tool
The primary tool for printer exploitation is PRET. Install and use it for advanced attacks.
XPS/TrueType VM Exploitation (Canon ImageCLASS)
For Canon printers vulnerable to TrueType VM bugs:
-
Create XPS payload with malicious font:
- XPS is a ZIP containing
andDocuments/1/Pages/1.fpage/Resources/evil.ttf - The fpage references the malicious font
- XPS is a ZIP containing
-
Minimal XPS page example:
<Glyphs Fill="#ff000000" FontUri="/Resources/evil.ttf" FontRenderingEmSize="12" OriginX="10" OriginY="10"/>
-
RCE primitive (TrueType hinting VM):
- Hinting bytecode in TTF is executed by a TrueType VM
- Canon's VM lacked stack bounds checks
: OOB stack read → info leakCINDEX
: unchecked relative stack pivot → controlled writesDELTAP1- Combine
/WS
(VM storage write/read) to stage values and perform precise 32-bit writesRS
-
Exploit outline:
- Create XPS with malicious page and include
/Resources/evil.ttf - In
/fpgm
, useprep
to leak and computeCINDEXstack_cur - Stage target value with
; pivot withWS
to destinationDELTAP1 - Use
to write to function pointer for PC controlRS
- Create XPS with malicious page and include
-
Deliver via PJL:
Use the bundled script:
./scripts/pjl-xps-deliver.sh <IP> <xps_file>
Or manually:
{ printf "@PJL ENTER LANGUAGE = XPS\r\n"; cat exploit.xps; } | nc -q0 <PRINTER_IP> 9100
Target Discovery
Shodan Queries
pjl port:9100
Workflow Recommendations
- Start with enumeration - Use
to gather printer infopjl-enumerate.sh - Check filesystem access - Try
to see if you can access filespjl-file-ops.sh list - Identify printer model - Use
to determine brand/version@PJL INFO ID - Research vulnerabilities - Check if the model has known exploits (especially Canon for TrueType VM bugs)
- Use PRET - For advanced exploitation, use the PRET tool
- Document findings - Save all enumeration output for reporting
Safety Notes
- Authorization required - Only test printers you own or have explicit permission to test
- Printer disruption - Some commands may affect printer operation
- Data loss - File operations can delete or overwrite printer data
- Legal compliance - Ensure all testing complies with applicable laws and policies