Résumé
Cet article fournit des exemples de requêtes que les professionnels de l’informatique peuvent utiliser dans le cadre des rapports de conformité des mises à jour de sécurité en ce qui concerne le Bulletin de sécurité MS17-010.
Attention Ces exemples ne doivent pas être considérés comme une source définitive d’informations sur l’état de conformité. À l’instar de toutes les informations sur la conformité des mises à jour logicielles, ces requêtes reposent sur les informations de résultats d’analyse actuelles et précises figurant dans la base de données Microsoft System Center Configuration Manager. Les exemples de requêtes ont fait l’objet de tests restreints dans Configuration Manager version 1702 et Microsoft SQL Server 2016.
Pour plus d’informations sur cette attaque et le ransomware, consultez la section « Références ».
L’approche la plus simple et la plus généralement recommandée est de déployer la dernière mise à jour cumulative sur les ordinateurs Windows 10 et Windows Server 2016, ainsi que de déployer le dernier correctif cumulatif mensuel sur les ordinateurs antérieurs à Windows 10. Utilisez ensuite les rapports de conformité Configuration Manager intégrés pour déterminer la conformité générale.
Informations sur les requêtes
Versions antérieures à Windows 10
Les ordinateurs Windows 8.1 et Windows Server 2012 R2 qui ne signalent pas que la mise à jour KB2919355 est installée sont retournés par la requête, car cette mise à jour est requise pour que les mises à jour ultérieures puissent être signalées comme étant applicables. Par conséquent, vous pouvez considérer que ces systèmes ne sont pas mis à jour et qu’un examen approfondi est nécessaire.
Les ordinateurs Windows Vista, Windows 7, Windows 8.1, Windows Server 2008 R2 SP1, Windows Server 2008 SP2, Windows Server 2012 ou Windows Server 2012 R2 sont retournés par la requête si le correctif cumulatif mensuel de mars 2017, d’avril 2017 ou de mai 2017 n’est pas installé et s’ils signalent les mises à jour de sécurité uniquement spécifiques suivantes comme étant obligatoires (Required) :
- Windows Vista et Windows Server 2008 SP2 : KB4012598
- Windows 7 et Windows Server 2008 R2 SP1 : KB4012212
- Windows Server 2012 : KB4012214
- Windows Server 2012 R2 et Windows 8.1 : KB4012213
Exemple de requête
-- For Windows 7, Server 2008 R2 SP1, Windows Server 2012, Server 2012 R2 and Windows 8.1, Windows Vista and Server 2008 SP2
-- This query lists machines that are reporting any of the 'Security Only' updates as 'Required'.
-- If any machine has either March, April or May Monthly Rollup installed, then they wouldn't report March 'Security Only' update as 'Required', but look for the Monthly updates anyway.
DECLARE @MarchSecurityOnly TABLE (ArticleID NVARCHAR(20))
INSERT INTO @MarchSecurityOnly VALUES ('4012212')
INSERT INTO @MarchSecurityOnly VALUES ('4012213')
INSERT INTO @MarchSecurityOnly VALUES ('4012214')
INSERT INTO @MarchSecurityOnly VALUES ('4012598')
DECLARE @MarchMonthly TABLE (ArticleID NVARCHAR(20))
INSERT INTO @MarchMonthly VALUES ('4012215')
INSERT INTO @MarchMonthly VALUES ('4015549')
INSERT INTO @MarchMonthly VALUES ('4019264')
INSERT INTO @MarchMonthly VALUES ('4012216')
INSERT INTO @MarchMonthly VALUES ('4015550')
INSERT INTO @MarchMonthly VALUES ('4019215')
INSERT INTO @MarchMonthly VALUES ('4012217')
INSERT INTO @MarchMonthly VALUES ('4015551')
INSERT INTO @MarchMonthly VALUES ('4019216')
DECLARE @KB2919355SRV NVARCHAR(50) = '8452bac0-bf53-4fbd-915d-499de08c338b'
DECLARE @KB2919355WSx86 NVARCHAR(50) = '4ca4dbaa-fae4-4a7c-9760-8e202d10128f'
DECLARE @KB2919355WSx64 NVARCHAR(50) = '26e2a7ee-34d5-4161-ab79-56625337046f'
SELECT
RS.Name0,
UI.ArticleID as ArticleID,
UI.BulletinID as BulletinID,
UI.Title as Title,
SN.StateDescription AS State,
UCS.LastStatusCheckTime AS LastStateReceived,
UCS.LastStatusChangeTime AS LastStateChanged,
UI.CI_UniqueID AS UniqueUpdateID
FROM v_Update_ComplianceStatusReported UCS
JOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_ID
JOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceID
JOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID=2 AND SN.StateID = UCS.Status
WHERE UI.ArticleID IN (SELECT ArticleID FROM @MarchSecurityOnly)
AND RS.Name0 NOT IN (
-- Monthly is installed
SELECT distinct RS.Name0
FROM v_Update_ComplianceStatusReported UCS
JOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_ID
JOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceID
JOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID=3 AND SN.StateID = UCS.Status
WHERE UI.ArticleID IN (SELECT ArticleID FROM @MarchMonthly)
)
UNION
-- Windows Server 2012 R2 machines that do not report KB2919355 as Installed.
SELECT
distinct RS.Name0,
UI.ArticleID as ArticleID,
UI.BulletinID as BulletinID,
'KB2919355' as Title,
'Update is not Installed' AS State,
NULL AS LastStateReceived,
NULL AS LastStateChanged,
'KB2919355' AS UniqueUpdateID
FROM v_Update_ComplianceStatusReported UCS
JOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_ID
JOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceID
JOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID = UCS.Status AND SN.StateID <> 3
JOIN v_GS_OPERATING_SYSTEM OS ON RS.ResourceID = OS.ResourceID AND OS.BuildNumber0 = '9600' AND OS.Caption0 like '%Server 2012 R2%' -- Server 2012 R2
WHERE UI.CI_UniqueID = @KB2919355SRV -- Server 2012 R2
UNION
-- Windows 8.1 x86 machines that do not report KB2919355 as Installed.
SELECT
distinct RS.Name0,
UI.ArticleID as ArticleID,
UI.BulletinID as BulletinID,
'KB2919355' as Title,
'Update is not Installed' AS State,
NULL AS LastStateReceived,
NULL AS LastStateChanged,
'KB2919355' AS UniqueUpdateID
FROM v_Update_ComplianceStatusReported UCS
JOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_ID
JOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceID
JOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID = UCS.Status AND SN.StateID <> 3
JOIN v_GS_OPERATING_SYSTEM OS ON RS.ResourceID = OS.ResourceID AND OS.BuildNumber0 = '9600' AND OS.Caption0 like '%Windows 8.1%' -- Windows 8.1
JOIN v_GS_COMPUTER_SYSTEM CS1 ON CS1.ResourceID = RS.ResourceID AND CS1.SystemType0 = 'X86-based PC' -- x86
WHERE UI.CI_UniqueID = @KB2919355WSx86
UNION
-- Windows 8.1 x64 machines that do not report KB2919355 as Installed.
SELECT
distinct RS.Name0,
UI.ArticleID as ArticleID,
UI.BulletinID as BulletinID,
'KB2919355' as Title,
'Update is not Installed' AS State,
NULL AS LastStateReceived,
NULL AS LastStateChanged,
'KB2919355' AS UniqueUpdateID
FROM v_Update_ComplianceStatusReported UCS
JOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_ID
JOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceID
JOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID = UCS.Status AND SN.StateID <> 3
JOIN v_GS_OPERATING_SYSTEM OS ON RS.ResourceID = OS.ResourceID AND OS.BuildNumber0 = '9600' AND OS.Caption0 like '%Windows 8.1%' -- Windows 8.1
JOIN v_GS_COMPUTER_SYSTEM CS1 ON CS1.ResourceID = RS.ResourceID AND CS1.SystemType0 = 'X64-based PC' -- x64
WHERE UI.CI_UniqueID = @KB2919355WSx64
Windows 10 et Windows Server 2016
Reportez-vous également à la rubrique Microsoft Docs suivante :
Scénario 1
Clients disposant d’une règle de remplacement non définie sur « Expirer immédiatement »
Si les mises à jour remplacées ne sont pas expirées et restent dès lors disponibles dans Configuration Manager, vous pouvez utiliser la requête suivante pour déterminer les systèmes Windows 10 et Windows Server 2016 sur lesquels la mise à jour cumulative de mars ou une mise à jour ultérieure n’est pas installée.
Remarque Pour que les données de la mise à jour cumulative de mars puissent être évaluées, la valeur de Configuration Manager correspondant à la durée d’attente (en mois) avant l’expiration d’une mise à jour doit être suffisamment élevée pour que la mise à jour de mars ne soit pas signalée comme étant expirée. Le même principe s’applique aux mises à jour ultérieures. Si cela ne concerne pas votre environnement, vous pouvez essayer les informations du scénario 2.
Pour les systèmes Windows 10 et Windows Server 2016 suivants, la requête suivante retourne les systèmes sur lesquels aucune des mises à jour cumulatives mensuelles suivantes (publiées en mars 2017 ou ultérieurement) n’est installée :
- Windows 10 RTM : KB4012606, KB4019474, KB4015221, KB4016637
- Windows 10 version 1511 : KB4013198, KB4015219, KB4016636, KB4019473
- Windows 10 version 1607 et Windows Server 2016 : KB4013429, KB4015217, KB4015438, KB4016635, KB4019472
Exemple de requête
-- This query is for Windows 10 computers that do not have the March 2017 update (or any of the superseding updates) installed and that could be 'unpatched'.-- These queries are OS dependent. This is because we are querying individual KB's, and we have to compare those KB's against correct builds to avoid getting inaccurate results.DECLARE @BuildNumberRTM INT = '10240'DECLARE @MarchWin10 TABLE (ArticleID NVARCHAR(20))INSERT INTO @MarchWin10 VALUES ('4012606') -- March CumulativeINSERT INTO @MarchWin10 VALUES ('4019474')INSERT INTO @MarchWin10 VALUES ('4015221')INSERT INTO @MarchWin10 VALUES ('4016637')-- Windows 10 1511DECLARE @BuildNumber1511 INT = '10586'DECLARE @MarchWin101511 TABLE (ArticleID NVARCHAR(20))INSERT INTO @MarchWin101511 VALUES ('4013198') -- March CumulativeINSERT INTO @MarchWin101511 VALUES ('4015219')INSERT INTO @MarchWin101511 VALUES ('4016636')INSERT INTO @MarchWin101511 VALUES ('4019473')-- Windows 10 1607DECLARE @BuildNumber1607 INT = '14393'DECLARE @MarchWin101607 TABLE (ArticleID NVARCHAR(20))INSERT INTO @MarchWin101607 VALUES ('4013429') -- March CumulativeINSERT INTO @MarchWin101607 VALUES ('4015217')INSERT INTO @MarchWin101607 VALUES ('4015438')INSERT INTO @MarchWin101607 VALUES ('4016635')INSERT INTO @MarchWin101607 VALUES ('4019472')SELECT RS.Name0, OS.BuildNumber0 FROM v_R_System RSJOIN v_GS_OPERATING_SYSTEM OS ON RS.ResourceID = OS.ResourceID AND OS.BuildNumber0 = @BuildNumber1607WHERE RS.Name0 NOT IN (SELECT RS.Name0FROM v_Update_ComplianceStatusReported UCSJOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_IDJOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceIDJOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID=3 AND SN.StateID = UCS.StatusJOIN v_GS_OPERATING_SYSTEM OS ON OS.ResourceID = RS.ResourceID AND OS.BuildNumber0 = @BuildNumber1607WHERE UI.ArticleID IN (SELECT ArticleID FROM @MarchWin101607))UNIONSELECT RS.Name0, OS.BuildNumber0 FROM v_R_System RSJOIN v_GS_OPERATING_SYSTEM OS ON RS.ResourceID = OS.ResourceID AND OS.BuildNumber0 = @BuildNumberRTMWHERE RS.Name0 NOT IN (SELECT RS.Name0FROM v_Update_ComplianceStatusReported UCSJOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_IDJOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceIDJOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID=3 AND SN.StateID = UCS.StatusJOIN v_GS_OPERATING_SYSTEM OS ON OS.ResourceID = RS.ResourceID AND OS.BuildNumber0 = @BuildNumberRTMWHERE UI.ArticleID IN (SELECT ArticleID FROM @MarchWin10))UNIONSELECT RS.Name0, OS.BuildNumber0 FROM v_R_System RSJOIN v_GS_OPERATING_SYSTEM OS ON RS.ResourceID = OS.ResourceID AND OS.BuildNumber0 = @BuildNumber1511WHERE RS.Name0 NOT IN (SELECT RS.Name0FROM v_Update_ComplianceStatusReported UCSJOIN v_UpdateInfo UI ON UCS.CI_ID = UI.CI_IDJOIN v_R_System RS ON RS.ResourceType=5 AND RS.ResourceID = UCS.ResourceIDJOIN v_StateNames SN ON SN.TopicType=500 AND SN.StateID=3 AND SN.StateID = UCS.StatusJOIN v_GS_OPERATING_SYSTEM OS ON OS.ResourceID = RS.ResourceID AND OS.BuildNumber0 = @BuildNumber1511WHERE UI.ArticleID IN (SELECT ArticleID FROM @MarchWin101511))
Scénario 2
Clients disposant d’une règle de remplacement définie sur « Expirer immédiatement » (ou pas assez longue)
Des mises à jour cumulatives sont remplacées chaque mois et expirent si l’option Règles de remplacement de Configuration Manager est définie sur « Expirer immédiatement ». Par conséquent, les données de conformité ne sont pas disponibles pour les mises à jour expirées. Toutefois, dans ce scénario, vous disposerez de données de conformité sur la mise à jour cumulative la plus récente. La méthode la plus simple est dès lors de déployer la dernière mise à jour cumulative et de générer un rapport sur cette mise à jour.
Méthodes alternatives pour Windows 10 et Windows Server 2016
Les méthodes alternatives aux scénarios 1 et 2 ci-après peuvent vous aider à déterminer les ordinateurs qui ne sont pas correctement mis à jour.
Méthodes alternatives pour Windows 10 et Windows Server 2016
Étendez l’inventaire matériel pour inclure la classe Win32_QuickFixEngineering et utilisez ces données pour déterminer les ordinateurs sur lesquels aucune des mises à jour cumulatives de mars 2017, d’avril 2017 ou de mai 2017 n’est installée.
Remarque Si ce paramètre n’était pas encore activé et que vous le faites maintenant, vous devez d’abord attendre que tous les clients signalent leur inventaire matériel.
-- Customers with the Win32_QuickFixEngineering class enabled for HINV can use these queries.-- This query is for Windows 10 computers that do not have the March 2017 update (or any of the superseding updates) installed and could be 'unpatched'.-- These queries are OS dependent because we are querying individual KB's, and we have to compare those KB's against correct builds to avoid getting inaccurate results.-- Query limits results for computers that have at least one row in the v_GS_Quick_Fix_Engineering class to make sure that there is some HINV data for the computer for this class.-- Windows 10 RTMDECLARE @BuildNumberRTM INT = '10240'DECLARE @MarchWin10 TABLE (ArticleID NVARCHAR(20))INSERT INTO @MarchWin10 VALUES ('4012606') -- March CumulativeINSERT INTO @MarchWin10 VALUES ('4019474')INSERT INTO @MarchWin10 VALUES ('4015221')INSERT INTO @MarchWin10 VALUES ('4016637')-- Windows 10 1511DECLARE @BuildNumber1511 INT = '10586'DECLARE @MarchWin101511 TABLE (ArticleID NVARCHAR(20))INSERT INTO @MarchWin101511 VALUES ('4013198') -- March CumulativeINSERT INTO @MarchWin101511 VALUES ('4015219')INSERT INTO @MarchWin101511 VALUES ('4016636')INSERT INTO @MarchWin101511 VALUES ('4019473')-- Windows 10 1607DECLARE @BuildNumber1607 INT = '14393'DECLARE @MarchWin101607 TABLE (ArticleID NVARCHAR(20))INSERT INTO @MarchWin101607 VALUES ('4013429') -- March CumulativeINSERT INTO @MarchWin101607 VALUES ('4015217')INSERT INTO @MarchWin101607 VALUES ('4015438')INSERT INTO @MarchWin101607 VALUES ('4016635')INSERT INTO @MarchWin101607 VALUES ('4019472')SELECT RS.Name0, OS.BuildNumber0, QFE.HotFixID0, COUNT(QFEALL.HotFixID0) AS TotalHotfixes FROM v_R_System RSJOIN v_GS_OPERATING_SYSTEM OS ON OS.ResourceID = RS.ResourceID AND OS.BuildNumber0 = @BuildNumberRTMJOIN v_GS_QUICK_FIX_ENGINEERING QFEALL ON QFEALL.ResourceID = RS.ResourceIDLEFT JOIN v_GS_QUICK_FIX_ENGINEERING QFE ON QFE.ResourceID = RS.ResourceID AND QFE.HotFixID0 IN (SELECT 'KB' + ArticleID FROM @MarchWin10)WHERE QFE.HotFixID0 IS NULLGROUP BY RS.Name0, OS.BuildNumber0, QFE.HotFixID0HAVING COUNT(QFEALL.HotFixID0) > 0UNIONSELECT RS.Name0, OS.BuildNumber0, QFE.HotFixID0, COUNT(QFEALL.HotFixID0) AS TotalHotfixes FROM v_R_System RSJOIN v_GS_OPERATING_SYSTEM OS ON OS.ResourceID = RS.ResourceID AND OS.BuildNumber0 = @BuildNumber1511JOIN v_GS_QUICK_FIX_ENGINEERING QFEALL ON QFEALL.ResourceID = RS.ResourceIDLEFT JOIN v_GS_QUICK_FIX_ENGINEERING QFE ON QFE.ResourceID = RS.ResourceID AND QFE.HotFixID0 IN (SELECT 'KB' + ArticleID FROM @MarchWin101511)WHERE QFE.HotFixID0 IS NULLGROUP BY RS.Name0, OS.BuildNumber0, QFE.HotFixID0HAVING COUNT(QFEALL.HotFixID0) > 0UNIONSELECT RS.Name0, OS.BuildNumber0, QFE.HotFixID0, COUNT(QFEALL.HotFixID0) AS TotalHotfixes FROM v_R_System RSJOIN v_GS_OPERATING_SYSTEM OS ON OS.ResourceID = RS.ResourceID AND OS.BuildNumber0 = @BuildNumber1607JOIN v_GS_QUICK_FIX_ENGINEERING QFEALL ON QFEALL.ResourceID = RS.ResourceIDLEFT JOIN v_GS_QUICK_FIX_ENGINEERING QFE ON QFE.ResourceID = RS.ResourceID AND QFE.HotFixID0 IN (SELECT 'KB' + ArticleID FROM @MarchWin101607)WHERE QFE.HotFixID0 IS NULLGROUP BY RS.Name0, OS.BuildNumber0, QFE.HotFixID0HAVING COUNT(QFEALL.HotFixID0) > 0
Méthodes alternatives pour tous les systèmes d’exploitation
Créez un élément et une base de référence de configuration qui interrogent les mises à jour cumulatives de mars 2017, d’avril 2017 et de mai 2017 à partir de la classe Win32_QuickFixEngineering et qui signalent l’état de conformité.
L’exemple de script Windows PowerShell suivant peut être utilisé dans une base de référence DCM.
$InstalledKBList = Get-Wmiobject -class Win32_QuickFixEngineering -namespace "root\cimv2" | select-object -Property HotFixID | Out-String[array]$MS17010VulnerabilityList ="KB4012598","KB4012212","KB4012215","KB4012213","KB4012216","KB4012214","KB4012217","KB4012606","KB4013198","KB4013429","KB4015219","KB4015221","KB4016636","KB4015438","KB4015550","KB4015551","KB4016637","KB4019473","KB4016635","KB4018466","KB4015552","KB4019215","KB4019216","KB4019474","KB4019472","KB4019264"$Compliant = 0;foreach ($elem in $MS17010VulnerabilityList){if ($InstalledKBList -match $elem){#Write-Output "$elem Found"$Compliant = 1break}}$Compliant