2013-12-04 21:46:45 -06:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-12-04 21:46:45 -06:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
require "rex/proto/pjl"
|
|
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2013-12-04 21:46:45 -06:00
|
|
|
include Msf::Exploit::Remote::Tcp
|
2013-12-05 10:25:04 -06:00
|
|
|
include Msf::Auxiliary::Scanner
|
2014-01-15 13:49:37 -06:00
|
|
|
include Msf::Auxiliary::Report
|
2013-12-04 21:46:45 -06:00
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
|
super(update_info(info,
|
2014-01-15 13:49:37 -06:00
|
|
|
"Name" => "Printer Directory Listing Scanner",
|
|
|
|
|
"Description" => %q{
|
2014-01-21 13:29:08 -06:00
|
|
|
This module lists a directory on a set of printers using the
|
|
|
|
|
Printer Job Language (PJL) protocol.
|
2013-12-04 21:46:45 -06:00
|
|
|
},
|
2014-01-15 13:49:37 -06:00
|
|
|
"Author" => [
|
2014-01-25 17:36:08 -06:00
|
|
|
"wvu", # Rex::Proto::PJL and modules
|
2014-01-15 13:49:37 -06:00
|
|
|
"sinn3r", # RSpec tests
|
2014-01-25 17:36:08 -06:00
|
|
|
"MC", # Independent mixin and modules
|
|
|
|
|
"Myo Soe", # Independent modules
|
2014-01-27 08:40:44 -06:00
|
|
|
"Matteo Cantoni <goony[at]nothink.org>" # Independent modules
|
2013-12-05 00:28:53 -06:00
|
|
|
],
|
2014-01-15 13:49:37 -06:00
|
|
|
"References" => [
|
2013-12-04 21:46:45 -06:00
|
|
|
["URL", "https://en.wikipedia.org/wiki/Printer_Job_Language"]
|
|
|
|
|
],
|
2014-01-15 13:49:37 -06:00
|
|
|
"License" => MSF_LICENSE
|
2013-12-04 21:46:45 -06:00
|
|
|
))
|
|
|
|
|
|
|
|
|
|
register_options([
|
2014-01-15 13:49:37 -06:00
|
|
|
Opt::RPORT(Rex::Proto::PJL::DEFAULT_PORT),
|
2015-02-25 15:52:26 -06:00
|
|
|
OptString.new("PATH", [true, "Remote path", '0:\..\..\..'])
|
2017-05-03 15:42:21 -05:00
|
|
|
])
|
2013-12-04 21:46:45 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def run_host(ip)
|
2015-02-25 15:52:26 -06:00
|
|
|
path = datastore["PATH"]
|
2014-01-15 13:49:37 -06:00
|
|
|
|
2013-12-04 21:46:45 -06:00
|
|
|
connect
|
|
|
|
|
pjl = Rex::Proto::PJL::Client.new(sock)
|
2013-12-16 11:38:52 -06:00
|
|
|
pjl.begin_job
|
2014-01-15 13:49:37 -06:00
|
|
|
|
2015-02-25 15:52:26 -06:00
|
|
|
pjl.fsinit(path[0..1])
|
|
|
|
|
listing = pjl.fsdirlist(path)
|
2014-01-15 13:49:37 -06:00
|
|
|
|
2013-12-16 11:38:52 -06:00
|
|
|
pjl.end_job
|
2013-12-04 21:46:45 -06:00
|
|
|
disconnect
|
|
|
|
|
|
2013-12-05 10:56:28 -06:00
|
|
|
if listing
|
2014-01-21 13:29:08 -06:00
|
|
|
print_good("#{ip}:#{rport} - #{listing}")
|
2014-03-28 02:15:38 -05:00
|
|
|
report_note(
|
2013-12-04 21:46:45 -06:00
|
|
|
:host => ip,
|
|
|
|
|
:port => rport,
|
|
|
|
|
:proto => "tcp",
|
2013-12-05 10:56:28 -06:00
|
|
|
:type => "printer.dir.listing",
|
|
|
|
|
:data => listing
|
2014-03-28 02:15:38 -05:00
|
|
|
)
|
2013-12-04 21:46:45 -06:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|