navigation
Home
admin
|
Imprimantes
October 18th, 2016
|
| Table des matières |  |
Locker le panneau de commande des imprimantes HP sans utiliser HP JET ADMIN
Manipuler la configuration de copieurs avec wget
| Locker le panneau de commande des imprimantes HP sans utiliser HP JET ADMIN |  |
HPJET Admin est un peu lourd. Si l'objectif est uniquement de locker le panneau de commande d'une imprimante, il y a bien plus simple en utilisant directement des commandes PJL :
telnet 172.xxx.xxx.xxx 9100
Trying 172.xxx.xxx.xxx...
Connected to xxxxxxxxxxxx
Escape character is '^]'.
@PJL DEFAULT CPLOCK=MAXIMUM
@PJL INQUIRE CPLOCK
MAXIMUM
^]
telnet> quit
Connection closed. |
Autre niveau de blocage : MODERATE
Sources http://www.irongeek.com/i.php?page=security/networkprinterhacking#Coding your own scripts with Perl and PJL
Note :
J'ai lu pas mal de méthodes que je n'ai pas réussi à mettre en oeuvre...
http://h30499.www3.hp.com/t5/Black-and-White/Front-Panel-Lock-by-Telnet/td-p/4717027
http://www.guinix.com/technote/pjl.html
Quelques commandes PJL
Source : http://www.math.cas.cz/~jarnik/utl/HP/PJL%20Commands.html
To communicate with an HP JetDirect card, you can use lpd protocol or
telnet to port 9099 or 9100.
For lpd protocol, use queue names raw or text. Queue text will probably do
text-to-PostScript or text-to-PCL conversion, and queue raw will accept
PostScript or PCL.
There seems no difference between telnet connections to port 9099 and 9100.
Only one simultaneous connection seems to be accepted. Once a telnet
connection is established, older (pre-1998) printers refuse connections to
the either these ports or the lpd port; newer (post-2000) printers accept
the connection but seem to be ignore the data sent. If we set idle_timeout
to 0 then we could 'hog' the only allowed connection.
#################
# * All PJL jobs must begin and end with a
# Universal Exit Language (UEL) command
# "<ESC>%-12345X". This command exits the
# current printer language and returns
# control to PJL.
# * The UEL command at the beginning of the
# job must be immediately followed by the PJL
# command prefix "@PJL". The "@PJL" may be
# the prefix of another PJL command. Or, if
# the command is ended with the "@PJL" then
# it must be followed by a linefeed
# character. A carriage return is optional.
# No other characters, including control
# characters, are allowed between the UEL
# command and the @PJL prefix (see any of the
# examples below).
# * The UEL command at the job end must not
# be followed by anything (except the first
# character of the next job).
# * Line Termination--a line feed character
# is required to terminate all PJL commands
# except the UEL command. A carriage return
# can precede the terminating line feed;
# however, the carriage return is optional
# and is ignored.
# * No blank command lines are allowed.
#
# Often you would then use the sequence:
# <ESC>%-12345X@PJL
# @PJL JOB
# @PJL command1
# @PJL command2
# @PJL EOJ
# <ESC>%-12345X
#
# What does this do?:
# @PJL SAVETIME
#
#
# Four Levels of Control Panel Lock (CPLOCK)
# @PJL DEFAULT CPLOCK=MINIMUM
# MINIMUM Menus that are unlocked: Information, Paper Handling, Print Quality, EIO
# @PJL DEFAULT CPLOCK=MODERATE
# MODERATE Menus that are unlocked: Information, Printing
# @PJL DEFAULT CPLOCK=MAXIMUM (or ON)
# MAXIMUM Menus that are unlocked: (none)
# @PJL DEFAULT CPLOCK=NONE (or OFF)
# OFF Menus that are unlocked: (all)
#
# Password
# @PJL DEFAULT PASSWORD=[numeric password 1 to 65535, 0 disables]
# @PJL JOB PASSWORD = value [if password has been set]
#
# Common PJL Commands
# @PJL COMMENT some text to ignore
# @PJL ECHO "text to show"
# @PJL ENTER LANGUAGE = PCL, POSTSCRIPT, ESCP [finish with <ESC>%-12345X@PJL]
# @PJL INITIALIZE [NOTE: Use Initialize, not Reset]
# @PJL OPMSG DISPLAY="MESSAGE" [NOTE: will wait for operator to press GO]
# @PJL RDYMSG DISPLAY="MESSAGE"
# @PJL RESET [NOTE: What does this do?]
# @PJL SET TESTPAGE=SELFTEST, CONTSELFTEST, PCLTYPELIST, PCLDEMOPAGE, PSCONFIGPAGE, PSTYPEFACELIST, PSDEMOPAGE
# @PJL STMSG DISPLAY="MESSAGE" [NOTE: will wait for operator to press a key]
# @PJL USTATUSOFF [NOTE: What does this do?]
#
# To change settings for just the current job, replace "DEFAULT" with
# "SET", or with "USTATUS" (what does that do?).
# @PJL DEFAULT AUTOCONT=ON or OFF
# @PJL DEFAULT BINDING=LONGEDGE or SHORTEDGE
# @PJL DEFAULT COPIES=1 to 999
# @PJL DEFAULT COURIER=DARK
# @PJL DEFAULT DENSITY=1, 2, 3, 4 or 5
# @PJL DEFAULT DUPLEX=ON or OFF
# @PJL DEFAULT ECONOMODE=ON or OFF
# @PJL DEFAULT FINISH = STAPLE
# @PJL DEFAULT FORMLINES=5 to 128
# @PJL DEFAULT JOBOFFSET=ON or OFF
# @PJL DEFAULT LPARM : PCL FONTNUMBER=2
# @PJL DEFAULT LPARM : PCL PITCH=.44 to 99.99
# @PJL DEFAULT LPARM : PCL PTSIZE=4 to 999.75
# @PJL DEFAULT LPARM : PCL SYMSET=PC8
# @PJL DEFAULT MANUALFEED=ON or OFF
# @PJL DEFAULT MEDIATYPE = paper, glossy, TRANSPARENCY, special
# @PJL DEFAULT MPTRAY=FIRST or CASSETTE
# @PJL DEFAULT ORIENTATION=LANDSCAPE
# @PJL DEFAULT OUTBIN=UPPER, LOWER, SIDE, bin1, bin2
# @PJL DEFAULT PAPER=Letter, Legal, Executive, Ledger, Com10, B4, B5, Custom, JISB4, JISB5, JPost, JPostD, A3, A4, C5, DL, Monarch
# @PJL DEFAULT POWERSAVE = ON or OFF
# @PJL DEFAULT POWERSAVETIME = 15, 30, 60, 90, 120 [or other values of minutes?]
# @PJL DEFAULT PRINTERNAME=XXXXXXX
# @PJL DEFAULT PRINTQUALITY = draft, normal, high
# @PJL DEFAULT PS:MBT=ON, OFF, or AUTO [NOTE: Memory Booster Technology]
# @PJL DEFAULT RENDERMODE = COLOR, GRAYSCALE
# @PJL DEFAULT RESOLUTION = 300, 600, 1200
# @PJL DEFAULT RET=ON, OFF, LIGHT, MEDIUM OR DARK [NOTE: RET is Resolution Enhancement]
#
# Where would the info be returned?
# @PJL INFO PAGECOUNT [Shows: number]
# @PJL INFO STATUS [Shows: CODE=number nl DISPLAY="str" nl ONLINE=TRUE or FALSE]
# Seems that we can INQUIRE most anything that we can SET
# (what is the difference between DINQUIRE and plain INQUIRE?):
# @PJL INQUIRE CPLOCK [Shows: ON or OFF]
# @PJL INQUIRE PASSWORD [Shows: ENABLED or DISABLED]
# @PJL INQUIRE POWERSAVE [Shows: ON or OFF]
# @PJL INQUIRE POWERSAVETIME [Shows: number]
#
| Manipuler la configuration de copieurs avec wget |  |
Ce script permet à l'aide de wget de se connecter au copieur, d'enregistrer le cookie de session et de passer des commandes au copieur.
#!/bin/bash
#
# Modification de la config des copieurs avec wget
#
# B Richard DSI - janvier 2013
#
#DEBUG=1
DEBUG=0
# Liste des copieurs à modifier (noms des copieurs séparés par un espace)
LISTE_MFP="copieur1 copieur2"
# commande à exécuter
# modification de la configuration des interfaces USB et réseau : passage en auto
CMD="ggt_textbox%282%29=60&ggt_checkbox%283%29=1&ggt_select%284%29=0&ggt_checkbox%285%29=1&ggt_select%286%29=0&ggt_select%287%29=0&action=submitbtn"
for mfp in $LISTE_MFP
do
echo modification de $mfp en cours - les fichiers récupérés sont enregistrés dans /tmp/log-modifs-$mfp
# preparations
[ -d /tmp/log-modifs-$mfp ] && rm -r /tmp/log-modifs-$mfp
mkdir /tmp/log-modifs-$mfp
cd /tmp/log-modifs-$mfp
# on se connecte et on enregistre le cookie
wget --cookies=on --keep-session-cookies --save-cookies /tmp/cmfp.txt http://$mfp/
wget --referer="http://$mfp/login.html?/main.html" --cookies=on --keep-session-cookies --load-cookies /tmp/cmfp.txt --save-cookies /tmp/cmfp.txt --post-data 'ggt_textbox%2810006%29=beaupasswd&action=loginbtn&ggt_hidden%2810008%29=3' http://$mfp/login.html?/main.html
# on execute la commande
wget --referer="http://$mfp/login.html?/main.html" --cookies=on --keep-session-cookies --load-cookies /tmp/cmfp.txt --save-cookies /tmp/cmfp.txt --post-data "$CMD" http://$mfp/sys_printer_if.html
# on recupere des infos
wget --cookies=on --keep-session-cookies --load-cookies /tmp/cmfp.txt http://$mfp/sys_count.html
# suppression du cookie
rm /tmp/cmfp.txt
# affichages
echo modification de $mfp ok
# recuperations d'informations
# le modele
modele_ligne=$(cat /tmp/log-modifs-$mfp/index.html |grep modelName)
modele=$(expr "$modele_ligne" : ".*<div class="modelName">(.*)</div>.*")
echo -e "npour info, il s agit d un modele $modele"
# le nombre d'impressions
data=$(tr 'n' ' ' < /tmp/log-modifs-$mfp/sys_count.html|sed 's/x14//g'|sed 's/x09//g') # on supprime des caractères qui nous embetent
[ $DEBUG -eq 1 ] && echo $data > /tmp/log-modifs-$mfp/sys_count.html.mod
if [ $modele = "MX-2010U" ]
then
nb_nb=$(expr "$data" : ".*Compteur totalisateur.*Noir et blanc(.*)Couleurs.*Nom du travail .*")
nb_coul=$(expr "$data" : ".*Compteur totalisateur.*Couleurs(.*)2 couleurs.*Nom du travail .*")
echo "nombre de copies noir et blanc : $nb_nb"
echo "nombre de copies couleurs : $nb_coul"
elif [ $modele = "MX-B382" ]
then
nb_nb=$(expr "$data" : ".*Compteur totalisateur.*Noir et blanc(.*)Couleurs.*Nom du travail .*")
echo "nombre de copies noir et blanc : $nb_nb"
fi
echo -e "nncopieur suivant ?"
read ok
done |
Les traitements avec expr sont faux : j'avais des pbs avec mon cms...
|
|
Contact
|
|---|
Pour m'envoyer un mail, Pour me laisser un commentaire :richard.brunooo chez gmail.com |  |
|
|