Skip to content

Commit 555e6c9

Browse files
committed
Modified a few things based on suggestions.
1 parent 58502f1 commit 555e6c9

File tree

1 file changed

+21
-28
lines changed

1 file changed

+21
-28
lines changed

modules/auxiliary/scanner/smb/smb_enumshares.rb

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -281,45 +281,41 @@ def srvsvc_netshareenum(ip)
281281
shares
282282
end
283283

284-
def profile_options(ip, share)
284+
def get_user_dirs(ip, share, base, sub_dirs)
285+
dirs = []
285286
usernames = []
286-
old_dirs = ['My Documents','Desktop']
287-
new_dirs = ['Desktop','Documents','Downloads','Music','Pictures','Videos']
288-
subdirs = []
287+
289288
begin
290-
read,write,type,files = eval_host(ip, share, "Documents and Settings")
289+
read,write,type,files = eval_host(ip, share, base)
291290
files.each do |f|
292291
if f[0] != "." and f[0] != ".."
293292
usernames.push(f[0])
294293
end
295294
end
296-
297-
# Return usernames along with their profile directories.
298295
usernames.each do |username|
299-
old_dirs.each do |dir|
300-
subdirs.push("Documents and Settings\\#{username}\\#{dir}")
296+
sub_dirs.each do |sub_dir|
297+
dirs.push("#{base}\\#{username}\\#{sub_dir}")
301298
end
302299
end
300+
return dirs
303301
rescue
304-
read,write,type,files = eval_host(ip, share, "Users")
305-
files.each do |f|
306-
if f[0] != "." and f[0] != ".."
307-
usernames.push(f[0])
308-
end
309-
end
302+
dirs = nil
303+
return dirs
304+
end
305+
end
310306

311-
# Return usernames along with their profile directories.
312-
usernames.each do |username|
313-
new_dirs.each do |dir|
314-
subdirs.push("Users\\#{username}\\#{dir}")
315-
end
316-
end
307+
def profile_options(ip, share)
308+
old_dirs = ['My Documents','Desktop']
309+
new_dirs = ['Desktop','Documents','Downloads','Music','Pictures','Videos']
310+
311+
dirs = get_user_dirs(ip, share, "Documents and Settings", old_dirs)
312+
if dirs == nil
313+
dirs = get_user_dirs(ip, share, "Users", new_dirs)
317314
end
318-
return subdirs
315+
return dirs
319316
end
320317

321318
def get_files_info(ip, rport, shares, info)
322-
323319
read = false
324320
write = false
325321

@@ -334,7 +330,8 @@ def get_files_info(ip, rport, shares, info)
334330

335331
list = shares.collect {|e| e[0]}
336332
list.each do |x|
337-
if x.strip == "ADMIN$"
333+
x = x.strip
334+
if x == "ADMIN$" or x == "IPC$"
338335
next
339336
end
340337
if not datastore['VERBOSE']
@@ -344,7 +341,6 @@ def get_files_info(ip, rport, shares, info)
344341
if x.strip() == "C$" and datastore['SpiderProfiles']
345342
subdirs = profile_options(ip, x)
346343
end
347-
348344
while subdirs.length > 0
349345
depth = subdirs[0].count("\\")
350346
if datastore['SpiderProfiles'] and x == "C$"
@@ -370,9 +366,6 @@ def get_files_info(ip, rport, shares, info)
370366
end
371367
header << "\\#{x.sub("C$","C$\\")}" if simple.client.default_name
372368
header << subdirs[0]
373-
header << " (#{type})" if type
374-
header << " - Readable" if read
375-
header << " - Writable" if write
376369

377370
pretty_tbl = Rex::Ui::Text::Table.new(
378371
'Header' => header,

0 commit comments

Comments
 (0)