# rub-nds/pret architecture

> Architecture diagram of the GitHub repository rub-nds/pret, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rub-nds/pret
- Repository: https://github.com/rub-nds/pret

## Overview

PRET is a printer-security testing toolkit: a user selects a target and printer language, then runs shell commands that are translated into printer-language traffic and returned as readable output. Its language drivers expose distinct PostScript, PJL, and PCL capabilities, including filesystem access, memory/configuration operations, job manipulation, and fuzzing. Discovery and optional language-support checks are separate entry paths; LPD printing and protocol tests are standalone tools. The README documents broader attack capabilities, while sampled source confirms only selected driver and transport details.

Main entry points: [`printer.py`](https://github.com/rub-nds/pret/blob/master/printer.py) (Command shell), [`helper.py`](https://github.com/rub-nds/pret/blob/master/helper.py) (Device transport), [`postscript.py`](https://github.com/rub-nds/pret/blob/master/postscript.py) (PostScript driver), [`pjl.py`](https://github.com/rub-nds/pret/blob/master/pjl.py) (PJL driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_session["Interactive session"]
  node_shell["Command shell<br/>[printer.py]"]
  node_transport["Device transport<br/>[helper.py]"]
  node_output["Output and logging<br/>[helper.py]"]
end

subgraph group_drivers["Printer languages"]
  node_ps["PostScript driver<br/>[postscript.py]"]
  node_pjl["PJL driver<br/>[pjl.py]"]
  node_pcl["PCL driver<br/>[pcl.py]"]
  node_filesystem["Remote filesystem<br/>[printer.py]"]
  node_jobops["Job and device operations<br/>[postscript.py]"]
  node_fuzzing["Fuzz testing<br/>[fuzzer.py]"]
  node_printing["Print command<br/>[printer.py]"]
end

subgraph group_discovery["Discovery and checks"]
  node_discovery_tool["Printer discovery<br/>[discovery.py]"]
  node_capability_check["Language support check<br/>[capabilities.py]"]
end

subgraph group_lpd["LPD utilities"]
  node_lpd_print["LPD print client<br/>[lpdprint.py]"]
  node_lpd_test["LPD security tests<br/>[lpdtest.py]"]
end

node_user(("Operator"))
node_printer["Network printer"]
node_snmp["SNMP printer services"]
node_ipp_http["IPP and web services"]
node_lpd_service["LPD printer service"]

node_user -->|"runs commands"| node_shell
node_shell -->|"selects PS"| node_ps
node_shell -->|"selects PJL"| node_pjl
node_shell -->|"selects PCL"| node_pcl
node_shell -->|"opens device"| node_transport
node_transport -->|"sends traffic"| node_printer
node_printer -->|"returns traffic"| node_transport
node_ps -->|"sends commands"| node_transport
node_pjl -->|"sends commands"| node_transport
node_pcl -->|"sends commands"| node_transport
node_shell -->|"dispatches commands"| node_filesystem
node_shell -->|"dispatches commands"| node_jobops
node_shell -->|"dispatches tests"| node_fuzzing
node_shell -->|"dispatches print"| node_printing
node_ps -->|"formats results"| node_output
node_pjl -->|"formats results"| node_output
node_pcl -->|"formats results"| node_output
node_user -->|"requests discovery"| node_discovery_tool
node_discovery_tool -->|"broadcast queries"| node_snmp
node_snmp -->|"returns device data"| node_discovery_tool
node_user -->|"requests safe check"| node_capability_check
node_capability_check -.->|"checks support"| node_ipp_http
node_capability_check -.->|"checks support"| node_snmp
node_user -->|"submits print job"| node_lpd_print
node_lpd_print -->|"sends job"| node_lpd_service
node_user -->|"runs protocol test"| node_lpd_test
node_lpd_test -->|"tests protocol"| node_lpd_service

click node_shell "https://github.com/rub-nds/pret/blob/master/printer.py"
click node_transport "https://github.com/rub-nds/pret/blob/master/helper.py"
click node_output "https://github.com/rub-nds/pret/blob/master/helper.py"
click node_ps "https://github.com/rub-nds/pret/blob/master/postscript.py"
click node_pjl "https://github.com/rub-nds/pret/blob/master/pjl.py"
click node_pcl "https://github.com/rub-nds/pret/blob/master/pcl.py"
click node_filesystem "https://github.com/rub-nds/pret/blob/master/printer.py"
click node_jobops "https://github.com/rub-nds/pret/blob/master/postscript.py"
click node_fuzzing "https://github.com/rub-nds/pret/blob/master/fuzzer.py"
click node_printing "https://github.com/rub-nds/pret/blob/master/printer.py"
click node_discovery_tool "https://github.com/rub-nds/pret/blob/master/discovery.py"
click node_capability_check "https://github.com/rub-nds/pret/blob/master/capabilities.py"
click node_lpd_print "https://github.com/rub-nds/pret/blob/master/lpd/lpdprint.py"
click node_lpd_test "https://github.com/rub-nds/pret/blob/master/lpd/lpdtest.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_shell,node_transport,node_output toneBlue
class node_ps,node_pjl,node_pcl,node_filesystem,node_jobops,node_fuzzing,node_printing toneAmber
class node_discovery_tool,node_capability_check toneMint
class node_lpd_print,node_lpd_test toneRose
class node_user,node_printer,node_snmp,node_ipp_http,node_lpd_service toneIndigo
```

## Components

### Interactive session

- [Command shell](https://github.com/rub-nds/pret/blob/master/printer.py): `printer.py`
- [Device transport](https://github.com/rub-nds/pret/blob/master/helper.py): `helper.py`
- [Output and logging](https://github.com/rub-nds/pret/blob/master/helper.py): `helper.py`

### Printer languages

- [PostScript driver](https://github.com/rub-nds/pret/blob/master/postscript.py): `postscript.py`
- [PJL driver](https://github.com/rub-nds/pret/blob/master/pjl.py): `pjl.py`
- [PCL driver](https://github.com/rub-nds/pret/blob/master/pcl.py): `pcl.py`
- [Remote filesystem](https://github.com/rub-nds/pret/blob/master/printer.py): `printer.py`
- [Job and device operations](https://github.com/rub-nds/pret/blob/master/postscript.py): `postscript.py`
- [Fuzz testing](https://github.com/rub-nds/pret/blob/master/fuzzer.py): `fuzzer.py`
- [Print command](https://github.com/rub-nds/pret/blob/master/printer.py): `printer.py`

### Discovery and checks

- [Printer discovery](https://github.com/rub-nds/pret/blob/master/discovery.py): `discovery.py`
- [Language support check](https://github.com/rub-nds/pret/blob/master/capabilities.py): `capabilities.py`

### LPD utilities

- [LPD print client](https://github.com/rub-nds/pret/blob/master/lpd/lpdprint.py): `lpd/lpdprint.py`
- [LPD security tests](https://github.com/rub-nds/pret/blob/master/lpd/lpdtest.py): `lpd/lpdtest.py`

### Other components

- **Operator**
- **Network printer**
- **SNMP printer services**
- **IPP and web services**
- **LPD printer service**

## Connections

- Operator → Command shell: runs commands
- Command shell → PostScript driver: selects PS
- Command shell → PJL driver: selects PJL
- Command shell → PCL driver: selects PCL
- Command shell → Device transport: opens device
- Device transport → Network printer: sends traffic
- Network printer → Device transport: returns traffic
- PostScript driver → Device transport: sends commands
- PJL driver → Device transport: sends commands
- PCL driver → Device transport: sends commands
- Command shell → Remote filesystem: dispatches commands
- Command shell → Job and device operations: dispatches commands
- Command shell → Fuzz testing: dispatches tests
- Command shell → Print command: dispatches print
- PostScript driver → Output and logging: formats results
- PJL driver → Output and logging: formats results
- PCL driver → Output and logging: formats results
- Operator → Printer discovery: requests discovery
- Printer discovery → SNMP printer services: broadcast queries
- SNMP printer services → Printer discovery: returns device data
- Operator → Language support check: requests safe check
- Language support check → IPP and web services: checks support
- Language support check → SNMP printer services: checks support
- Operator → LPD print client: submits print job
- LPD print client → LPD printer service: sends job
- Operator → LPD security tests: runs protocol test
- LPD security tests → LPD printer service: tests protocol
