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

Commit 1699fae

Browse files
author
byt3bl33d3r
committed
Fixed logic bug when enumerating share access
1 parent a12ec07 commit 1699fae

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

crackmapexec.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,22 +2621,22 @@ def dir_list(files,ip,path,pattern):
26212621
def _listShares(smb):
26222622
permissions = {}
26232623
root = ntpath.normpath("\\{}".format(PERM_DIR))
2624-
2624+
26252625
for share in smb.listShares():
26262626
share_name = share['shi1_netname'][:-1].encode('utf8')
2627-
permissions[share_name] = "NO ACCESS"
2627+
permissions[share_name] = []
26282628

26292629
try:
2630-
if smb.listPath(share_name, '', args.passwd):
2631-
permissions[share_name] = "READ"
2632-
except:
2630+
if smb.listPath(share_name, '\\*', args.passwd):
2631+
permissions[share_name].append('READ')
2632+
except SessionError:
26332633
pass
26342634

26352635
try:
26362636
if smb.createDirectory(share_name, root):
26372637
smb.deleteDirectory(share_name, root)
2638-
permissions[share_name] = "READ, WRITE"
2639-
except:
2638+
permissions[share_name].append('WRITE')
2639+
except SessionError:
26402640
pass
26412641

26422642
return permissions
@@ -2837,7 +2837,10 @@ def connect(host):
28372837
print_att('\tSHARE\t\t\tPermissions')
28382838
print_att('\t-----\t\t\t-----------')
28392839
for share, perm in share_list.iteritems():
2840-
print_att('\t{}\t\t\t{}'.format(share, perm))
2840+
if not perm:
2841+
print_att('\t{}\t\t\t{}'.format(share, 'NO ACCESS'))
2842+
else:
2843+
print_att('\t{}\t\t\t{}'.format(share, ', '.join(perm)))
28412844

28422845
if args.check_uac:
28432846
remoteOps = RemoteOperations(smb)

0 commit comments

Comments
 (0)