在没有远程 Powershell 或 WMI 的情况下获取远程 SMB/CIFS 共享的权限

Getting permissions of a remote SMB/CIFS share without remote powershell or WMI

我正在寻找一种从连接到共享的 Windows 计算机导出 SMB/CIFS 共享的 ACL(不要与 NTFS ACL 混淆)的方法。到目前为止,我可以在共享的高级安全属性中看到权限,但没有办法导出或解析它们,除非是 AutoIT 怪物。

我想以我可以解析的格式获取此信息,无论是 CSV、JSON、XML 等

我已经检查了这个建议使用 Powershell 的 Get-SmbShareAccess: and this TechNet question which uses Get-WmiObject: Get-wmiobject Win32_Share does not show Sharing Permissions 的问题,但两者都假设我们可以在托管服务器上执行 Powershell 代码共享:我不是这种情况,因为共享未托管在 windows 上,而且我没有 shell 访问计算机的权限。

我愿意接受任何语言,但如果可以选择,我更喜欢 Powershell。

Windows explorer 通过 win32 API 方法使用 RPC NetShareGetInfo(),但直接从 Powershell 调用它并不容易。

FileShareUtils 是一个很棒的画廊模块,可以为您完成所有这些,也是我能找到的最佳选择:

$share = Get-NetShare -Name 'MyShare' -Server 'MyFileServer01'
Server              : MyServer01
Name                : MyShare
Path                : E:\Folder\Path
Description         : 
ABE                 : Enabled
CachingMode         : Manual
ShareACLText        : BUILTIN\Administrators|FullControl,Everyone|FullControl
CurrentUses         : 4
ConcurrentUserLimit : -1
BranchCache         : Disabled
Flags               : 2051
Type                : Disk Drive
ShareSDDL           : D:(A;;FA;;;WD)(A;;FA;;;BA)
ShareACL            : System.Security.AccessControl.DirectorySecurity
$share.ShareACL.Access


FileSystemRights  : FullControl
AccessControlType : Allow
IdentityReference : Everyone
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

FileSystemRights  : FullControl
AccessControlType : Allow
IdentityReference : BUILTIN\Administrators
IsInherited       : False
InheritanceFlags  : None
PropagationFlags  : None

我无法测试整个 Get-NetShare 是否可以作为非管理员用户使用,但如果您可以在文件资源管理器中看到“共享”权限,那么这应该适合您。如果您仍然收到访问被拒绝的消息,那么您可以按照自己的方式完成 module code 并查看 where/why。