|
@@ -46,7 +46,7 @@ class MetasploitModule < Msf::Auxiliary
|
46
|
46
|
[
|
47
|
47
|
Opt::RPORT(22),
|
48
|
48
|
OptPath.new('KEY_FILE', [false, 'Filename of one or several cleartext public keys.'])
|
49
|
|
- ], self.class
|
|
49
|
+ ]
|
50
|
50
|
)
|
51
|
51
|
|
52
|
52
|
register_advanced_options(
|
|
@@ -59,7 +59,9 @@ class MetasploitModule < Msf::Auxiliary
|
59
|
59
|
]
|
60
|
60
|
)
|
61
|
61
|
|
62
|
|
- deregister_options('RHOST','PASSWORD','PASS_FILE','BLANK_PASSWORDS','USER_AS_PASS')
|
|
62
|
+ deregister_options(
|
|
63
|
+ 'RHOST','PASSWORD','PASS_FILE','BLANK_PASSWORDS','USER_AS_PASS', 'USERPASS_FILE', 'DB_ALL_PASS', 'DB_ALL_CREDS'
|
|
64
|
+ )
|
63
|
65
|
|
64
|
66
|
@good_credentials = {}
|
65
|
67
|
@good_key = ''
|
|
@@ -71,6 +73,10 @@ class MetasploitModule < Msf::Auxiliary
|
71
|
73
|
datastore['KEY_DIR']
|
72
|
74
|
end
|
73
|
75
|
|
|
76
|
+ def key_file
|
|
77
|
+ datastore['KEY_FILE']
|
|
78
|
+ end
|
|
79
|
+
|
74
|
80
|
def rport
|
75
|
81
|
datastore['RPORT']
|
76
|
82
|
end
|
|
@@ -95,8 +101,8 @@ class MetasploitModule < Msf::Auxiliary
|
95
|
101
|
this_key = []
|
96
|
102
|
in_key = false
|
97
|
103
|
keyfile.split("\n").each do |line|
|
98
|
|
- if line =~ /ssh-(dss|rsa)\s+/
|
99
|
|
- keys << line
|
|
104
|
+ if /(?<key>ssh-(?:dss|rsa)\s+.*)/ =~ line
|
|
105
|
+ keys << key
|
100
|
106
|
next
|
101
|
107
|
end
|
102
|
108
|
in_key = true if(line =~ /^-----BEGIN [RD]SA (PRIVATE|PUBLIC) KEY-----/)
|
|
@@ -162,8 +168,8 @@ class MetasploitModule < Msf::Auxiliary
|
162
|
168
|
|
163
|
169
|
def do_login(ip, port, user)
|
164
|
170
|
|
165
|
|
- if datastore['KEY_FILE'] and File.readable?(datastore['KEY_FILE'])
|
166
|
|
- keys = read_keyfile(datastore['KEY_FILE'])
|
|
171
|
+ if key_file && File.readable?(key_file)
|
|
172
|
+ keys = read_keyfile(key_file)
|
167
|
173
|
cleartext_keys = pull_cleartext_keys(keys)
|
168
|
174
|
msg = "#{ip}:#{rport} SSH - Trying #{cleartext_keys.size} cleartext key#{(cleartext_keys.size > 1) ? "s" : ""} per user."
|
169
|
175
|
elsif datastore['SSH_KEYFILE_B64'] && !datastore['SSH_KEYFILE_B64'].empty?
|