@@ -40,22 +40,26 @@ def initialize
40
40
'License' => MSF_LICENSE
41
41
)
42
42
43
+ register_options ( [
44
+ Msf ::Opt ::RPORT ( nil , false )
45
+ ] )
46
+
43
47
register_advanced_options (
44
48
[
45
49
*kerberos_storage_options ( protocol : 'SMB' ) ,
46
50
*kerberos_auth_options ( protocol : 'SMB' , auth_methods : Msf ::Exploit ::Remote ::AuthOption ::SMB_OPTIONS ) ,
47
51
]
48
52
)
49
53
50
- deregister_options ( 'RPORT' , 'SMBDIRECT' , ' SMB::ProtocolVersion')
54
+ deregister_options ( 'SMB::ProtocolVersion' )
51
55
end
52
56
53
57
def rport
54
- @smb_port
58
+ @rport
55
59
end
56
60
57
- def smb_direct
58
- ( @smb_port == 445 )
61
+ def connect ( * args , ** kwargs )
62
+ super ( * args , ** kwargs , direct : @smb_direct )
59
63
end
60
64
61
65
def seconds_to_timespan ( seconds )
@@ -189,10 +193,21 @@ def smb_os_description(res, nd_smb_fingerprint)
189
193
# Fingerprint a single host
190
194
#
191
195
def run_host ( ip )
192
- smb_ports = [ 445 , 139 ]
196
+ if datastore [ 'RPORT' ] . blank? || datastore [ 'RPORT' ] == 0
197
+ smb_services = [
198
+ { port : 445 , direct : true } ,
199
+ { port : 139 , direct : false }
200
+ ]
201
+ else
202
+ smb_services = [
203
+ { port : datastore [ 'RPORT' ] , direct : datastore [ 'SMBDirect' ] }
204
+ ]
205
+ end
206
+
193
207
lines = [ ] # defer status output to the very end to group lines together by host
194
- smb_ports . each do |pnum |
195
- @smb_port = pnum
208
+ smb_services . each do |smb_service |
209
+ @rport = smb_service [ :port ]
210
+ @smb_direct = smb_service [ :direct ]
196
211
self . simple = nil
197
212
198
213
begin
0 commit comments