Skip to content

Commit

Permalink
Land #8830, Cleanup auxiliary/scanner/msf/msf_rpc_login
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Cook committed Aug 14, 2017
2 parents 59086af + fa4fae3 commit 9fdf2ca
Showing 1 changed file with 25 additions and 33 deletions.
58 changes: 25 additions & 33 deletions modules/auxiliary/scanner/msf/msf_rpc_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core/rpc/v10/client'

class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::Tcp
include Msf::Auxiliary::Report
include Msf::Auxiliary::AuthBrute
include Msf::Auxiliary::Scanner

def initialize
super(
def initialize(info = {})
super(update_info(info,
'Name' => 'Metasploit RPC Interface Login Utility',
'Description' => %q{
This module simply attempts to login to a
Metasploit RPC interface using a specific
user/pass.
},
'Author' => [ 'Vlatko Kosturjak <kost[at]linux.hr>' ],
'License' => MSF_LICENSE
)
'Author' => [ 'Vlatko Kosturjak <kost[at]linux.hr>' ],
'License' => MSF_LICENSE
))

register_options(
[
Expand All @@ -27,34 +30,21 @@ def initialize
OptBool.new('BLANK_PASSWORDS', [false, "Try blank passwords for all users", false]),
OptBool.new('SSL', [ true, "Negotiate SSL for outgoing connections", true])
])
register_autofilter_ports([3790])

end

@@loaded_msfrpc = false
begin
require 'msf/core/rpc/v10/client'
@@loaded_msfrpc = true
rescue LoadError
register_autofilter_ports([3790])
end

def run_host(ip)

unless @@loaded_msfrpc
print_error("You don't have 'msgpack', please install that gem manually.")
return
end

begin
@rpc = Msf::RPC::Client.new(
:host => datastore['RHOST'],
:port => datastore['RPORT'],
:ssl => datastore['SSL']
:host => rhost,
:port => rport,
:ssl => ssl
)
rescue ::Interrupt
raise $!
rescue ::Exception => e
vprint_error("#{datastore['SSL'].to_s} Cannot create RPC client : #{e.to_s}")
rescue => e
vprint_error("Cannot create RPC client : #{e}")
return
end

Expand Down Expand Up @@ -90,27 +80,29 @@ def report_cred(opts)
create_credential_login(login_data)
end

def do_login(user='msf', pass='msf')
def do_login(user = 'msf', pass = 'msf')
vprint_status("Trying username:'#{user}' with password:'#{pass}'")
begin
res = @rpc.login(user, pass)
if res
print_good("SUCCESSFUL LOGIN. '#{user}' : '#{pass}'")
report_cred(
ip: datastore['RHOST'],
port: datastore['RPORT'],
ip: rhost,
port: rport,
service_name: 'msf-rpc',
user: user,
password: pass,
proof: res.body
password: pass
)
@rpc.close
return :next_user
end
rescue => e
vprint_status("#{datastore['SSL'].to_s} - Bad login")
@rpc.close
rescue Rex::ConnectionRefused => e
print_error("Connection refused : #{e}")
return :abort
rescue => e
vprint_status("#{peer} - Bad login")
return :skip_pass
end
ensure
@rpc.close
end
end

0 comments on commit 9fdf2ca

Please sign in to comment.