Skip to content

Commit f76773c

Browse files
SMB signing updates (#190)
* SMB signing code, collect additional registry entry * check smb2 signing enabled, fix console print, add doc * fix logging * add check if scanning local machine * collect signing enabled key * ClientAllowedNTLMServers, rename UseMachineId, comments * fix instantiation order --------- Co-authored-by: Rohan Vazarkar <rvazarkar@users.noreply.github.com>
1 parent b19ec2c commit f76773c

26 files changed

Lines changed: 2366 additions & 368 deletions

src/CommonLib/OutputTypes/Computer.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ public override string ToString() {
6060

6161
public class SmbInfo {
6262
public bool? SigningEnabled;
63-
public string OsVersion;
64-
public string OsBuild;
65-
public string DnsComputerName { get; internal set; }
6663
}
6764

6865
public class DCRegistryData {

src/CommonLib/OutputTypes/RegistryData.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public class RegistryData {
99
public uint? NtlmMinServerSec { get; set; } = null;
1010
public uint? NtlmMinClientSec { get; set; } = null;
1111
public uint? LmCompatibilityLevel { get; set; } = null;
12-
public uint? UseMachine { get; set; } = null;
12+
public uint? UseMachineId { get; set; } = null;
13+
public uint? RequireSecuritySignature { get; set; } = null;
14+
public uint? EnableSecuritySignature { get; set; } = null;
15+
public string[]? ClientAllowedNTLMServers { get; set; } = null;
1316
}
1417
#nullable disable

src/CommonLib/Processors/CAEnrollmentProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private async Task<APIResult<CAEnrollmentEndpoint>> GetNtlmEndpoint(Uri url, boo
165165
return APIResult<CAEnrollmentEndpoint>.Success(output);
166166
}
167167

168-
Console.WriteLine($"WebException occurred: {ex}");
168+
_logger.LogError($"WebException occurred: {ex}");
169169

170170
return APIResult<CAEnrollmentEndpoint>
171171
.Failure(

src/CommonLib/Processors/RegistryProcessor.cs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,25 @@ public RegistryProcessor(ILogger log, string domain) {
2626
];
2727

2828
_queries = [
29-
RegistryQuery.ForKey(RegistryHive.LocalMachine, @"System\CurrentControlSet\Control\Lsa\MSV1_0")
29+
RegistryQuery.ForKey(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0")
3030
.WithValues([
31-
"NtlmMinClientSec",
32-
"NtlmMinServerSec",
33-
"RestrictReceivingNTLMTraffic",
34-
"RestrictSendingNTLMTraffic",
31+
"ClientAllowedNTLMServers", // Network security: Restrict NTLM: Add remote server exceptions for NTLM authentication
32+
"NtlmMinClientSec", // Network security: Minimum session security for NTLM SSP based (including secure RPC) clients
33+
"NtlmMinServerSec", // Network security: Minimum session security for NTLM SSP based (including secure RPC) servers
34+
"RestrictReceivingNTLMTraffic", // Network security: Restrict NTLM: Incoming NTLM traffic
35+
"RestrictSendingNTLMTraffic", // Network security: Restrict NTLM: Outgoing NTLM traffic to remote servers
3536
]),
3637

37-
RegistryQuery.ForKey(RegistryHive.LocalMachine, @"System\CurrentControlSet\Control\Lsa\")
38+
RegistryQuery.ForKey(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Control\Lsa\")
3839
.WithValues([
39-
"LMCompatibilityLevel",
40-
"UseMachineId"
40+
"LMCompatibilityLevel", // Network security: LAN Manager authentication level
41+
"UseMachineId" // Network security: Allow Local System to use computer identity for NTLM
42+
]),
43+
44+
RegistryQuery.ForKey(RegistryHive.LocalMachine, @"SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters")
45+
.WithValues([
46+
"EnableSecuritySignature", // Microsoft network client: Digitally sign communications (if server agrees)
47+
"RequireSecuritySignature", // Microsoft network client: Digitally sign communications (always)
4148
])
4249
];
4350
}
@@ -57,6 +64,9 @@ public async Task<APIResult<RegistryData>> ReadRegistrySettings(string targetMac
5764

5865
var name = key.ValueName;
5966
switch (name) {
67+
case "ClientAllowedNTLMServers":
68+
output.ClientAllowedNTLMServers = (string[])key.Value;
69+
break;
6070
case "NtlmMinClientSec":
6171
output.NtlmMinClientSec = Convert.ToUInt32(key.Value);
6272
break;
@@ -73,7 +83,13 @@ public async Task<APIResult<RegistryData>> ReadRegistrySettings(string targetMac
7383
output.LmCompatibilityLevel = Convert.ToUInt32(key.Value);
7484
break;
7585
case "UseMachineId":
76-
output.UseMachine = Convert.ToUInt32(key.Value);
86+
output.UseMachineId = Convert.ToUInt32(key.Value);
87+
break;
88+
case "RequireSecuritySignature":
89+
output.RequireSecuritySignature = Convert.ToUInt32(key.Value);
90+
break;
91+
case "EnableSecuritySignature":
92+
output.EnableSecuritySignature = Convert.ToUInt32(key.Value);
7793
break;
7894
}
7995
}

0 commit comments

Comments
 (0)