Shane Corellian
posted this on October 19, 2010 23:28
Sometimes our Windows Shares can run amok in our environments. Run this query to get and idea of which machines in your environment have Shared directories where Non Administrator accounts have Full Access. As you can see from the SQL, this example removes the default Windows Shares (C$, IPC$ and ADMIN$). Obviously the C$ is relative to the actual mounted drive. If %SYSTEMROOT% is D:\ then the default share will be called D$. Copy and paste the following SQL into your New Report in Admin Arsenal. (Go to the menu: Reports , New Report...)
--BEGIN SQL
--List of Non Administrator accounts with Full permissions on Windows Shares
SELECT Computer.Name, Share.Name, Share.Description, Share.Path, SharePermission.Domain, SharePermission.UserName, isFull
FROM Computer
INNER JOIN Share on Computer.ComputerID = Share.ComputerID
INNER JOIN SharePermission on Share.Name = SharePermission.Name
WHERE Share.Name NOT IN ('C$','IPC$','ADMIN$','NETLOGON','SYSVOL')
AND NOT SharePermission.UserName LIKE ('Administrators')
AND NOT SharePermission.UserName in (SELECT UserName FROM LocalGroupMember where GroupName = 'Administrators')