Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Commit 21713ca

Browse files
author
byt3bl33d3r
committed
Added option to exclude directories from spidering
1 parent b2f0533 commit 21713ca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crackmapexec.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ def spider(smb_conn, ip, share, subfolder, patt, depth):
26102610
return
26112611

26122612
for result in filelist:
2613-
if result.is_directory() and result.get_longname() != '.' and result.get_longname() != '..':
2613+
if result.is_directory() and result.get_longname() != '.' and result.get_longname() != '..' and (subfolder.split('/')[-1] not in args.exclude_dirs):
26142614
spider(smb_conn, ip, share,subfolder+'/'+result.get_longname().encode('utf8'), patt, depth-1)
26152615
return
26162616

@@ -3045,6 +3045,7 @@ def concurrency(hosts):
30453045
sgroup = parser.add_argument_group("Spidering", "Options for spidering shares")
30463046
sgroup.add_argument("--spider", metavar='FOLDER', type=str, default='', help='Folder to spider (defaults to share root dir)')
30473047
sgroup.add_argument("--search-content", dest='search_content', action='store_true', help='Enable file content searching')
3048+
sgroup.add_argument("--exclude-dirs", metavar='DIR_LIST', dest='exclude_dirs', type=str, help='Directories to exclude from spidering')
30483049
sgroup.add_argument("--pattern", type=str, default= '', help='Pattern to search for in folders filenames and file content (if enabled)')
30493050
sgroup.add_argument("--patternfile", type=str, help='File containing patterns to search for in folders, filenames and file content (if enabled)')
30503051
sgroup.add_argument("--depth", type=int, default=10, help='Spider recursion depth (default: 10)')
@@ -3138,6 +3139,7 @@ def concurrency(hosts):
31383139
patterns.extend(args.pattern.split(','))
31393140

31403141
args.pattern = patterns
3142+
args.exclude_dirs = args.exclude_dirs.split(',')
31413143

31423144
if args.combo_file:
31433145
if not os.path.exists(args.combo_file):

0 commit comments

Comments
 (0)