Skip to content

Commit 7ab386f

Browse files
authored
Merge pull request Pennyw0rth#787 from Dfte/fix_shares_filter
Patches the --filter-shares so that it correctly finds READ,WRITE perm
2 parents 1d80c40 + 67d8e9e commit 7ab386f

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

nxc/protocols/smb.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,16 +1242,20 @@ def shares(self):
12421242
error = get_error_string(e)
12431243
self.logger.debug(f"Error adding share: {error}")
12441244

1245+
if self.args.filter_shares:
1246+
self.logger.display("[REMOVED] Use the --shares read,write options instead.")
1247+
12451248
self.logger.display("Enumerated shares")
12461249
self.logger.highlight(f"{'Share':<15} {'Permissions':<15} {'Remark'}")
12471250
self.logger.highlight(f"{'-----':<15} {'-----------':<15} {'------'}")
1251+
12481252
for share in permissions:
12491253
name = share["name"]
12501254
remark = share["remark"]
1251-
perms = share["access"]
1252-
if self.args.filter_shares and not any(x in perms for x in self.args.filter_shares):
1255+
perms = ",".join(share["access"])
1256+
if self.args.shares and self.args.shares.lower() not in perms.lower():
12531257
continue
1254-
self.logger.highlight(f"{name:<15} {','.join(perms):<15} {remark}")
1258+
self.logger.highlight(f"{name:<15} {perms:<15} {remark}")
12551259
return permissions
12561260

12571261
def dir(self):

nxc/protocols/smb/proto_args.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def proto_args(parser, parents):
3737
cred_gathering_group.add_argument("--user", dest="userntds", type=str, help="Dump selected user from DC")
3838

3939
mapping_enum_group = smb_parser.add_argument_group("Mapping/Enumeration", "Options for Mapping/Enumerating")
40-
mapping_enum_group.add_argument("--shares", action="store_true", help="Enumerate shares and access")
40+
mapping_enum_group.add_argument("--shares", type=str, nargs="?", const="", help="Enumerate shares and access, filter on specified argument (read ; write ; read,write)")
4141
mapping_enum_group.add_argument("--dir", nargs="?", type=str, const="", help="List the content of a path (default path: '%(const)s')")
4242
mapping_enum_group.add_argument("--interfaces", action="store_true", help="Enumerate network interfaces")
4343
mapping_enum_group.add_argument("--no-write-check", action="store_true", help="Skip write check on shares (avoid leaving traces when missing delete permissions)")
44-
mapping_enum_group.add_argument("--filter-shares", nargs="+", help="Filter share by access, option 'read' 'write' or 'read,write'")
44+
mapping_enum_group.add_argument("--filter-shares", nargs="+", help="Filter share by access, option 'READ' 'WRITE' or 'READ,WRITE'")
4545
mapping_enum_group.add_argument("--smb-sessions", action="store_true", help="Enumerate active smb sessions")
4646
mapping_enum_group.add_argument("--disks", action="store_true", help="Enumerate disks")
4747
mapping_enum_group.add_argument("--loggedon-users-filter", action="store", help="only search for specific user, works with regex")

0 commit comments

Comments
 (0)