diff --git a/README.md b/README.md index d0dc42e..abfc2f1 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ Massive credit to the below resources that really did 90% of this for me. This t * https://github.com/AlsidOfficial/WSUSpendu - powershell tool for abusing WSUS * https://github.com/ThunderGunExpress/Thunder_Woosus - Csharp tool for abusing WSUS +## Building +This project requires .NET Framework v4.0. You can download that here: https://dotnet.microsoft.com/en-us/download/dotnet-framework/net40. It may work with newer versions of .NET, however, it's not been tested. + ## Help Menu ``` diff --git a/SharpWSUS/lib/Server.cs b/SharpWSUS/lib/Server.cs index 98dd6d3..5a1a8b7 100644 --- a/SharpWSUS/lib/Server.cs +++ b/SharpWSUS/lib/Server.cs @@ -1,5 +1,6 @@ using System; using System.Net; +using System.Data.SqlClient; public class Server { @@ -12,7 +13,7 @@ public class Server public static int iPortNumber; public static bool bSSL; public static string sTargetComputerID; - public static int sTargetComputerTargetID; + public static int sTargetComputerTargetID; public static void GetServerDetails() { @@ -24,22 +25,27 @@ public static void GetServerDetails() } public static void FvContentDirectory() { - string sContentDirectoryTemp = string.Empty; - sContentDirectoryTemp = Reg.RegistryWOW6432.GetRegKey64(Reg.RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Update Services\Server\setup", "ContentDir"); - if (sContentDirectoryTemp == "ERROR_FILE_NOT_FOUND") + SqlCommand sqlComm = new SqlCommand(); + sqlComm.Connection = Connect.FsqlConnection(); + SqlDataReader sqldrReader; + sqlComm.CommandText = "exec spConfiguration"; + try { - sContentDirectoryTemp = Reg.RegistryWOW6432.GetRegKey32(Reg.RegHive.HKEY_LOCAL_MACHINE, @"SOFTWARE\Microsoft\Update Services\Server\setup", "ContentDir"); - if (sContentDirectoryTemp == "ERROR_FILE_NOT_FOUND") + //Gather Information via SQL + sqldrReader = sqlComm.ExecuteReader(); + if (sqldrReader.Read()) { - bWSUSInstalled = false; - Console.WriteLine("Something went wrong, unable to detect SQL details from registry."); - return; + Server.sLocalContentCacheLocation = (string)sqldrReader.GetValue(sqldrReader.GetOrdinal("LocalContentCacheLocation")); + Console.WriteLine(Server.sLocalContentCacheLocation); + sqldrReader.Close(); } } - sContentDirectoryTemp = HEX2ASCII(sContentDirectoryTemp); - sContentDirectoryTemp = ReverseString(sContentDirectoryTemp); - sLocalContentCacheLocation = Environment.ExpandEnvironmentVariables(sContentDirectoryTemp); - return; + catch (Exception e) + { + Console.WriteLine("\r\nFunction error - FvContentDirectory."); + + Console.WriteLine($"Error Message: {e.Message}"); + } } public static void FvFullComputerName() {