@@ -127,11 +127,86 @@ def report_note(opts={})
127
127
128
128
def report_auth_info ( opts = { } )
129
129
return if not db
130
- opts = {
131
- :workspace => myworkspace ,
132
- :task => mytask
133
- } . merge ( opts )
134
- framework . db . report_auth_info ( opts )
130
+ raise ArgumentError . new ( "Missing required option :host" ) if opts [ :host ] . nil?
131
+ raise ArgumentError . new ( "Missing required option :port" ) if ( opts [ :port ] . nil? and opts [ :service ] . nil? )
132
+
133
+ if opts [ :host ] . kind_of? ( ::Mdm ::Host )
134
+ host = opts [ :host ] . address
135
+ else
136
+ host = opts [ :host ]
137
+ end
138
+
139
+ type = :password
140
+ case opts [ :type ]
141
+ when "password"
142
+ type = :password
143
+ when "hash"
144
+ type = :nonreplayable_hash
145
+ when "ssh_key"
146
+ type = :ssh_key
147
+ end
148
+
149
+ case opts [ :proto ]
150
+ when "tcp"
151
+ proto = "tcp"
152
+ when "udp"
153
+ proto = "udp"
154
+ else
155
+ proto = "tcp"
156
+ end
157
+
158
+ if opts [ :service ] && opts [ :service ] . kind_of? ( Mdm ::Service )
159
+ port = opts [ :service ] . port
160
+ proto = opts [ :service ] . proto
161
+ service_name = opts [ :service ] . name
162
+ host = opts [ :service ] . host . address
163
+ else
164
+ port = opts . fetch ( :port )
165
+ service_name = opts . fetch ( :sname , nil )
166
+ end
167
+
168
+ username = opts . fetch ( :user , nil )
169
+ private = opts . fetch ( :pass , nil )
170
+
171
+ service_data = {
172
+ address : host ,
173
+ port : port ,
174
+ service_name : service_name ,
175
+ protocol : proto ,
176
+ workspace_id : myworkspace_id
177
+ }
178
+
179
+ if self . type == "post"
180
+ credential_data = {
181
+ origin_type : :session ,
182
+ session_id : session_db_id ,
183
+ post_reference_name : self . refname
184
+ }
185
+ else
186
+ credential_data = {
187
+ origin_type : :service ,
188
+ module_fullname : self . fullname
189
+ }
190
+ credential_data . merge! ( service_data )
191
+ end
192
+
193
+ unless private . nil?
194
+ credential_data [ :private_type ] = type
195
+ credential_data [ :private_data ] = private
196
+ end
197
+
198
+ unless username . nil?
199
+ credential_data [ :username ] = username
200
+ end
201
+
202
+ credential_core = create_credential ( credential_data )
203
+
204
+ login_data = {
205
+ core : credential_core ,
206
+ status : Metasploit ::Model ::Login ::Status ::UNTRIED
207
+ }
208
+ login_data . merge! ( service_data )
209
+ create_credential_login ( login_data )
135
210
end
136
211
137
212
def report_vuln ( opts = { } )
0 commit comments