@@ -23,8 +23,14 @@ def initialize
23
23
'Author' => 'hdm' ,
24
24
'License' => MSF_LICENSE ,
25
25
)
26
+ end
27
+
28
+ def connect ( *args , **kwargs )
29
+ super ( *args , **kwargs , direct : @smb_direct )
30
+ end
26
31
27
- deregister_options ( 'RPORT' , 'SMBDirect' )
32
+ def rport
33
+ @rport
28
34
end
29
35
30
36
# Fingerprint a single host
@@ -40,10 +46,20 @@ def run_host(ip)
40
46
self . simple . connect ( "\\ \\ #{ session . address } \\ IPC$" )
41
47
pipes += check_pipes
42
48
else
43
- [ [ 139 , false ] , [ 445 , true ] ] . each do |info |
49
+ if datastore [ 'RPORT' ] . blank? || datastore [ 'RPORT' ] == 0
50
+ smb_services = [
51
+ { port : 445 , direct : true } ,
52
+ { port : 139 , direct : false }
53
+ ]
54
+ else
55
+ smb_services = [
56
+ { port : datastore [ 'RPORT' ] , direct : datastore [ 'SMBDirect' ] }
57
+ ]
58
+ end
44
59
45
- datastore [ 'RPORT' ] = info [ 0 ]
46
- datastore [ 'SMBDirect' ] = info [ 1 ]
60
+ smb_services . each do |smb_service |
61
+ @rport = smb_service [ :port ]
62
+ @smb_direct = smb_service [ :direct ]
47
63
48
64
begin
49
65
connect
@@ -52,12 +68,12 @@ def run_host(ip)
52
68
disconnect
53
69
break
54
70
rescue Rex ::Proto ::SMB ::Exceptions ::SimpleClientError , Rex ::ConnectionError => e
55
- vprint_error ( "SMB client Error with RPORT=#{ info [ 0 ] } SMBDirect=#{ info [ 1 ] } : #{ e . to_s } " )
71
+ vprint_error ( "SMB client Error with RPORT=#{ @rport } SMBDirect=#{ @smb_direct } : #{ e . to_s } " )
56
72
end
73
+
57
74
end
58
75
end
59
76
60
-
61
77
if ( pipes . length > 0 )
62
78
print_good ( "Pipes: #{ pipes . join ( ", " ) } " )
63
79
# Add Report
0 commit comments