Land #8830, Cleanup auxiliary/scanner/msf/msf_rpc_login

bug/bundler_fix
Brent Cook 2017-08-14 02:47:08 -04:00
commit 9fdf2ca1f4
No known key found for this signature in database
GPG Key ID: 1FFAA0B24B708F96
1 changed files with 25 additions and 33 deletions

View File

@ -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(
[
@ -27,34 +30,21 @@ class MetasploitModule < Msf::Auxiliary
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
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
@ -90,27 +80,29 @@ class MetasploitModule < Msf::Auxiliary
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