< Summary

Class:SharpHoundCommonLib.Processors.DCRegistryProcessor
Assembly:SharpHoundCommonLib
File(s):D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\Processors\DCRegistryProcessor.cs
Covered lines:0
Uncovered lines:5
Coverable lines:5
Total lines:87
Line coverage:0% (0 of 5)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)0%200%

File(s)

D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\Processors\DCRegistryProcessor.cs

#LineLine coverage
 1using SharpHoundCommonLib.OutputTypes;
 2using System;
 3using System.Diagnostics.CodeAnalysis;
 4using System.Threading.Tasks;
 5using Microsoft.Extensions.Logging;
 6
 7namespace SharpHoundCommonLib.Processors
 8{
 9    public class DCRegistryProcessor
 10    {
 11        private readonly ILogger _log;
 12        public readonly ILdapUtils _utils;
 13        public delegate Task ComputerStatusDelegate(CSVComputerStatus status);
 14
 015        public DCRegistryProcessor(ILdapUtils utils, ILogger log = null)
 016        {
 017            _utils = utils;
 018            _log = log ?? Logging.LogProvider.CreateLogger("DCRegProc");
 019        }
 20
 21        /// <summary>
 22        /// This function gets the CertificateMappingMethods registry value stored on DCs.
 23        /// </summary>
 24        /// <remarks>https://support.microsoft.com/en-us/topic/kb5014754-certificate-based-authentication-changes-on-win
 25        /// <param name="target"></param>
 26        /// <returns>IntRegistryAPIResult</returns>
 27        /// <exception cref="Exception"></exception>
 28        [ExcludeFromCodeCoverage]
 29        public IntRegistryAPIResult GetCertificateMappingMethods(string target)
 30        {
 31            var ret = new IntRegistryAPIResult();
 32            const string subKey = @"SYSTEM\CurrentControlSet\Control\SecurityProviders\Schannel";
 33            const string subValue = "CertificateMappingMethods";
 34            var data = Helpers.GetRegistryKeyData(target, subKey, subValue, _log);
 35
 36            ret.Collected = data.Collected;
 37            if (!data.Collected)
 38            {
 39                ret.FailureReason = data.FailureReason;
 40                return ret;
 41            }
 42
 43            if (data.Value == null)
 44            {
 45                ret.Value = -1;
 46                return ret;
 47            }
 48
 49            ret.Value = (int)data.Value;
 50
 51            return ret;
 52        }
 53
 54        /// <summary>
 55        /// This function gets the StrongCertificateBindingEnforcement registry value stored on DCs.
 56        /// </summary>
 57        /// <remarks>https://support.microsoft.com/en-us/topic/kb5014754-certificate-based-authentication-changes-on-win
 58        /// <param name="target"></param>
 59        /// <returns>IntRegistryAPIResult</returns>
 60        /// <exception cref="Exception"></exception>
 61        [ExcludeFromCodeCoverage]
 62        public IntRegistryAPIResult GetStrongCertificateBindingEnforcement(string target)
 63        {
 64            var ret = new IntRegistryAPIResult();
 65            const string subKey = @"SYSTEM\CurrentControlSet\Services\Kdc";
 66            const string subValue = "StrongCertificateBindingEnforcement";
 67            var data = Helpers.GetRegistryKeyData(target, subKey, subValue, _log);
 68
 69            ret.Collected = data.Collected;
 70            if (!data.Collected)
 71            {
 72                ret.FailureReason = data.FailureReason;
 73                return ret;
 74            }
 75
 76            if (data.Value == null)
 77            {
 78                ret.Value = -1;
 79                return ret;
 80            }
 81
 82            ret.Value = (int)data.Value;
 83
 84            return ret;
 85        }
 86    }
 87}