< Summary

Class:SharpHoundCommonLib.WellKnownPrincipal
Assembly:SharpHoundCommonLib
File(s):D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\WellKnownPrincipal.cs
Covered lines:71
Uncovered lines:3
Coverable lines:74
Total lines:91
Line coverage:95.9% (71 of 74)
Covered branches:321
Total branches:330
Branch coverage:97.2% (321 of 330)

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetWellKnownPrincipal(...)97.27%330095.94%

File(s)

D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\WellKnownPrincipal.cs

#LineLine coverage
 1using SharpHoundCommonLib.Enums;
 2using SharpHoundCommonLib.OutputTypes;
 3
 4namespace SharpHoundCommonLib
 5{
 6    public static class WellKnownPrincipal
 7    {
 8        /// <summary>
 9        ///     Gets the principal associated with a well known SID
 10        /// </summary>
 11        /// <param name="sid"></param>
 12        /// <param name="commonPrincipal"></param>
 13        /// <returns>True if SID matches a well known principal, false otherwise</returns>
 14        public static bool GetWellKnownPrincipal(string sid, out TypedPrincipal commonPrincipal)
 16315        {
 16316            commonPrincipal = sid switch
 16317            {
 118                "S-1-0" => new TypedPrincipal("Null Authority", Label.User),
 219                "S-1-0-0" => new TypedPrincipal("Nobody", Label.User),
 120                "S-1-1" => new TypedPrincipal("World Authority", Label.User),
 121                "S-1-1-0" => new TypedPrincipal("Everyone", Label.Group),
 122                "S-1-2" => new TypedPrincipal("Local Authority", Label.User),
 123                "S-1-2-0" => new TypedPrincipal("Local", Label.Group),
 124                "S-1-2-1" => new TypedPrincipal("Console Logon", Label.Group),
 125                "S-1-3" => new TypedPrincipal("Creator Authority", Label.User),
 126                "S-1-3-0" => new TypedPrincipal("Creator Owner", Label.User),
 127                "S-1-3-1" => new TypedPrincipal("Creator Group", Label.Group),
 128                "S-1-3-2" => new TypedPrincipal("Creator Owner Server", Label.Computer),
 129                "S-1-3-3" => new TypedPrincipal("Creator Group Server", Label.Computer),
 130                "S-1-3-4" => new TypedPrincipal("Owner Rights", Label.Group),
 131                "S-1-4" => new TypedPrincipal("Non-unique Authority", Label.User),
 132                "S-1-5" => new TypedPrincipal("NT Authority", Label.User),
 133                "S-1-5-1" => new TypedPrincipal("Dialup", Label.Group),
 134                "S-1-5-2" => new TypedPrincipal("Network", Label.Group),
 135                "S-1-5-3" => new TypedPrincipal("Batch", Label.Group),
 136                "S-1-5-4" => new TypedPrincipal("Interactive", Label.Group),
 137                "S-1-5-6" => new TypedPrincipal("Service", Label.Group),
 138                "S-1-5-7" => new TypedPrincipal("Anonymous", Label.Group),
 139                "S-1-5-8" => new TypedPrincipal("Proxy", Label.Group),
 540                "S-1-5-9" => new TypedPrincipal("Enterprise Domain Controllers", Label.Group),
 141                "S-1-5-10" => new TypedPrincipal("Principal Self", Label.User),
 742                "S-1-5-11" => new TypedPrincipal("Authenticated Users", Label.Group),
 143                "S-1-5-12" => new TypedPrincipal("Restricted Code", Label.Group),
 144                "S-1-5-13" => new TypedPrincipal("Terminal Server Users", Label.Group),
 145                "S-1-5-14" => new TypedPrincipal("Remote Interactive Logon", Label.Group),
 146                "S-1-5-15" => new TypedPrincipal("This Organization", Label.Group),
 147                "S-1-5-17" => new TypedPrincipal("IUSR", Label.User),
 148                "S-1-5-18" => new TypedPrincipal("Local System", Label.User),
 149                "S-1-5-19" => new TypedPrincipal("Local Service", Label.User),
 150                "S-1-5-20" => new TypedPrincipal("Network Service", Label.User),
 151                "S-1-5-113" => new TypedPrincipal("Local Account", Label.User),
 152                "S-1-5-114" => new TypedPrincipal("Local Account and Member of Administrators Group", Label.User),
 153                "S-1-5-80-0" => new TypedPrincipal("All Services ", Label.Group),
 1654                "S-1-5-32-544" => new TypedPrincipal("Administrators", Label.Group),
 355                "S-1-5-32-545" => new TypedPrincipal("Users", Label.Group),
 156                "S-1-5-32-546" => new TypedPrincipal("Guests", Label.Group),
 157                "S-1-5-32-547" => new TypedPrincipal("Power Users", Label.Group),
 358                "S-1-5-32-548" => new TypedPrincipal("Account Operators", Label.Group),
 159                "S-1-5-32-549" => new TypedPrincipal("Server Operators", Label.Group),
 160                "S-1-5-32-550" => new TypedPrincipal("Print Operators", Label.Group),
 161                "S-1-5-32-551" => new TypedPrincipal("Backup Operators", Label.Group),
 162                "S-1-5-32-552" => new TypedPrincipal("Replicators", Label.Group),
 563                "S-1-5-32-554" => new TypedPrincipal("Pre-Windows 2000 Compatible Access", Label.Group),
 264                "S-1-5-32-555" => new TypedPrincipal("Remote Desktop Users", Label.Group),
 165                "S-1-5-32-556" => new TypedPrincipal("Network Configuration Operators", Label.Group),
 166                "S-1-5-32-557" => new TypedPrincipal("Incoming Forest Trust Builders", Label.Group),
 167                "S-1-5-32-558" => new TypedPrincipal("Performance Monitor Users", Label.Group),
 168                "S-1-5-32-559" => new TypedPrincipal("Performance Log Users", Label.Group),
 369                "S-1-5-32-560" => new TypedPrincipal("Windows Authorization Access Group", Label.Group),
 170                "S-1-5-32-561" => new TypedPrincipal("Terminal Server License Servers", Label.Group),
 171                "S-1-5-32-562" => new TypedPrincipal("Distributed COM Users", Label.Group),
 172                "S-1-5-32-568" => new TypedPrincipal("IIS_IUSRS", Label.Group),
 173                "S-1-5-32-569" => new TypedPrincipal("Cryptographic Operators", Label.Group),
 174                "S-1-5-32-573" => new TypedPrincipal("Event Log Readers", Label.Group),
 175                "S-1-5-32-574" => new TypedPrincipal("Certificate Service DCOM Access", Label.Group),
 176                "S-1-5-32-575" => new TypedPrincipal("RDS Remote Access Servers", Label.Group),
 177                "S-1-5-32-576" => new TypedPrincipal("RDS Endpoint Servers", Label.Group),
 178                "S-1-5-32-577" => new TypedPrincipal("RDS Management Servers", Label.Group),
 179                "S-1-5-32-578" => new TypedPrincipal("Hyper-V Administrators", Label.Group),
 180                "S-1-5-32-579" => new TypedPrincipal("Access Control Assistance Operators", Label.Group),
 181                "S-1-5-32-580" => new TypedPrincipal("Remote Management Users", Label.Group),
 082                "S-1-5-32-581" => new TypedPrincipal("System Managed Accounts Group", Label.Group),
 083                "S-1-5-32-582" => new TypedPrincipal("Storage Replica Administrators", Label.Group),
 084                "S-1-5-32-583" => new TypedPrincipal("Device Owners", Label.Group),
 6285                _ => null
 16386            };
 87
 16388            return commonPrincipal != null;
 16389        }
 90    }
 91}