Skip to content

Commit ca08804

Browse files
committed
Make sure module is awre of USE_SRVSVC_ONLY if that kicks in
1 parent a6ce629 commit ca08804

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

modules/auxiliary/scanner/smb/smb_enumshares.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def initialize(info={})
4646

4747
register_options(
4848
[
49-
OptBool.new('SHOW_SHARE', [true, 'Show all the folders and files', false ]),
49+
OptBool.new('DIR_SHARE', [true, 'Show all the folders and files', false ]),
5050
OptBool.new('USE_SRVSVC_ONLY', [true, 'List shares only with SRVSVC', false ])
5151
], self.class)
5252

@@ -181,6 +181,8 @@ def lanman_netshareenum(ip, rport, info)
181181
))
182182
rescue ::Rex::Proto::SMB::Exceptions::ErrorCode => e
183183
if e.error_code == 0xC00000BB
184+
vprint_error("Got 0xC00000BB while enumerating shares, switching to srvsvc...")
185+
datastore['USE_SRVSVC_ONLY'] = true # Make sure the module is aware of this state
184186
return srvsvc_netshareenum(ip)
185187
end
186188
end
@@ -327,14 +329,16 @@ def get_files_info(ip, rport, shares, info)
327329
end
328330

329331
def cleanup
330-
datastore['RPORT'] = @rport
331-
datastore['SMBDirect'] = @smb_redirect
332+
datastore['RPORT'] = @rport
333+
datastore['SMBDirect'] = @smb_redirect
334+
datastore['USE_SRVSVC_ONLY'] = @srvsvc
332335
end
333336

334337

335338
def run_host(ip)
336339
@rport = datastore['RPORT']
337340
@smb_redirect = datastore['SMBDirect']
341+
@srvsvc = datastore['USE_SRVSVC_ONLY']
338342
shares = []
339343

340344
[[139, false], [445, true]].each do |info|
@@ -366,7 +370,7 @@ def run_host(ip)
366370
:update => :unique_data
367371
)
368372

369-
if datastore['SHOW_SHARE'] and not datastore['USE_SRVSVC_ONLY']
373+
if datastore['DIR_SHARE'] and not datastore['USE_SRVSVC_ONLY']
370374
get_files_info(ip, rport, shares, info)
371375
end
372376

0 commit comments

Comments
 (0)