feat: add --shares-depth flag for subdirectory write permission checking#1188
feat: add --shares-depth flag for subdirectory write permission checking#1188sup3rDav3 wants to merge 2 commits intoPennyw0rth:mainfrom
Conversation
- Adds --shares-depth argument to SMB protocol (default: 0, root only) - When depth > 0, recursively checks subdirectories for write access - Only runs subdir check when root write check fails (no performance impact by default) - Reports writable subdirectories inline e.g. READ,WRITE (ad.local\scripts) - Respects --no-write-check flag - Compatible with --shares write filter - Fixes: write permissions were only checked on top-level share directories - Tested against Windows Server 2022 - detected writable SYSVOL\scripts subdir Closes Pennyw0rth#1186
Either you have not reviewed the code (and changes) or I am really curious why you have introduced +1300 lines of formatting changes. |
I'm not quite sure what happened TBH. Got PRs semi-mixed up, IDE got squirrelley (tabs vs. spaces formatting issues). The fix was really only 20-25 new lines. Feel free to delete this mess and so I can refine my process. Thanks. |
Okay, then I will close this for now. If #1138 is validated that it properly works and integrated, we should probably go for a similar solution, because this one here would result in hundreds or thousands of folders to be written. |
Fair enough, sorry for the confusion and thanks for your time. Back to #1176 👍 |
Description
Fixes #1186: Write permissions were only checked on top-level share directories, not subdirectories. A writable subdirectory (e.g. SYSVOL\scripts) would not be detected even if the user had write access to it.
Adds a new
--shares-depthargument that recursively checks subdirectories for write access up to the specified depth. Default is 0 (root only) so existing behavior is completely unchanged.This PR was developed with the assistance of Claude (Anthropic) via claude.ai. Claude assisted with the implementation approach, and ruff linting fixes. All code was reviewed and tested by the author against a live Windows Server 2022 domain controller.
Type of change
Setup guide for the review
Environment:
Target:
Reproduce the bug (before fix):
nxc smb TARGET -u lowpriv -p PASS --shares
Result: SYSVOL shows READ only — writable scripts folder not detected
Test the fix:
nxc smb TARGET -u lowpriv -p PASS --shares --shares-depth 2
Result: SYSVOL shows READ,WRITE (ad.local\scripts)
Other usage:
nxc smb TARGET -u USER -p PASS --shares --shares-depth 1
nxc smb TARGET -u USER -p PASS --shares write --shares-depth 2
nxc smb TARGET -u USER -p PASS --shares --no-write-check --shares-depth 2
Screenshots (if appropriate):
Checklist:
tests/e2e_commands.txtfile if necessary