Skip to content

Commit e235aad

Browse files
committed
Sometimes we might not be able to access a dir, be aware of that
1 parent 862dd18 commit e235aad

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modules/post/windows/gather/enum_dirperms.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def check_dir(dir, token)
6868
# If path doesn't exist, do not continue
6969
begin
7070
session.fs.dir.entries(dir)
71-
rescue
72-
print_error("Path seems invalid: #{dir}")
71+
rescue => e
72+
vprint_error("#{e.message}: #{dir}")
7373
return nil
7474
end
7575

@@ -103,7 +103,12 @@ def enum_subdirs(perm_filter, dpath, maxdepth, token)
103103
filter = datastore['FILTER']
104104
filter = nil if datastore['FILTER'] == 'NA'
105105

106-
dirs = session.fs.dir.foreach(dpath)
106+
begin
107+
dirs = session.fs.dir.foreach(dpath)
108+
rescue Rex::Post::Meterpreter::RequestError
109+
# Sometimes we cannot see the dir
110+
dirs = []
111+
end
107112

108113
if maxdepth >= 1 or maxdepth < 0
109114
dirs.each do|d|

0 commit comments

Comments
 (0)