Skip to content

Commit 3854d08

Browse files
Fixed smb_enumshares to support dir list in SRVSVC
1 parent 6885ef8 commit 3854d08

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

modules/auxiliary/scanner/smb/smb_enumshares.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def initialize(info={})
2828
directories, files, time stamps, etc.
2929
3030
By default, a netshareenum request is done in order to retrieve share information,
31-
but if this fails, you may also fall back to SRVSVC. When SRVSVC is used, please
32-
note the module will not attempt to enumerate more info like netshareenum.
31+
but if this fails, you may also fall back to SRVSVC.
3332
},
3433
'Author' =>
3534
[
@@ -47,7 +46,7 @@ def initialize(info={})
4746
register_options(
4847
[
4948
OptBool.new('DIR_SHARE', [true, 'Show all the folders and files', false ]),
50-
OptBool.new('USE_SRVSVC_ONLY', [true, 'List shares only with SRVSVC', false ])
49+
OptBool.new('USE_SRVSVC_ONLY', [true, 'List shares with SRVSVC', false ])
5150
], self.class)
5251

5352
deregister_options('RPORT', 'RHOST')
@@ -79,13 +78,18 @@ def to_unix_time(thi, tlo)
7978

8079
def eval_host(ip, share)
8180
read = write = false
81+
82+
# srvsvc adds a null byte that needs to be removed
83+
if datastore['USE_SRVSVC_ONLY']
84+
share = share[0..-2]
85+
end
86+
8287
return false,false,nil,nil if share == 'IPC$'
8388

8489
self.simple.connect("\\\\#{ip}\\#{share}")
8590

8691
begin
8792
device_type = self.simple.client.queryfs_fs_device['device_type']
88-
8993
unless device_type
9094
vprint_error("\\\\#{ip}\\#{share}: Error querying filesystem device type")
9195
return false,false,nil,nil
@@ -373,7 +377,7 @@ def run_host(ip)
373377
:update => :unique_data
374378
)
375379

376-
if datastore['DIR_SHARE'] and not datastore['USE_SRVSVC_ONLY']
380+
if datastore['DIR_SHARE']
377381
get_files_info(ip, rport, shares, info)
378382
end
379383

0 commit comments

Comments
 (0)