@@ -125,13 +125,102 @@ def report_note(opts={})
125
125
framework . db . report_note ( opts )
126
126
end
127
127
128
+ # This Legacy method is responsible for creating credentials from data supplied
129
+ # by a module. This method is deprecated and the new Metasploit::Credential methods
130
+ # should be used directly instead.
131
+ #
132
+ # @param :opts [Hash] the option hash
133
+ # @option opts [String] :host the address of the host (also takes a {Mdm::Host})
134
+ # @option opts [Fixnum] :port the port of the connected service
135
+ # @option opts [Mdm::Service] :service an optional Service object to build the cred for
136
+ # @option opts [String] :type What type of private credential this is (e.g. "password", "hash", "ssh_key")
137
+ # @option opts [String] :proto Which transport protocol the service uses
138
+ # @option opts [String] :sname The 'name' of the service
139
+ # @option opts [String] :user The username for the cred
140
+ # @option opts [String] :pass The private part of the credential (e.g. password)
128
141
def report_auth_info ( opts = { } )
142
+ print_error "*** #{ self . fullname } is still calling the deprecated report_auth_info method! This needs to be updated!"
129
143
return if not db
130
- opts = {
131
- :workspace => myworkspace ,
132
- :task => mytask
133
- } . merge ( opts )
134
- framework . db . report_auth_info ( opts )
144
+ raise ArgumentError . new ( "Missing required option :host" ) if opts [ :host ] . nil?
145
+ raise ArgumentError . new ( "Missing required option :port" ) if ( opts [ :port ] . nil? and opts [ :service ] . nil? )
146
+
147
+ if opts [ :host ] . kind_of? ( ::Mdm ::Host )
148
+ host = opts [ :host ] . address
149
+ else
150
+ host = opts [ :host ]
151
+ end
152
+
153
+ type = :password
154
+ case opts [ :type ]
155
+ when "password"
156
+ type = :password
157
+ when "hash"
158
+ type = :nonreplayable_hash
159
+ when "ssh_key"
160
+ type = :ssh_key
161
+ end
162
+
163
+ case opts [ :proto ]
164
+ when "tcp"
165
+ proto = "tcp"
166
+ when "udp"
167
+ proto = "udp"
168
+ else
169
+ proto = "tcp"
170
+ end
171
+
172
+ if opts [ :service ] && opts [ :service ] . kind_of? ( Mdm ::Service )
173
+ port = opts [ :service ] . port
174
+ proto = opts [ :service ] . proto
175
+ service_name = opts [ :service ] . name
176
+ host = opts [ :service ] . host . address
177
+ else
178
+ port = opts . fetch ( :port )
179
+ service_name = opts . fetch ( :sname , nil )
180
+ end
181
+
182
+ username = opts . fetch ( :user , nil )
183
+ private = opts . fetch ( :pass , nil )
184
+
185
+ service_data = {
186
+ address : host ,
187
+ port : port ,
188
+ service_name : service_name ,
189
+ protocol : proto ,
190
+ workspace_id : myworkspace_id
191
+ }
192
+
193
+ if self . type == "post"
194
+ credential_data = {
195
+ origin_type : :session ,
196
+ session_id : session_db_id ,
197
+ post_reference_name : self . refname
198
+ }
199
+ else
200
+ credential_data = {
201
+ origin_type : :service ,
202
+ module_fullname : self . fullname
203
+ }
204
+ credential_data . merge! ( service_data )
205
+ end
206
+
207
+ unless private . nil?
208
+ credential_data [ :private_type ] = type
209
+ credential_data [ :private_data ] = private
210
+ end
211
+
212
+ unless username . nil?
213
+ credential_data [ :username ] = username
214
+ end
215
+
216
+ credential_core = create_credential ( credential_data )
217
+
218
+ login_data = {
219
+ core : credential_core ,
220
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
221
+ }
222
+ login_data . merge! ( service_data )
223
+ create_credential_login ( login_data )
135
224
end
136
225
137
226
def report_vuln ( opts = { } )
0 commit comments