Path: blob/master/modules/auxiliary/scanner/nessus/nessus_xmlrpc_login.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient7include Msf::Auxiliary::Report8include Msf::Auxiliary::AuthBrute9include Msf::Auxiliary::Scanner1011def initialize12super(13'Name' => 'Nessus XMLRPC Interface Login Utility',14'Description' => %q{15This module simply attempts to login to a Nessus XMLRPC interface using a16specific user/pass.17},18'Author' => [ 'Vlatko Kosturjak <kost[at]linux.hr>' ],19'License' => MSF_LICENSE,20'DefaultOptions' => { 'SSL' => true }21)2223register_options(24[25Opt::RPORT(8834),26OptString.new('URI', [true, "URI for Nessus XMLRPC login. Default is /login", "/login"]),27OptBool.new('BLANK_PASSWORDS', [false, "Try blank passwords for all users", false])28]29)30end3132def run_host(ip)33begin34res = send_request_cgi({35'uri' => datastore['URI'],36'method' => 'GET'37}, 25)38http_fingerprint({ :response => res })39rescue ::Rex::ConnectionError => e40vprint_error("#{datastore['URI']} - #{e}")41return42end4344if not res45vprint_error("#{datastore['URI']} - No response")46return47end48if res.code != 40349vprint_error("Authorization not requested")50return51end5253each_user_pass do |user, pass|54do_login(user, pass)55end56end5758def do_login(user = 'nessus', pass = 'nessus')59vprint_status("Trying username:'#{user}' with password:'#{pass}'")60headers = {}6162begin63res = send_request_cgi({64'encode' => true,65'uri' => datastore['URI'],66'method' => 'POST',67'headers' => headers,68'vars_post' => {69'login' => user,70'password' => pass71}72}, 25)73rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT74print_error("HTTP Connection Failed, Aborting")75return :abort76end7778if not res79print_error("Connection timed out, Aborting")80return :abort81end8283if res.code != 20084vprint_error("FAILED LOGIN. '#{user}' : '#{pass}'")85return :skip_pass86end8788if res.code == 20089if res.body =~ /<status>OK<\/status>/90print_good("SUCCESSFUL LOGIN. '#{user}':'#{pass}'")91report_cred(92ip: datastore['RHOST'],93port: datastore['RPORT'],94service_name: 'nessus-xmlrpc',95user: user,96password: pass97)98return :next_user99end100end101vprint_error("FAILED LOGIN. '#{user}':'#{pass}'")102return :skip_pass103end104105def report_cred(opts)106service_data = {107address: opts[:ip],108port: opts[:port],109service_name: opts[:service_name],110protocol: 'tcp',111workspace_id: myworkspace_id112}113114credential_data = {115origin_type: :service,116module_fullname: fullname,117username: opts[:user],118private_data: opts[:password],119private_type: :password120}.merge(service_data)121122login_data = {123last_attempted_at: DateTime.now,124core: create_credential(credential_data),125status: Metasploit::Model::Login::Status::SUCCESSFUL,126}.merge(service_data)127128create_credential_login(login_data)129end130end131132133