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 # Current source: https://github.com/rapid7/metasploit-framework
## ##
require 'msf/core/rpc/v10/client'
class MetasploitModule < Msf::Auxiliary class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::Tcp
include Msf::Auxiliary::Report include Msf::Auxiliary::Report
include Msf::Auxiliary::AuthBrute include Msf::Auxiliary::AuthBrute
include Msf::Auxiliary::Scanner include Msf::Auxiliary::Scanner
def initialize def initialize(info = {})
super( super(update_info(info,
'Name' => 'Metasploit RPC Interface Login Utility', 'Name' => 'Metasploit RPC Interface Login Utility',
'Description' => %q{ 'Description' => %q{
This module simply attempts to login to a This module simply attempts to login to a
Metasploit RPC interface using a specific Metasploit RPC interface using a specific
user/pass. user/pass.
}, },
'Author' => [ 'Vlatko Kosturjak <kost[at]linux.hr>' ], 'Author' => [ 'Vlatko Kosturjak <kost[at]linux.hr>' ],
'License' => MSF_LICENSE 'License' => MSF_LICENSE
) ))
register_options( register_options(
[ [
@ -27,34 +30,21 @@ class MetasploitModule < Msf::Auxiliary
OptBool.new('BLANK_PASSWORDS', [false, "Try blank passwords for all users", false]), OptBool.new('BLANK_PASSWORDS', [false, "Try blank passwords for all users", false]),
OptBool.new('SSL', [ true, "Negotiate SSL for outgoing connections", true]) OptBool.new('SSL', [ true, "Negotiate SSL for outgoing connections", true])
]) ])
register_autofilter_ports([3790]) register_autofilter_ports([3790])
end
@@loaded_msfrpc = false
begin
require 'msf/core/rpc/v10/client'
@@loaded_msfrpc = true
rescue LoadError
end end
def run_host(ip) def run_host(ip)
unless @@loaded_msfrpc
print_error("You don't have 'msgpack', please install that gem manually.")
return
end
begin begin
@rpc = Msf::RPC::Client.new( @rpc = Msf::RPC::Client.new(
:host => datastore['RHOST'], :host => rhost,
:port => datastore['RPORT'], :port => rport,
:ssl => datastore['SSL'] :ssl => ssl
) )
rescue ::Interrupt rescue ::Interrupt
raise $! raise $!
rescue ::Exception => e rescue => e
vprint_error("#{datastore['SSL'].to_s} Cannot create RPC client : #{e.to_s}") vprint_error("Cannot create RPC client : #{e}")
return return
end end
@ -90,27 +80,29 @@ class MetasploitModule < Msf::Auxiliary
create_credential_login(login_data) create_credential_login(login_data)
end end
def do_login(user='msf', pass='msf') def do_login(user = 'msf', pass = 'msf')
vprint_status("Trying username:'#{user}' with password:'#{pass}'") vprint_status("Trying username:'#{user}' with password:'#{pass}'")
begin begin
res = @rpc.login(user, pass) res = @rpc.login(user, pass)
if res if res
print_good("SUCCESSFUL LOGIN. '#{user}' : '#{pass}'") print_good("SUCCESSFUL LOGIN. '#{user}' : '#{pass}'")
report_cred( report_cred(
ip: datastore['RHOST'], ip: rhost,
port: datastore['RPORT'], port: rport,
service_name: 'msf-rpc', service_name: 'msf-rpc',
user: user, user: user,
password: pass, password: pass
proof: res.body
) )
@rpc.close
return :next_user return :next_user
end end
rescue => e rescue Rex::ConnectionRefused => e
vprint_status("#{datastore['SSL'].to_s} - Bad login") print_error("Connection refused : #{e}")
@rpc.close return :abort
rescue => e
vprint_status("#{peer} - Bad login")
return :skip_pass return :skip_pass
end end
ensure
@rpc.close
end end
end end