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

Commit 2a18c36

Browse files
author
byt3bl33d3r
committed
added regex support when spidering
1 parent 21713ca commit 2a18c36

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crackmapexec.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,7 @@ def spider(smb_conn, ip, share, subfolder, patt, depth):
26172617
def dir_list(files, ip, path, pattern, share, smb):
26182618
for result in files:
26192619
for instance in pattern:
2620-
if instance in result.get_longname():
2620+
if re.findall(instance, result.get_longname()):
26212621
if result.is_directory():
26222622
print_att("//{}/{}/{} [dir]".format(ip, path.replace("//",""), result.get_longname().encode('utf8')))
26232623
else:
@@ -2644,8 +2644,8 @@ def search_content(smb, path, result, share, pattern, ip):
26442644
if contents == '':
26452645
return
26462646

2647-
if re.findall(pattern, contents, re.IGNORECASE):
2648-
print_att("//{}/{}/{} offset:{} pattern:{}".format(ip, path.replace("//",""), result.get_longname().encode('utf8'), rfile.tell(), pattern))
2647+
if re.findall(pattern, contents):
2648+
print_att("//{}/{}/{} offset:{} pattern:{}".format(ip, path.replace("//",""), result.get_longname().encode('utf8'), rfile.tell(), pattern.pattern))
26492649
rfile.close()
26502650
return
26512651
except Exception:
@@ -3134,9 +3134,9 @@ def concurrency(hosts):
31343134

31353135
for line in args.patternfile.readlines():
31363136
line = line.rstrip()
3137-
patterns.append(line)
3137+
patterns.append(re.compile(line, re.IGNORECASE))
31383138

3139-
patterns.extend(args.pattern.split(','))
3139+
patterns.extend(re.compile(patt, re.IGNORECASE) for patt in args.pattern.split(','))
31403140

31413141
args.pattern = patterns
31423142
args.exclude_dirs = args.exclude_dirs.split(',')

0 commit comments

Comments
 (0)