Address @jlee-r7's comments
parent
bab32d15f3
commit
af66310e3a
|
@ -1,2 +1,16 @@
|
|||
require "rex/proto/pjl/constants"
|
||||
# https://en.wikipedia.org/wiki/Printer_Job_Language
|
||||
# See external links for PJL spec
|
||||
|
||||
module Rex::Proto::PJL
|
||||
|
||||
require "rex/proto/pjl/client"
|
||||
|
||||
UEL = "\e%-12345X" # Universal Exit Language
|
||||
PREFIX = "@PJL"
|
||||
|
||||
INFO_ID = "#{PREFIX} INFO ID"
|
||||
INFO_STATUS = "#{PREFIX} INFO STATUS"
|
||||
|
||||
RDYMSG_DISPLAY = "#{PREFIX} RDYMSG DISPLAY"
|
||||
|
||||
end
|
||||
|
|
|
@ -1,95 +1,80 @@
|
|||
#
|
||||
# https://en.wikipedia.org/wiki/Printer_Job_Language
|
||||
#
|
||||
# See external links for PJL spec
|
||||
#
|
||||
|
||||
module Rex
|
||||
module Proto
|
||||
module PJL
|
||||
|
||||
module Rex::Proto::PJL
|
||||
class Client
|
||||
|
||||
def initialize(sock)
|
||||
@sock = sock
|
||||
end
|
||||
|
||||
#
|
||||
# Begin PJL job
|
||||
#
|
||||
def pjl_begin_job
|
||||
command = "#{PJL_UEL}#{PJL_PREFIX}\n"
|
||||
# @return [void]
|
||||
def begin_job
|
||||
command = "#{UEL}#{PREFIX}\n"
|
||||
@sock.put(command)
|
||||
end
|
||||
|
||||
#
|
||||
# End PJL job
|
||||
#
|
||||
def pjl_end_job
|
||||
command = "#{PJL_UEL}\n"
|
||||
# @return [void]
|
||||
def end_job
|
||||
command = "#{UEL}\n"
|
||||
@sock.put(command)
|
||||
end
|
||||
|
||||
#
|
||||
# Send INFO request and receive response
|
||||
#
|
||||
# @param category [String] INFO category
|
||||
# @return [String] INFO response
|
||||
#
|
||||
def pjl_get_info(category)
|
||||
def get_info(category)
|
||||
case category
|
||||
when :id
|
||||
command = "#{PJL_INFO_ID}\n"
|
||||
command = "#{INFO_ID}\n"
|
||||
when :status
|
||||
command = "#{PJL_INFO_STATUS}\n"
|
||||
command = "#{INFO_STATUS}\n"
|
||||
end
|
||||
pjl_begin_job
|
||||
begin_job
|
||||
@sock.put(command)
|
||||
pjl_end_job
|
||||
end_job
|
||||
@sock.get_once
|
||||
end
|
||||
|
||||
#
|
||||
# Get version information
|
||||
#
|
||||
# @return [String] Version information
|
||||
#
|
||||
def pjl_get_info_id
|
||||
def get_info_id
|
||||
id = nil
|
||||
response = pjl_get_info(:id)
|
||||
response = get_info(:id)
|
||||
if response =~ /"(.*)"/
|
||||
id = $1
|
||||
end
|
||||
return id
|
||||
end
|
||||
|
||||
#
|
||||
# Get ready message
|
||||
#
|
||||
# @return [String] Ready message
|
||||
#
|
||||
def pjl_get_rdymsg
|
||||
def get_rdymsg
|
||||
rdymsg = nil
|
||||
response = pjl_get_info(:status)
|
||||
response = get_info(:status)
|
||||
if response =~ /DISPLAY="(.*)"/
|
||||
rdymsg = $1
|
||||
end
|
||||
return rdymsg
|
||||
end
|
||||
|
||||
#
|
||||
# Set ready message
|
||||
#
|
||||
# @param message [String] Ready message
|
||||
#
|
||||
def pjl_set_rdymsg(message)
|
||||
command = %Q{#{PJL_RDYMSG_DISPLAY} = "#{message}"\n}
|
||||
pjl_begin_job
|
||||
# @return [void]
|
||||
def set_rdymsg(message)
|
||||
command = %Q{#{RDYMSG_DISPLAY} = "#{message}"\n}
|
||||
begin_job
|
||||
@sock.put(command)
|
||||
pjl_end_job
|
||||
end_job
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#
|
||||
# https://en.wikipedia.org/wiki/Printer_Job_Language
|
||||
#
|
||||
# See external links for PJL spec
|
||||
#
|
||||
|
||||
module Rex
|
||||
module Proto
|
||||
module PJL
|
||||
|
||||
# Miscellaneous constants
|
||||
PJL_PREFIX = "@PJL"
|
||||
|
||||
# Kernel commands
|
||||
PJL_UEL = "\e%-12345X"
|
||||
|
||||
# Status readback commands
|
||||
PJL_INFO_ID = "#{PJL_PREFIX} INFO ID"
|
||||
PJL_INFO_STATUS = "#{PJL_PREFIX} INFO STATUS"
|
||||
|
||||
# Device attendance commands
|
||||
PJL_RDYMSG_DISPLAY = "#{PJL_PREFIX} RDYMSG DISPLAY"
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,9 +8,9 @@ require "rex/proto/pjl"
|
|||
|
||||
class Metasploit4 < Msf::Auxiliary
|
||||
|
||||
include Msf::Auxiliary::Scanner
|
||||
include Msf::Auxiliary::Report
|
||||
include Msf::Exploit::Remote::Tcp
|
||||
include Msf::Auxiliary::Report
|
||||
include Msf::Auxiliary::Scanner
|
||||
|
||||
def initialize(info = {})
|
||||
super(update_info(info,
|
||||
|
@ -39,11 +39,11 @@ class Metasploit4 < Msf::Auxiliary
|
|||
def run_host(ip)
|
||||
connect
|
||||
pjl = Rex::Proto::PJL::Client.new(sock)
|
||||
rdymsg = pjl.pjl_get_rdymsg
|
||||
rdymsg = pjl.get_rdymsg
|
||||
if datastore["CHANGE"]
|
||||
message = datastore["MESSAGE"]
|
||||
pjl.pjl_set_rdymsg(message)
|
||||
rdymsg = pjl.pjl_get_rdymsg
|
||||
pjl.set_rdymsg(message)
|
||||
rdymsg = pjl.get_rdymsg
|
||||
end
|
||||
disconnect
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ require "rex/proto/pjl"
|
|||
|
||||
class Metasploit4 < Msf::Auxiliary
|
||||
|
||||
include Msf::Auxiliary::Scanner
|
||||
include Msf::Auxiliary::Report
|
||||
include Msf::Exploit::Remote::Tcp
|
||||
include Msf::Auxiliary::Report
|
||||
include Msf::Auxiliary::Scanner
|
||||
|
||||
def initialize(info = {})
|
||||
super(update_info(info,
|
||||
|
@ -37,7 +37,7 @@ class Metasploit4 < Msf::Auxiliary
|
|||
def run_host(ip)
|
||||
connect
|
||||
pjl = Rex::Proto::PJL::Client.new(sock)
|
||||
id = pjl.pjl_get_info_id
|
||||
id = pjl.get_info_id
|
||||
disconnect
|
||||
|
||||
if id
|
||||
|
|
Loading…
Reference in New Issue