Address @jlee-r7's comments

bug/bundler_fix
William Vu 2013-12-05 10:25:04 -06:00
parent bab32d15f3
commit af66310e3a
5 changed files with 47 additions and 74 deletions

View File

@ -1,2 +1,16 @@
require "rex/proto/pjl/constants" # https://en.wikipedia.org/wiki/Printer_Job_Language
require "rex/proto/pjl/client" # 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

View File

@ -1,95 +1,80 @@
#
# https://en.wikipedia.org/wiki/Printer_Job_Language # https://en.wikipedia.org/wiki/Printer_Job_Language
#
# See external links for PJL spec # See external links for PJL spec
#
module Rex
module Proto
module PJL
module Rex::Proto::PJL
class Client class Client
def initialize(sock) def initialize(sock)
@sock = sock @sock = sock
end end
#
# Begin PJL job # Begin PJL job
# #
def pjl_begin_job # @return [void]
command = "#{PJL_UEL}#{PJL_PREFIX}\n" def begin_job
command = "#{UEL}#{PREFIX}\n"
@sock.put(command) @sock.put(command)
end end
#
# End PJL job # End PJL job
# #
def pjl_end_job # @return [void]
command = "#{PJL_UEL}\n" def end_job
command = "#{UEL}\n"
@sock.put(command) @sock.put(command)
end end
#
# Send INFO request and receive response # Send INFO request and receive response
# #
# @param category [String] INFO category # @param category [String] INFO category
# @return [String] INFO response # @return [String] INFO response
# def get_info(category)
def pjl_get_info(category)
case category case category
when :id when :id
command = "#{PJL_INFO_ID}\n" command = "#{INFO_ID}\n"
when :status when :status
command = "#{PJL_INFO_STATUS}\n" command = "#{INFO_STATUS}\n"
end end
pjl_begin_job begin_job
@sock.put(command) @sock.put(command)
pjl_end_job end_job
@sock.get_once @sock.get_once
end end
#
# Get version information # Get version information
# #
# @return [String] Version information # @return [String] Version information
# def get_info_id
def pjl_get_info_id
id = nil id = nil
response = pjl_get_info(:id) response = get_info(:id)
if response =~ /"(.*)"/ if response =~ /"(.*)"/
id = $1 id = $1
end end
return id return id
end end
#
# Get ready message # Get ready message
# #
# @return [String] Ready message # @return [String] Ready message
# def get_rdymsg
def pjl_get_rdymsg
rdymsg = nil rdymsg = nil
response = pjl_get_info(:status) response = get_info(:status)
if response =~ /DISPLAY="(.*)"/ if response =~ /DISPLAY="(.*)"/
rdymsg = $1 rdymsg = $1
end end
return rdymsg return rdymsg
end end
#
# Set ready message # Set ready message
# #
# @param message [String] Ready message # @param message [String] Ready message
# # @return [void]
def pjl_set_rdymsg(message) def set_rdymsg(message)
command = %Q{#{PJL_RDYMSG_DISPLAY} = "#{message}"\n} command = %Q{#{RDYMSG_DISPLAY} = "#{message}"\n}
pjl_begin_job begin_job
@sock.put(command) @sock.put(command)
pjl_end_job end_job
end end
end end
end end
end
end

View File

@ -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

View File

@ -8,9 +8,9 @@ require "rex/proto/pjl"
class Metasploit4 < Msf::Auxiliary class Metasploit4 < Msf::Auxiliary
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report
include Msf::Exploit::Remote::Tcp include Msf::Exploit::Remote::Tcp
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner
def initialize(info = {}) def initialize(info = {})
super(update_info(info, super(update_info(info,
@ -39,11 +39,11 @@ class Metasploit4 < Msf::Auxiliary
def run_host(ip) def run_host(ip)
connect connect
pjl = Rex::Proto::PJL::Client.new(sock) pjl = Rex::Proto::PJL::Client.new(sock)
rdymsg = pjl.pjl_get_rdymsg rdymsg = pjl.get_rdymsg
if datastore["CHANGE"] if datastore["CHANGE"]
message = datastore["MESSAGE"] message = datastore["MESSAGE"]
pjl.pjl_set_rdymsg(message) pjl.set_rdymsg(message)
rdymsg = pjl.pjl_get_rdymsg rdymsg = pjl.get_rdymsg
end end
disconnect disconnect

View File

@ -8,9 +8,9 @@ require "rex/proto/pjl"
class Metasploit4 < Msf::Auxiliary class Metasploit4 < Msf::Auxiliary
include Msf::Auxiliary::Scanner
include Msf::Auxiliary::Report
include Msf::Exploit::Remote::Tcp include Msf::Exploit::Remote::Tcp
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner
def initialize(info = {}) def initialize(info = {})
super(update_info(info, super(update_info(info,
@ -37,7 +37,7 @@ class Metasploit4 < Msf::Auxiliary
def run_host(ip) def run_host(ip)
connect connect
pjl = Rex::Proto::PJL::Client.new(sock) pjl = Rex::Proto::PJL::Client.new(sock)
id = pjl.pjl_get_info_id id = pjl.get_info_id
disconnect disconnect
if id if id