CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/modules/auxiliary/scanner/nessus/nessus_xmlrpc_login.rb
Views: 1904
##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])29end3031def run_host(ip)32begin33res = send_request_cgi({34'uri' => datastore['URI'],35'method' => 'GET'36}, 25)37http_fingerprint({ :response => res })38rescue ::Rex::ConnectionError => e39vprint_error("#{datastore['URI']} - #{e}")40return41end4243if not res44vprint_error("#{datastore['URI']} - No response")45return46end47if res.code != 40348vprint_error("Authorization not requested")49return50end5152each_user_pass do |user, pass|53do_login(user, pass)54end55end5657def do_login(user='nessus', pass='nessus')58vprint_status("Trying username:'#{user}' with password:'#{pass}'")59headers = {}6061begin62res = send_request_cgi({63'encode' => true,64'uri' => datastore['URI'],65'method' => 'POST',66'headers' => headers,67'vars_post' => {68'login' => user,69'password' => pass70}71}, 25)7273rescue ::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