Coder Social home page Coder Social logo

rub-nds / pret Goto Github PK

View Code? Open in Web Editor NEW
3.8K 199.0 602.0 1.87 MB

Printer Exploitation Toolkit - The tool that made dumpster diving obsolete.

Home Page: http://hacking-printers.net

License: GNU General Public License v2.0

Python 70.98% PostScript 29.02%

pret's Introduction

PRET - Printer Exploitation Toolkit

Is your printer secure? Check before someone else does...

PRET is a new tool for printer security testing developed in the scope of a Master's Thesis at Ruhr University Bochum. It connects to a device via network or USB and exploits the features of a given printer language. Currently PostScript, PJL and PCL are supported which are spoken by most laser printers. This allows cool stuff like capturing or manipulating print jobs, accessing the printer's file system and memory or even causing physical damage to the device. All attacks are documented in detail in the Hacking Printers Wiki.

The main idea of PRET is to facilitate the communication between the end-user and the printer. Thus, after entering a UNIX-like command, PRET translates it to PostScript, PJL or PCL, sends it to the printer, evaluates the result and translates it back to a user-friendly format. PRET offers a whole bunch of commands useful for printer attacks and fuzzing.

PRET design

Installation

PRET only requires a Python2 interpreter. For colored output and SNMP support however, third party modules need to be installed:

# pip install colorama pysnmp

If running on a Windows console and Unicode characters are not displayed correctly, install the win_unicode_console module:

# pip install win_unicode_console

For experimental, ‘driverless’ printing (see print command), ImageMagick and GhostScript need to be installed:

# apt-get install imagemagick ghostscript

Usage

usage: pret.py [-h] [-s] [-q] [-d] [-i file] [-o file] target {ps,pjl,pcl}

positional arguments:
  target                printer device or hostname
  {ps,pjl,pcl}          printing language to abuse

optional arguments:
  -h, --help            show this help message and exit
  -s, --safe            verify if language is supported
  -q, --quiet           suppress warnings and chit-chat
  -d, --debug           enter debug mode (show traffic)
  -i file, --load file  load and run commands from file
  -o file, --log file   log raw data sent to the target
Example usage:
$ ./pret.py laserjet.lan ps
$ ./pret.py /dev/usb/lp0 pjl
Positional Arguments:

PRET requires a valid target and a printer language as arguments. The target can either be the IP address/hostname of a network printer (with port 9100/tcp open) or a device like /dev/usb/lp0 for a local USB printer. To quickly discover all network printers in your subnet using SNMP broadcast, simply run PRET without arguments:

./pret.py
No target given, discovering local printers

address          device                       uptime    status                 
───────────────────────────────────────────────────────────────────────────────
192.168.1.5      hp LaserJet 4250             10:21:49   Ready                 
192.168.1.11     HP LaserJet M3027 MFP        13 days    Paper jam             
192.168.1.27     Lexmark X792                 153 days   Ready                 
192.168.1.28     Brother MFC-7860DW           16:31:17   Sleep mode            

The printer language to be abused must be one of ps, pjl or pcl. Not all languages are supported by every printer, so you may want to switch languages if you don't receive any feedback. Each printer language is mapped to a different set of PRET commands and has different capabilities to exploit.

Optional Arguments:

--safe tries to check via IPP, HTTP and SNMP if the selected printing language (PS/PJL/PCL) is actually supported by the device before connecting. On non-networked printers (USB, parallel cable) this test will fail.

--quit suppresses printer model determination, intro message and some other chit-chat.

--debug shows the datastream actually sent to the device and the feedback received. Note that header data and other overhead is filtered. The see the whole traffic, use wireshark. Debugging can also be switched on/off within a PRET session using the debug command

--load filename reads and executes PRET commands from a text file. This is useful for automation. Command files can also be invoked later within a PRET session via the load command.

--log filename writes a copy of the raw datastream sent to the printer into a file. This can be useful to build a malicious print job file which can be deployed on another printer not directly reachable, for example by printing it from USB drive.

Generic Commands

After connecting to a printer device, you will see the PRET shell and can execute various commands:

$ ./pret.py laserjet.lan pjl
      ________________
    _/_______________/|
   /___________/___//||   PRET | Printer Exploitation Toolkit v0.25
  |===        |----| ||    by Jens Mueller <[email protected]>
  |           |   ô| ||
  |___________|   ô| ||
  | ||/.´---.||    | ||        「 cause your device can be
  |-||/_____\||-.  | |´           more fun than paper jams 」
  |_||=L==H==||_|__|/

     (ASCII art by
     Jan Foerster)

Connection to laserjet.lan established
Device:   hp LaserJet 4250

Welcome to the pret shell. Type help or ? to list commands.
laserjet.lan:/> help

Available commands (type help <topic>):
=======================================
append  debug    edit    free  id    ls       open      restart   timeout  
cat     delete   env     fuzz  info  mirror   printenv  selftest  touch    
cd      df       exit    get   load  mkdir    put       set       traversal
chvol   disable  find    help  lock  nvram    pwd       site      unlock   
close   display  format  hold  loop  offline  reset     status    version  

laserjet.lan:/> ls ../../
-      834   .profile
d        -   bin
d        -   dev
d        -   etc
d        -   hp
d        -   hpmnt
-     1276   init
d        -   lib
d        -   pipe
d        -   tmp
laserjet.lan:/> exit

A list of generic PRET commands is given below:

help      List available commands or get detailed help with 'help cmd'.
debug     Enter debug mode. Use 'hex' for hexdump:  debug [hex]
load      Run commands from file:  load cmd.txt
loop      Run command for multiple arguments:  loop <cmd> <arg1> <arg2> …
open      Connect to remote device:  open <target>
close     Disconnect from device.
timeout   Set connection timeout:  timeout <seconds>
discover  Discover local printer devices via SNMP.
print     Print image file or raw text:  print <file>|"text"
site      Execute custom command on printer:  site <command>
exit      Exit the interpreter.

Generic file system operations with a PS/PJL/PCL specific implementation are:

┌───────────┬─────┬─────┬─────┬────────────────────────────────────────┐
│ Command   │ PS  │ PJL │ PCL │ Description                            │
├───────────┼─────┼─────┼─────┼────────────────────────────────────────┤
│ ls        │  ✓  │  ✓  │  ✓  │ List contents of remote directory.     │
│ get       │  ✓  │  ✓  │  ✓  │ Receive file: get <file>               │
│ put       │  ✓  │  ✓  │  ✓  │ Send file: put <local file>            │
│ append    │  ✓  │  ✓  │     │ Append to file: append <file> <str>    │
│ delete    │  ✓  │  ✓  │  ✓  │ Delete remote file: delete <file>      │
│ rename    │  ✓  │     │     │ Rename remote file: rename <old> <new> │
│ find      │  ✓  │  ✓  │     │ Recursively list directory contents.   │
│ mirror    │  ✓  │  ✓  │     │ Mirror remote filesystem to local dir. │
│ cat       │  ✓  │  ✓  │  ✓  │ Output remote file to stdout.          │
│ edit      │  ✓  │  ✓  │  ✓  │ Edit remote files with vim.            │
│ touch     │  ✓  │  ✓  │     │ Update file timestamps: touch <file>   │
│ mkdir     │  ✓  │  ✓  │     │ Create remote directory: mkdir <path>  │
├───────────┼─────┼─────┼─────┼────────────────────────────────────────┤
│ cd        │  ✓  │  ✓  │     │ Change remote working directory.       │
│ pwd       │  ✓  │  ✓  │     │ Show working directory on device.      │
│ chvol     │  ✓  │  ✓  │     │ Change remote volume: chvol <volume>   │
│ traversal │  ✓  │  ✓  │     │ Set path traversal: traversal <path>   │
├───────────┼─────┼─────┼─────┼────────────────────────────────────────┤
│ format    │  ✓  │  ✓  │     │ Initialize printer's file system.      │
│ fuzz      │  ✓  │  ✓  │     │ File system fuzzing: fuzz <category>   │
├─ ─ ─ ─ ─ ─┴─ ─ ─┴─ ─ ─┴─ ─ ─┴─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤
│   path   - Explore fs structure with path traversal strategies.      │
│   write  - First put/append file, then check for its existence.      │
│   blind  - Read-only tests for existing files like /etc/passwd.      │
├───────────┬─────┬─────┬─────┬────────────────────────────────────────┤
│ df        │  ✓  │  ✓  │     │ Show volume information.               │
│ free      │  ✓  │  ✓  │  ✓  │ Show available memory.                 │
└───────────┴─────┴─────┴─────┴────────────────────────────────────────┘

Commands in PS mode

id         Show device information.
version    Show PostScript interpreter version.
devices    Show available I/O devices.
uptime     Show system uptime (might be random).
date       Show printer's system date and time.
pagecount  Show printer's page counter.

lock       Set startjob and system parameters password.
unlock     Unset startjob and system parameters password.
restart    Restart PostScript interpreter.
reset      Reset PostScript settings to factory defaults.
disable    Disable printing functionality.
destroy    Cause physical damage to printer's NVRAM.
hang       Execute PostScript infinite loop.

overlay    Put overlay eps file on all hardcopies:  overlay <file.eps>
cross      Put printer graffiti on all hardcopies:  cross <font> <text>
replace    Replace string in documents to be printed:  replace <old> <new>
capture    Capture further jobs to be printed on this device.
hold       Enable job retention.

set        Set key to value in topmost dictionary:  set <key=value>
known      List supported PostScript operators:  known <operator>
search     Search all dictionaries by key:  search <key>
dicts      Return a list of dictionaries and their permissions.
resource   List or dump PostScript resource:  resource <category> [dump]

dump       Dump dictionary:  dump <dict>
  Dictionaries: - systemdict - statusdict - userdict 
                - globaldict - serverdict - errordict
                - internaldict - currentsystemparams
                - currentuserparams - currentpagedevice

config     Change printer settings:  config <setting>
  duplex        - Set duplex printing.
  copies #      - Set number of copies.
  economode     - Set economic mode.
  negative      - Set negative print.
  mirror        - Set mirror inversion.

Not all commands are supported by every printer. Especially Brother and Kyocera devices use their own PostScript clones – Br-Script and KPDL – instead of licensing original ‘Adobe PostScript’. Such flavours of the PostScript language may not be 100% compatible, especially concerning security sensitive features like capturing print jobs. Access to the file system is supported by most printers, however usually limited to a certain, sandboxed directory.

Commands in PJL mode

id         Show device information.
status     Enable status messages.
version    Show firmware version or serial number (from 'info config').
pagecount  Manipulate printer's page counter:  pagecount <number>
printenv   Show printer environment variable:  printenv <VAR>
env        Show environment variables (alias for 'info variables').
set        Set printer environment variable:  set <VAR=VALUE>

display    Set printer's display message:  display <message>
offline    Take printer offline and display message:  offline <message>
restart    Restart printer.
reset      Reset to factory defaults.
selftest   Perform various printer self-tests.
disable    Disable printing functionality.
destroy    Cause physical damage to printer's NVRAM.
flood      Flood user input, may reveal buffer overflows.

lock       Lock control panel settings and disk write access.
unlock     Unlock control panel settings and disk write access.
hold       Enable job retention.

nvram      NVRAM operations:  nvram <operation>
  nvram dump [all]           - Dump (all) NVRAM to local file.
  nvram read addr            - Read single byte from address.
  nvram write addr value     - Write single byte to address.

info       Show information:  info <category>
  info config      - Provides configuration information.
  info filesys     - Returns PJL file system information.
  info id          - Provides the printer model number.
  info memory      - Identifies amount of memory available.
  info pagecount   - Returns the number of pages printed.
  info status      - Provides the current printer status.
  info ustatus     - Lists the unsolicited status variables.
  info variables   - Lists printer's environment variables.

Some commands are supported exclusively by HP printers, because other vendors have only implemented a subset of the PJL standard. This is especially true for PML based commands like restartor reset. Enabling long-term job retention via the hold command seems to be possible for some Epson devices only. NVRAM access via the nvram command is a proprietary feature of Brother printers. Limited access to the file system is supported by various HP, OKI, Konica, Xerox, Epson and Ricoh devices.

Commands in PCL mode

selftest   Perform printer self-test.
info       Show information:  info <category>
  info fonts      - Show installed fonts.
  info macros     - Show installed macros.
  info patterns   - Show user-defined patterns.
  info symbols    - Show symbol sets.
  info extended   - Show extended fonts.

PCL is a very limited page description language without access to the file system. The get/put/ls commands therefore use a virtual file system based on PCL macros, implemented mostly for the hack value. This proof-of-concept shows that even a device which supports only minimalist languages like PCL can be used to store arbitrary files like copyright infringing material. Although such a file sharing service is not a security vulnerability per se, it might apply as ‘misuse of service’ depending on the corporate policy

File Listing

  • pret.py - Executable main program
  • capabilities.py - Routines to check for printer language support
  • discovery.py - Routines to list printers using SNMP broadcast
  • printer.py - Generic code to describe a printing device
  • postscript.py - PS specific code (inherits from class printer)
  • pjl.py - PJL specific code (inherits from class printer)
  • pcl.py - PCL specific code (inherits from class printer)
  • helper.py - Help functions for output, logging, sockets, etc.
  • codebook.py - Static table of PJL status/error codes
  • fuzzer.py - Constants for file system fuzzing
  • mibs/* - Printer specific SNMP MIBs
  • db/* - database of supported models
  • lpd/* - Scripts for LPD fuzzing

Getting Started

Given the features and various proprietary extensions in printing languages like PostScript and PJL, conducting a pentest on printers is not a trivial job. PRET can help to assist and verify known issues in the language. Once you have played around with the tool, you may want to perform a systematic printer security analysis. A good starting point is the Printer Security Testing Cheat Sheet.

Happy Hacking!

pret's People

Contributors

anthonymastrean avatar dabdine avatar darkiros avatar datawearsahood avatar jensvoid avatar jurajsomorovsky avatar kianmeng avatar mladevbb avatar roumy avatar rpavlik avatar runejuhl avatar tivervac avatar varens avatar waples avatar wtjerry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pret's Issues

error when I launch any command from PRET

I have this error message when I try to run a command with PRET :

Command execution failed (a bytes-like object is required, not 'str')

its appears with any printer languages (pjl, pcl, ps)

i can't do this, why idk

when i do python pret.py <my ip > pjl its say : 「 pentesting tool that made dumpster diving obsolete‥ 」

plzzz help me

Access USB printer on windows (Shared printer)

Hello,
I'm trying to reach a USB printer while using Windows environment using your python tool PRET.
I shared the usb printer over network and checked using net use command that I receive a connection:

Local name
Remote name \GUY\6201
Resource type Print
Status OK
Opens 0
Connections 1
The command completed successfully.

I repeatedly get with you tool:
Connection to \GUY\6201 failed (getaddrinfo failed)
Connection closed.

I suspect the problem is here:
if os.path.exists(target)
and stat.S_ISCHR(os.stat(target).st_mode):
self._file = os.open(target, os.O_RDWR)
# treat target as ipv4 socket
else: self._sock.connect((target, 9100))

because on Windows the target shared printer has no real path at the system.
Can you offer me what shall be done?

does not print

after puting the file or text it gives this error

Cannot convert (convert-im6.q16: no images defined `pcl:-' @ error/convert.c/ConvertImageCommand/3258.)

Capture list is null

Hello,
I'm a beginner starting test printer. I want to use the PRET tool to capture the printing task and re-print it. Very thanks to provide a platform for connecting the printer. However, when I tried to connect my printer HP LaserJet 5200 Series PCL 5, I could connect it using pret.py, I also could run the capture start process, but when I run "capture list", the list is free. So could you tell me where is the problem with my test. There are three questions which I want to ask.
1.What the printer version the PRET tool supports? Does my printer HP LaserJet 5200 Series PCL 5 supports to run the capture task?
2.If the tool doesn't support the version HP LaserJet 5200 Series PCL 5. could you tell me some ideas how to capture the printer's task and re-print the printer's task.
Very hoping for your reply. Thanks very much. If you want to reply by email, please send me emails with [email protected]. Thanks.

ESC Printer Language Support

Hey,
I wanna test this on my Epson WF-6590 Series
Only thing I found out is that Epson only uses their own language ESC/P not ps or pcl
any idea how I would be able to do that (I am mostly interested in the capture function)

Thanks guys have a wonderful day

Not working with local USB printer (Epson Stylus TX125)

Executing sudo ./pret.py /dev/usb/lp0 pjl

I get:

Connection to /dev/usb/lp0 established
Receiving data failed (watchdog timeout)

�%�
�%�

All commands fails, also tried with PCL and PS modes and get similar results..

Syntaxerror : invalid syntax

When, I give this command "python combogen"
($ python combogen
File "/data/data/com.termux/files/home/ComboGen/combogen", line 6
Z
^
SyntaxError: invalid syntax)

This showing why? Need help
Screenshot_2020-10-30-10-14-55-418_com termux

crash

python pret.py
Traceback (most recent call last):
File "pret.py", line 8, in
from discovery import discovery
File "/opt/PRET/discovery.py", line 13, in
from pysnmp.proto import api
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/api/init.py", line 7, in
from pysnmp.proto.api import v1, v2c, verdec
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/api/v1.py", line 8, in
from pysnmp.proto import rfc1155, rfc1157, error
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/rfc1155.py", line 50, in
class NetworkAddress(univ.Choice):
File "/usr/lib/python2.7/dist-packages/pysnmp/proto/rfc1155.py", line 55, in NetworkAddress
def clone(self, value=univ.noValue, **kwargs):
AttributeError: 'module' object has no attribute 'noValue'

hi
I have installed the depend

Convert-im6.q16: no images defined `pcl:-'

Full Error:

Cannot convert (convert-im6.q16: no images defined `pcl:-' @ error/convert.c/ConvertImageCommand/3258.)

I am using PRET on a Windows Ubuntu Subsystem and found that whenever I try to use the print command, type in "asd" as a test, it would return this error in all modes (ps, pjl, pcl).

My printer model is: HP ENVY 4500 e-All-in-One Printer Series

Any help would be appreciated! 😀

Xerox Printers Compatibility

I've tested multiple types of Xerox printers using PRET with ps, pcl & pjl, none of the languages work.

Am I missing something?

Model:
Xerox Altalink c8035
XEROX WorkCentre 7225

Command execution failed (timed out) - HP 5540

This is the result when detecting the device and commands like cd or ls.
The other options (display, restart, print, etc...) do not work but the connection is established. I tried pjl, pcl and ps but nothing work.
My printer is a HP 5540 (not appearing in ./db compatibles printers).

Can't specify port with lpdtest.py

Whether I change the default port in the script from 515 to (for example) 30886 or if I specify the port in the bash command with the option --port 30886, I get the same error:

Traceback (most recent call last):
File "lpdtest.py", line 185, in
s.send(bytes("\002"+queue+"\n",'utf-8'))
TypeError: str() takes at most 1 argument (2 given)

If I don't specify the port, the script seems to fire off, although the print server is not on port 515, so nothing happens. But at least I don't get an error. The error only occurs when I specify the port.

Why does changing the port number make the script think that there's an additional argument? And how can this be fixed?

HP printers device file

Hello guys!
Is it possible to access printer which is connected via hp-setup util?
E.g. when the "connection" field in cups looks like this hp:/usb/HP_Color_LaserJet_M452nw?serial=VNC3C34589

I couldn't find anything in /dev/usb/ and also tried to connect via bus device (e.g. ./pret.py /dev/bus/usb/003/003 ps) which seems to not work because of "Command execution failed" (Invalid argument) errors

x

x

Combogen

I am running the combogen then

python combogen
File "/data/data/com.termux/files/home/ComboGen/combogen", line 6
Z
^
SyntaxError: invalid syntax

Thes tipe of issues I will face you can help me

Mac OSX support

I couldn't manage to find a /dev/usb/lp0 sort of port for the serial connection on OSX. Can I get some support or documentation on how to use it on OSX over usb serial?

Any chance to get this to work on Python 3?

All of my new systems run Python 3 and I've been migrating off of Python 2. I installed Python 2.7 just to test this out but pip runs with Python 3 on my system. When I try to run pret.py it errors out every time.

Python3

Please, upgrade to Python3 to use at least with python 3.5.

PRET.py Cannot convert (ImageMagick or Ghostscript missing) error

So i tried to print a pdf file on this printer i got into using pret.

I typed the print ./thedoc.pdf command then this error came up Cannot convert (ImageMagick or Ghostscript missing).
I checked if I had ghostscript installed and apparently I did but the issue persists.

Any help or fix appreciated.

licensing

Can you please add a license to your project?
Thanks!

PJL ls directory traversal outputting wrong data

Hello there, I connected to a vulnerable printer at port 9100 using the PJL protocol and was confused by the fact that ls changed its output for the same directory. For example, I'd do "ls /", and get the right output. Then I do ls /somefolder and get the contents for /. Then I do ls /somefolder/someotherfolder and I get the contents for /somefolder.

I thought maybe the previous directory could have just been the / folder, so I investigated in wireshark. Filtering for port TCP 9100, I followed the TCP stream.

When I did "ls /somefolder", the client sent out the right packet:

.%-12345X@PJL FSDIRLIST NAME="0:/somefolder" ENTRY=1 COUNT=65535
@PJL ECHO DELIMITER27053

.%-12345X

and the server responded properly with the contents of /somefolder:

@PJL ECHO DELIMITER27053
.@PJL FSDIRLIST NAME="0:/somefolder" ENTRY=1
data TYPE=DIR
tmp_files TYPE=DIR
. TYPE=DIR
internal TYPE=DIR
.. TYPE=DIR
fonts TYPE=DIR

however, this is what the client showed:

x.x.x.x:/> ls /somefolder
d        -   BCEFontfiles
d        -   BCEtransfiles
...

even though that is the contents of the / folder. Next when I did ls /somefolder/data (using the output in wireshark):

.%-12345X@PJL FSDIRLIST NAME="0:/somefolder/data" ENTRY=1 COUNT=65535
@PJL ECHO DELIMITER38628

.%-12345X

and again, correct response:

@PJL ECHO DELIMITER38628
.@PJL FSDIRLIST NAME="0:/somefolder/data" ENTRY=1
. TYPE=DIR
.. TYPE=DIR
.

this is the output:

x.x.x.x:/> ls /somefolder/data
d        -   data
d        -   fonts
d        -   internal
d        -   tmp_files

Hopefully you can see the problem.

py2 to py3 issues

I see last commit which changed things from python2 to python3 for better compatibility but when i run the tool it doesn't send any commands to server.

Connection to 0.0.0.0 established
Connection to 0.0.0.0 failed (a bytes-like object is required, not 'str')
Connection closed.

I've fixed pjl.py as below

self.send(cmd_send.encode('utf-8'))

Now it sends first set of status commands to the server but fails parsing the response i believe.

Connection to 0.0.0.0 established
Device:   Connection to 0.0.0.0 failed (can only concatenate str (not "bytes") to str)
Connection closed.

Can you please test it and resolve the further issues ?

SNMP Error when running PRET

Error I get when I run PRET without any arguments

SNMP Error (},)

brand new Kali VM 2017.3
python 2.7.14
pysnmp is properly installed
pysnmp version: 4.3.2

Problem w/ pret.py

Whenever I open pret.py it immediately closes. From what I understand I might need python 2.0 but I'm not sure how I would use it thru CMD on windows. If I could get any help that would be amazing, Thanks!

Incompatibilty of PRET on Kali Linux and Python3

Hi everybody!
So I clone PRET on my Kali Linux and I obviously get this error because Python 2 has been removed of Kali but it will mess the execution of PRET :
python -m pip install colorama pysnmP
/usr/bin/python: No module named pip

So when I start ./pret.py, I get :
./pret.py
Please install the 'colorama' module for color support.
Please install the 'pysnmp' module for SNMP support.
usage: pret.py [-h] [-s] [-q] [-d] [-i file] [-o file] target {ps,pjl,pcl}
pret.py: error: too few arguments

So I try with Python 3 and get these following errors (because it's not written to work with Python 2 ig) :
Traceback (most recent call last):
File "./pret.py", line 8, in
from discovery import discovery
File "/home/thoms/Bureau/AdventOfCyber/PRET/PRET/discovery.py", line 7, in
from helper import output, conv
File "/home/thoms/Bureau/AdventOfCyber/PRET/PRET/helper.py", line 130
def discover(self, (ipaddr, (device, uptime, status, prstat))):
^
SyntaxError: invalid syntax`

How can I make PRET fully functionnal??

PS : when I use "python3 -m pip install colorama pysnmP", I get this :
python3 -m pip install colorama pysnmP
Requirement already satisfied: colorama in /usr/lib/python3/dist-packages (0.4.3)
Requirement already satisfied: pysnmP in /usr/lib/python3/dist-packages (4.4.6)

ConvertProgram Error!

Hi, When I use the print command after connecting to the printer, I get an error saying "Can not convertProgram Error ('utf8' codec can not decode byte 0xc0 in position 2: invalid start bytes). When I search Google, I try to change the code to utf16. I looked up each Python script and I can not find the code in the language set. Let me know how to fix the error.

SNMP Error when running

After following instructions and installing PRET on a Kali Linux VM, I get the following error:

root@kali:/opt/pret# ./pret.py
No target given, discovering local printers
SNMP Error (setComponentByType() got multiple values for keyword argument 'verifyConstraints')

usage: pret.py [-h] [-s] [-q] [-d] [-i file] [-o file] target {ps,pjl,pcl}
pret.py: error: too few arguments

pysnmp version: 4.3.2

Overlay or Cross "No data received"

Is the message "No data received" indicating that the attempt has failed? Nothing is printed on the subsequent jobs except for what is on the printed document.

%rom% writable

Hello, what is the possibility of changing the %rom% to writable folder on a lexmark machine?

HP LaserJet - Out of memory, will not capture jobs anymore

Hey guys,

I'm trying to capture the jobs being sent to a network printer.

I am connected to the said printer through PostScript.

capture start works perfectly, but then capture list gives me the following error:

Free virtual memory: 0B | Limit to capture: 5.0M
Within threshold - will not capture
Within threshold - will not capture
Within threshold - will not capture
Memory almost full, will not capture jobs anymore

I've tried erasing the saved jobs, resetting the printer, factory reset, disabling job storage, but nothing works so far, any clues?

This is the config:

Product Name:
HP LaserJet E60055

Model Number:
M0P33A

4.3.0.2

Firmware Revision:
2403317_000027

Firmware Datecode:
20170526

HP FutureSmart Level:
HP FutureSmart 4

Memory
Total RAM:
1024 MB

pret.py doesn't work on hp envy

I tried to connect to my printer by writing: python pret.py {192.168.1.27} pjl and no luck
pret
I tried all languages and it keep outputting the same result
I have a HP ENVY 4500 series
and this is a nmap scan I did on my printer
scan

Requires a second connect for it to print when using --load

So I have 3 printers at home I have been playing around with, and I seem to have an issue with all of them using PJL (I have not tested beyond PJL). When I go to print something using the load parameter, it doesn't seem to want to work. If I have a txt file that has the lines

print example.pdf
exit

It will run successfully, but print nothing. That isn't until I connect manually again, then do the same command, and then it will spit out two. This does not happen when I manually connect and type in the commands, I was thinking this is about the wait time, but why would it allow it to run the exit command if the print was not fully sent yet? Thanks

Connection Failed

Every time i try any option, i get this.
Connection to 198.16.168.44 failed (Connection refused)
Connection closed.

"This only affects jobs printed by a PostScript driver" ?

Good day. After connecting on printer, I enter the command "capture start". The system tells me "This only affects jobs printed by a PostScript driver".
But I connected to the Xerox Phaser 3300, the documentation says it supports PostScript.
Maybe I need to install some special driver on my Kali?

Syntax error running PRET from Termux on Android

I am trying to run PRET in Termux(busy box) on Android, all newest versions installed today.

I get the following:
$ python pret.py
Traceback (most recent call last):
File "pret.py", line 8, in
from discovery import discovery
File "/data/data/com.termux/files/home/PRET/discovery.py", line 7, in
from helper import output, conv
File "/data/data/com.termux/files/home/PRET/helper.py", line 130
def discover(self, (ipaddr, (device, uptime, status, prstat))):
^
SyntaxError: invalid syntax

I am a beginner at programming... Any help here would be much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.