C'è un modo per rilevare se è installato un software antivirus in una macchina che utilizza C#? So che il Centro sicurezza rileva il software antivirus, ma come lo si può rilevare in C#?Rileva antivirus su Windows utilizzando C#
risposta
Secondo Microsoft, il Centro sicurezza di Windows utilizza un approccio a due livelli per lo stato di rilevamento. Un livello è manuale e l'altro livello è automatico tramite Strumentazione gestione Windows (WMI). Nella modalità di rilevamento manuale, Centro sicurezza di Windows cerca le chiavi di registro ei file forniti a Microsoft da produttori di software indipendenti. Queste chiavi e file di registro consentono a Windows Security Center di rilevare lo stato del software indipendente. In modalità WMI, i produttori di software determinano lo stato del proprio prodotto e riportano tale stato a Windows Security Center tramite un provider WMI. In entrambe le modalità, Centro sicurezza PC di Windows tenta di determinare se quanto segue è vero:
Un programma antivirus è presente.
Le firme dell'antivirus sono aggiornate.
La scansione in tempo reale o la scansione in accesso è attivata per i programmi antivirus.
Per i firewall, Centro sicurezza PC di Windows rileva se è installato un firewall di terze parti e se il firewall è attivato o meno.
Quindi, al fine di determinare la presenza di un software antivirus, è possibile utilizzare il WMI effettuare una connessione al root\SecurityCenter
spazio dei nomi (a partire da Windows Vista è necessario utilizzare lo spazio dei nomi root\SecurityCenter2
), e quindi eseguire una query per la classe AntiVirusProduct
WMI.
Guardate questo codice di esempio
using System;
using System.Text;
using System.Management;
namespace ConsoleApplication1
{
class Program
{
public static bool AntivirusInstalled()
{
string wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter";
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipathstr, "SELECT * FROM AntivirusProduct");
ManagementObjectCollection instances = searcher.Get();
return instances.Count > 0;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return false;
}
public static void Main(string[] args)
{
bool returnCode = AntivirusInstalled();
Console.WriteLine("Antivirus Installed " + returnCode.ToString());
Console.WriteLine();
Console.Read();
}
}
}
La query WMI cambia leggermente in Vista SP2 e oltre.
Prova questa parte \ root \ SecurityCenter2 invece di \ root \ SecurityCenter
I risultati sono leggermente differente. È ancora possibile ottenere il nome visualizzato, ma è necessario eseguire un po 'di mascheramento dei bit per il campo ProductState per determinare se onAccessScanner è abilitato/disabilitato e il tipo di informazioni upToDate.
Aperto C:\Windows\System32\wbem\wscenter.mof
da Blocco note. Ti aiuta che gli spazi dei nomi e classi esistono:
C# Query:
// SELECT * FROM AntiVirusProduct
// SELECT * FROM FirewallProduct
// SELECT * FROM AntiSpywareProduct
ManagementObjectSearcher wmiData = new ManagementObjectSearcher(@"root\SecurityCenter2", "SELECT * FROM AntiVirusProduct");
ManagementObjectCollection data = wmiData.Get();
foreach (ManagementObject virusChecker in data)
{
var virusCheckerName = virusChecker["displayName"];
}
wscenter.mof:
#pragma autorecover
#pragma classflags(64)
#pragma namespace("\\\\.\\root")
[NamespaceSecuritySDDL("O:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464G:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464D:(A;CI;0x1;;;BU)(A;CI;0x1;;;BA)(A;CI;0x1;;;NS)(A;CI;0x1;;;LS)(A;CI;0x1;;;AU)(A;CI;0x6001D;;;S-1-5-80-3232712927-1625117661-2590453128-1738570065-3637376297)")]
Instance of __namespace
{
Name = "SecurityCenter";
};
[NamespaceSecuritySDDL("O:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464G:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464D:(A;CI;0x1;;;BU)(A;CI;0x1;;;BA)(A;CI;0x1;;;NS)(A;CI;0x1;;;LS)(A;CI;0x1;;;AU)(A;CI;0x6001D;;;S-1-5-80-3232712927-1625117661-2590453128-1738570065-3637376297)")]
Instance of __namespace
{
Name = "SecurityCenter2";
};
#pragma namespace("\\\\.\\root\\SecurityCenter")
class AntiVirusProduct
{
[key,Not_Null] string instanceGuid;
[Not_Null] string displayName;
[Not_Null] boolean productUptoDate;
boolean onAccessScanningEnabled;
boolean productHasNotifiedUser;
boolean productWantsWscNotifications;
uint8 productState;
string companyName;
string versionNumber;
string pathToSignedProductExe;
};
class FirewallProduct
{
[key,Not_Null] string instanceGuid;
[Not_Null] string displayName;
boolean enabled;
boolean productHasNotifiedUser;
boolean productWantsWscNotifications;
uint8 productState;
string companyName;
string versionNumber;
string pathToSignedProductExe;
};
class AntiSpywareProduct
{
[key,Not_Null] string instanceGuid;
[Not_Null] string displayName;
[Not_Null] boolean productUptoDate;
boolean productEnabled;
boolean productHasNotifiedUser;
boolean productWantsWscNotifications;
uint8 productState;
string companyName;
string versionNumber;
string pathToSignedProductExe;
};
#pragma namespace("\\\\.\\root\\SecurityCenter2")
class AntiVirusProduct
{
[key,Not_Null] string instanceGuid;
[Not_Null] string displayName;
[Not_Null] string pathToSignedProductExe;
[Not_Null] string pathToSignedReportingExe;
[Not_Null] uint32 productState;
string timestamp;
};
class FirewallProduct
{
[key,Not_Null] string instanceGuid;
[Not_Null] string displayName;
[Not_Null] string pathToSignedProductExe;
[Not_Null] string pathToSignedReportingExe;
[Not_Null] uint32 productState;
string timestamp;
};
class AntiSpywareProduct
{
[key,Not_Null] string instanceGuid;
[Not_Null] string displayName;
[Not_Null] string pathToSignedProductExe;
[Not_Null] string pathToSignedReportingExe;
[Not_Null] uint32 productState;
string timestamp;
};
#pragma autorecover
- 1. Software antivirus Windows Server 2008 con un'API
- 2. Esegui programma antivirus utilizzando delphi
- 3. Rileva Windows o Linux in C, C++
- 4. Rileva FN-Key su Mac utilizzando Javascript
- 5. C/C++/Assembly Rileva automaticamente se Hyper-Threading è attivo su Windows, Mac e Linux
- 6. AntiVirus uccide la mia applicazione
- 7. Bluetooth: Rileva evento utilizzando Bluez
- 8. Come memorizzare e recuperare le credenziali su Windows utilizzando C#
- 9. Utilizzando WebSocket su Windows 7
- 10. ROauth su Windows utilizzando R
- 11. Come rilevare l'antivirus su Windows Server 2008 in C#?
- 12. Chiamata al motore di scansione antivirus McAfee
- 13. Rileva versione Windows con JavaScript
- 14. Rileva 404 immagini utilizzando Javascript
- 15. Rileva in modo affidabile Windows in Python
- 16. Funzione sleep in Windows, utilizzando C
- 17. Scarica aggiornamenti di Windows utilizzando C#
- 18. Rileva tasto Invio C#
- 19. C# compilato in mono - Rileva sistema operativo
- 20. Rileva file letta in C#
- 21. Rileva dimensioni carattere Windows (100%, 125%, 150%)
- 22. Utilizzando sys.stdin in select.select su Windows
- 23. Rileva tocco su bitmap
- 24. Rileva modifiche su NSUserDefaults
- 25. rileva l'operazione di copia di Windows Explorer
- 26. Masterizza file su CD utilizzando C#
- 27. Rileva gioco hack tramite analisi screenshot C#
- 28. Installazione del servizio Windows C# su Windows 7
- 29. Rileva unità rimovibile (ad esempio unità flash USB) C/C++
- 30. File audio non elaborato su AAC utilizzando Windows Media Foundation su Windows 7
c'è alcun modo di sapere se l'antivirus viene aggiornato sul sistema in windows [email protected] ng.47 – TechBrkTru
È possibile utilizzare WMI; vedere [qui] (http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/thread/bd97d9e6-75c1-4f58-9573-9009df5de19b). – SLaks