3
3
# Current source: https://github.com/rapid7/metasploit-framework
4
4
##
5
5
6
+ require 'msf/core/rpc/v10/client'
7
+
6
8
class MetasploitModule < Msf ::Auxiliary
9
+ include Msf ::Exploit ::Remote ::Tcp
7
10
include Msf ::Auxiliary ::Report
8
11
include Msf ::Auxiliary ::AuthBrute
9
12
include Msf ::Auxiliary ::Scanner
10
13
11
- def initialize
12
- super (
14
+ def initialize ( info = { } )
15
+ super ( update_info ( info ,
13
16
'Name' => 'Metasploit RPC Interface Login Utility' ,
14
17
'Description' => %q{
15
18
This module simply attempts to login to a
16
19
Metasploit RPC interface using a specific
17
20
user/pass.
18
21
} ,
19
- 'Author' => [ 'Vlatko Kosturjak <kost[at]linux.hr>' ] ,
20
- 'License' => MSF_LICENSE
21
- )
22
+ 'Author' => [ 'Vlatko Kosturjak <kost[at]linux.hr>' ] ,
23
+ 'License' => MSF_LICENSE
24
+ ) )
22
25
23
26
register_options (
24
27
[
@@ -27,34 +30,21 @@ def initialize
27
30
OptBool . new ( 'BLANK_PASSWORDS' , [ false , "Try blank passwords for all users" , false ] ) ,
28
31
OptBool . new ( 'SSL' , [ true , "Negotiate SSL for outgoing connections" , true ] )
29
32
] )
30
- register_autofilter_ports ( [ 3790 ] )
31
33
32
- end
33
-
34
- @@loaded_msfrpc = false
35
- begin
36
- require 'msf/core/rpc/v10/client'
37
- @@loaded_msfrpc = true
38
- rescue LoadError
34
+ register_autofilter_ports ( [ 3790 ] )
39
35
end
40
36
41
37
def run_host ( ip )
42
-
43
- unless @@loaded_msfrpc
44
- print_error ( "You don't have 'msgpack', please install that gem manually." )
45
- return
46
- end
47
-
48
38
begin
49
39
@rpc = Msf ::RPC ::Client . new (
50
- :host => datastore [ 'RHOST' ] ,
51
- :port => datastore [ 'RPORT' ] ,
52
- :ssl => datastore [ 'SSL' ]
40
+ :host => rhost ,
41
+ :port => rport ,
42
+ :ssl => ssl
53
43
)
54
44
rescue ::Interrupt
55
45
raise $!
56
- rescue :: Exception => e
57
- vprint_error ( "#{ datastore [ 'SSL' ] . to_s } Cannot create RPC client : #{ e . to_s } " )
46
+ rescue => e
47
+ vprint_error ( "Cannot create RPC client : #{ e } " )
58
48
return
59
49
end
60
50
@@ -90,27 +80,29 @@ def report_cred(opts)
90
80
create_credential_login ( login_data )
91
81
end
92
82
93
- def do_login ( user = 'msf' , pass = 'msf' )
83
+ def do_login ( user = 'msf' , pass = 'msf' )
94
84
vprint_status ( "Trying username:'#{ user } ' with password:'#{ pass } '" )
95
85
begin
96
86
res = @rpc . login ( user , pass )
97
87
if res
98
88
print_good ( "SUCCESSFUL LOGIN. '#{ user } ' : '#{ pass } '" )
99
89
report_cred (
100
- ip : datastore [ 'RHOST' ] ,
101
- port : datastore [ 'RPORT' ] ,
90
+ ip : rhost ,
91
+ port : rport ,
102
92
service_name : 'msf-rpc' ,
103
93
user : user ,
104
- password : pass ,
105
- proof : res . body
94
+ password : pass
106
95
)
107
- @rpc . close
108
96
return :next_user
109
97
end
110
- rescue => e
111
- vprint_status ( "#{ datastore [ 'SSL' ] . to_s } - Bad login" )
112
- @rpc . close
98
+ rescue Rex ::ConnectionRefused => e
99
+ print_error ( "Connection refused : #{ e } " )
100
+ return :abort
101
+ rescue => e
102
+ vprint_status ( "#{ peer } - Bad login" )
113
103
return :skip_pass
114
104
end
105
+ ensure
106
+ @rpc . close
115
107
end
116
108
end
0 commit comments