Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/dcerpc/hidden.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary67# Exploit mixins should be called first8include Msf::Exploit::Remote::DCERPC910include Msf::Auxiliary::Report1112# Scanner mixin should be near last13include Msf::Auxiliary::Scanner1415def initialize16super(17'Name' => 'Hidden DCERPC Service Discovery',18'Description' => %q{19This module will query the endpoint mapper and make a list20of all ncacn_tcp RPC services. It will then connect to each of21these services and use the management API to list all other22RPC services accessible on this port. Any RPC service found attached23to a TCP port, but not listed in the endpoint mapper, will be displayed24and analyzed to see whether anonymous access is permitted.25},26'Author' => 'hdm',27'License' => MSF_LICENSE28)2930deregister_options('RPORT')31end3233# Obtain information about a single host34def run_host(ip)35epm = dcerpc_endpoint_list36if !epm37print_status("Could not contact the endpoint mapper on #{ip}")38return39end4041eports = {}4243epm.each do |ep|44next if !(ep[:port] && ep[:prot] && (ep[:prot] == 'tcp'))4546eports[ep[:port]] ||= {}47eports[ep[:port]][ep[:uuid] + '_' + ep[:vers]] = true48end4950eports.each_pair do |eport, servs|51rport = eport52print_status("Looking for services on #{ip}:#{rport}...")5354ids = dcerpc_mgmt_inq_if_ids(rport)55next if !ids5657ids.each do |id|58next if servs.key?(id[0] + '_' + id[1])5960print_status("\tHIDDEN: UUID #{id[0]} v#{id[1]}")6162conn = nil63bind = nil64call = nil65data = nil66error = nil67begin68connect(true, { 'RPORT' => eport })69conn = true7071handle = dcerpc_handle(id[0], id[1], 'ncacn_ip_tcp', [eport])72dcerpc_bind(handle)73bind = true7475dcerpc.call(0, NDR.long(0) * 128)76call = true7778if (!dcerpc.last_response.nil? && !dcerpc.last_response.stub_data.nil?)79data = dcerpc.last_response.stub_data80end81rescue ::Interrupt82raise $ERROR_INFO83rescue ::Exception => e84error = e.to_s85end8687if error88if error =~ (/DCERPC FAULT/) && error !~ (/nca_s_fault_access_denied/)89call = true90else91elog(e)92end93end9495status = "\t\t"96status << 'CONN ' if conn97status << 'BIND ' if bind98status << 'CALL ' if call99status << "DATA=#{data.unpack('H*')[0]} " if data100status << "ERROR=#{error} " if error101102print_status(status)103print_status('')104105## Add Report106report_note(107host: ip,108proto: 'tcp',109port: datastore['RPORT'],110type: "DCERPC HIDDEN: UUID #{id[0]} v#{id[1]}",111data: status112)113end114end115rescue ::Interrupt116raise $ERROR_INFO117rescue ::Exception => e118print_status("Error: #{e}")119end120121end122123124