Skip to content

Commit

Permalink
SQLCheck bug fixes
Browse files Browse the repository at this point in the history
Fixed certificate matching.
Added Local Admin warning.
Fixed driver not found exceptions.
Fixed Domain Attributes failure.
Display Certificate signature type and key strength.
Display whether SQL certs are hard-coded in the registry or not.
  • Loading branch information
Malcolm-Stewart committed Sep 16, 2021
1 parent a01663b commit 0a138a8
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 47 deletions.
Binary file modified SQLCheck/.vs/SQLCheck/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified SQLCheck/.vs/SQLCheck/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified SQLCheck/.vs/SQLCheck/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
148 changes: 112 additions & 36 deletions SQLCheck/SQLCheck/Collectors.cs

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions SQLCheck/SQLCheck/DriverInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,32 @@ public static DriverInfo GetDriverInfo(string driverName, FileVersionInfo versio
case "SQLNCLI10":
case "SQL Server Native Client 10.0":
// SQLNCLI10 and SQL Server Native Client 10.0
if (versionInfo == null)
{
TLS12 = "Unknown";
break;
}
if (versionInfo.ProductMajorPart == 10 && versionInfo.ProductMinorPart == 0 && versionInfo.ProductBuildPart >= 6543) TLS12 = "Yes"; // 10.0
if (versionInfo.ProductMajorPart == 10 && versionInfo.ProductMinorPart == 50 && versionInfo.ProductBuildPart >= 6537) TLS12 = "Yes"; // 10.50
if (versionInfo.ProductMajorPart == 10 && versionInfo.ProductMinorPart == 51 && versionInfo.ProductBuildPart >= 6537) TLS12 = "Yes"; // 10.51
break;
case "SQLNCLI11":
case "SQL Server Native Client 11.0":
// SQLNCLI11 and SQL Server Native Client 11.0
if (versionInfo == null)
{
TLS12 = "Unknown";
break;
}
if (versionInfo.ProductMajorPart == 11 && versionInfo.ProductMinorPart == 0 && versionInfo.ProductBuildPart >= 6538) TLS12 = "Yes";
break;
case "ODBC Driver 11 for SQL Server":
// ODBC Driver 11 for SQL Server
if (versionInfo == null)
{
TLS12 = "Unknown";
break;
}
if (versionInfo.ProductMajorPart == 12 && versionInfo.ProductMinorPart == 0 && versionInfo.ProductBuildPart >= 4219) TLS12 = "Yes";
break;
}
Expand Down
11 changes: 9 additions & 2 deletions SQLCheck/SQLCheck/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,28 @@ namespace SQLCheck
//


static class Program
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>

public static readonly string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
public static readonly int schemaVersion = 1; // increment whenever the DataSet schema changes, not for every code fix
static bool TraceOn = false;

[STAThread]
static void Main()
static void Main(string[] args)
{
if (args.Length > 0 && args[0].ToUpper() == "T") TraceOn = true;
DataSet ds = Storage.CreateDataSet("Test");
Collectors.Collect(ds);
TextReport.Report(ds, Console.Out);
}

public static void Trace(string Message)
{
if (TraceOn) Console.WriteLine(Message);
}
}
}
4 changes: 2 additions & 2 deletions SQLCheck/SQLCheck/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1137.0")]
[assembly: AssemblyFileVersion("1.0.1137.0")]
[assembly: AssemblyVersion("1.0.1160.0")]
[assembly: AssemblyFileVersion("1.0.1160.0")]
2 changes: 2 additions & 0 deletions SQLCheck/SQLCheck/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public static DataSet CreateDataSet(String ComputerName)
dt.AddColumn("ID", "Integer");
dt.Columns["ID"].AutoIncrement = true;
dt.AddColumn("ParentID", "Integer");
dt.AddColumn("CurrentUser", "String");
dt.AddColumn("NETBIOSName", "String");
dt.AddColumn("FQDN", "String");
dt.AddColumn("DNSSuffix", "String");
Expand Down Expand Up @@ -323,6 +324,7 @@ public static DataSet CreateDataSet(String ComputerName)
dt.AddColumn("ServerCompatibility", "String");
dt.AddColumn("Supported", "String");
dt.AddColumn("MultiSubnetFailoverSupport", "String");
dt.AddColumn("Message", "String");
ds.Tables.Add(dt);

//
Expand Down
20 changes: 13 additions & 7 deletions SQLCheck/SQLCheck/TextReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ static void ReportComputer(DataSet ds, TextWriter s) // outputs computer and do
DataRow Domain = null;
bool is64bit = Computer.GetBoolean("CPU64Bit");

s.WriteLine($"Report run by: {Computer.GetString("CurrentUser")}");
s.WriteLine();
s.WriteLine($"NETBIOS Name: {Computer.GetString("NETBIOSName")}"); // use of extension methods in case a field does not exist
s.WriteLine($"FQDN: {Computer.GetString("FQDN")}");
s.WriteLine($"DNS Suffix: {Computer.GetString("DNSSuffix")}");
Expand Down Expand Up @@ -464,14 +466,16 @@ static void ReportCertificate(DataSet ds, TextWriter s) // outputs a list of th
s.WriteLine();

ReportFormatter rf = new ReportFormatter();
rf.SetColumnNames("Friendly Name:L", "CN:L", "SAN:L", "Thumbprint:L", "Server Cert:L", "Usage:L", "Private Key:L", "Not Before:L", "Not After:L", "Problem:L");
rf.SetColumnNames("Friendly Name:L", "CN:L", "SAN:L", "Thumbprint:L", "Server Cert:L", "Key Len:R", "Sig Type:L", "Usage:L", "Private Key:L", "Not Before:L", "Not After:L", "Problem:L");
foreach (DataRow Certificate in dtCertificate.Rows)
{
rf.SetcolumnData(Certificate.GetString("FriendlyName"),
Certificate.GetString("CommonName"),
Certificate.GetString("SubjectAlternativeName"),
Certificate.GetString("ThumbPrint"),
Certificate.GetBoolean("ServerCert") ? "Yes" : "",
Certificate.GetString("KeySize"),
Certificate.GetString("SignatureAlgorithm"),
Certificate.GetString("KeySpec"),
Certificate.GetBoolean("HasPrivateKey") ? "Yes" : "",
Certificate.GetString("NotBefore"),
Expand Down Expand Up @@ -626,10 +630,10 @@ static void ReportDatabaseDriver(DataSet ds, TextWriter s) // outputs computer
DataTable dtDatabaseDriver = ds.Tables["DatabaseDriver"];
ReportFormatter rf = new ReportFormatter();

rf.SetColumnNames("Name:L", "Type:L", "Version:L", "Supported:L", "TLS 1.2:L", "TLS 1.3:L", "MSF:L", "GUID:L", "Path:L");
rf.SetColumnNames("Name:L", "Type:L", "Version:L", "Supported:L", "TLS 1.2:L", "TLS 1.3:L", "MSF:L", "GUID:L", "Path:L", "Message:L");
foreach (DataRow DatabaseDriver in dtDatabaseDriver.Rows)
{
if (DatabaseDriver.GetString("Supported") != "") // only SQL drivres and providers have this set
if (DatabaseDriver.GetString("Supported") != "") // only SQL drivers and providers have this set
{
rf.SetcolumnData(DatabaseDriver.GetString("DriverName"),
DatabaseDriver.GetString("DriverType"),
Expand All @@ -639,7 +643,8 @@ static void ReportDatabaseDriver(DataSet ds, TextWriter s) // outputs computer
DatabaseDriver.GetString("TLS13"),
DatabaseDriver.GetString("MultiSubnetFailoverSupport"),
DatabaseDriver.GetString("Guid"),
DatabaseDriver.GetString("Path"));
DatabaseDriver.GetString("Path"),
DatabaseDriver.GetString("Message"));
}
}
s.WriteLine(rf.GetHeaderText());
Expand All @@ -653,16 +658,17 @@ static void ReportDatabaseDriver(DataSet ds, TextWriter s) // outputs computer

s.WriteLine("Other OLE DB Providers and ODBC Drivers:");
s.WriteLine();
rf.SetColumnNames("Name:L", "Type:L", "Version:L", "GUID:L", "Path:L");
rf.SetColumnNames("Name:L", "Type:L", "Version:L", "GUID:L", "Path:L", "Message:L");
foreach (DataRow DatabaseDriver in dtDatabaseDriver.Rows)
{
if (DatabaseDriver.GetString("Supported") == "") // only SQL drivres and providers have this set
if (DatabaseDriver.GetString("Supported") == "") // only SQL drivers and providers have this set
{
rf.SetcolumnData(DatabaseDriver.GetString("DriverName"),
DatabaseDriver.GetString("DriverType"),
DatabaseDriver.GetString("Version"),
DatabaseDriver.GetString("Guid"),
DatabaseDriver.GetString("Path"));
DatabaseDriver.GetString("Path"),
DatabaseDriver.GetString("Message"));
}
}
s.WriteLine(rf.GetHeaderText());
Expand Down
Binary file modified SQL_Network_Analyzer/.vs/SQLNetworkAnalyzer/v15/.suo
Binary file not shown.

0 comments on commit 0a138a8

Please sign in to comment.