Script vbs pour vérifier que votre PC est protégé contre WANNACRY

Script vbs pour vérifier que votre PC est protégé contre WANNACRY

Script vbs pour vérifier que votre PC est protégé contre WANNACRY

Aucun commentaire sur Script vbs pour vérifier que votre PC est protégé contre WANNACRY 7 217 views

Encore une attaque de Ransomware , qui comme d’habitude débute par une pièce jointe d’email infectée et qui, cette fois c’est nouveau, peut se propager sur un réseau d’entreprise si les PCs et les serveurs n’ont pas au minimum un KB présent dans une liste qui varie suivant l’os présente. Je répète, si vous avez une faille SMB v1 ou un cheval de troie DoublePulsar, votre PC va voir ses fichiers encryptés sans que vous n’ayiez rien ouvert de dangereux.

Les mises à jour windows , même si elles se font ne signifient pas qu’elles ne sont pas en échec d’installation. D’où le besoin de ce testeur.

VerifieWannaCry-V1.vbs
 

Je vous propose une script VBS qui recherche dans les KBs installés du poste , si vous en avez au moins un KB qui adresse cette faille. Ce script est basé sur cette liste de KBs :
‘ # KB4012598 KB4012212 – Windows Server 2008
‘ # KB4012212 KB4012215 KB4019264 – Windows Server 2008 R2
‘ # KB4012214 KB4012217 KB4019216 KB4012220 KB4015551 KB4015554 KB4015553 KB4012219 – Windows Server 2012
‘ # KB4012213 KB4012216 KB4015550 KB4019215 – Windows Server 2012 R2
‘ # KB4013429 KB4019472 KB4015217 KB4015438 KB4016635 – Windows Server 2016
‘ # KB4012598 – Windows Vista
‘ # KB4012212 KB4012215 KB4019264 KB4015549 – Windows 7
‘ # KB4012213 KB4012216 KB4015550 KB4019215 KB4015553 KB4012219 – Windows 8.1
‘ # KB4012606 KB4013198 KB4013429 – Windows 10
‘ # windows 10 1703 creator update pas de KB car pas de faille, check version OS
‘ # KB4012598 – Windows XP
‘ # KB4012598 – Windows 2003
‘ # KB4012598 – Windows 8

On remarque que tous les OS Windows sont concernés, sauf windows 10 version 1703 creator update, j’ai donc inséré un test spécifique pour cet OS. Le test est simple, je passe en revue tous les KBs du poste et je vérifie que le numéro du KB appartient à cette liste , sinon on passe au KB installé suivant. 1 seul KB trouvé qui matche fait quitter le script.

' Checks if the computer is vulnerable to SMBv1 wannacry
'
' Auteur : Frenchytech JM SAILLIO
' Pre-requis Net3.5
' V1 29052017

‘ listes KBs par os
‘ # KB4012598 KB4012212 – Windows Server 2008
‘ # KB4012212 KB4012215 KB4019264 – Windows Server 2008 R2
‘ # KB4012214 KB4012217 KB4019216 KB4012220 KB4015551 KB4015554 KB4015553 KB4012219 – Windows Server 2012
‘ # KB4012213 KB4012216 KB4015550 KB4019215 – Windows Server 2012 R2
‘ # KB4013429 KB4019472 KB4015217 KB4015438 KB4016635 – Windows Server 2016
‘ # KB4012598 – Windows Vista
‘ # KB4012212 KB4012215 KB4019264 KB4015549 – Windows 7
‘ # KB4012213 KB4012216 KB4015550 KB4019215 KB4015553 KB4012219 – Windows 8.1
‘ # KB4012606 KB4013198 KB4013429 – Windows 10
‘ # windows 10 1703 creator update pas de KB car pas de faille, check version OS
‘ # KB4012598 – Windows XP
‘ # KB4012598 – Windows 2003
‘ # KB4012598 – Windows 8

Dim KBList, colQuickFixes, oss
Set KBList = CreateObject(« System.Collections.ArrayList »)

‘ Microsoft Security Bulletin MS17-010
‘ ref: https://technet.microsoft.com/library/security/MS17-010

KBList.Add « 4012212 »
KBList.Add « 4012213 »
KBList.Add « 4012214 »
KBList.Add « 4012215 »
KBList.Add « 4012216 »
KBList.Add « 4012217 »
KBList.Add « 4012598 »
KBList.Add « 4012606 »
KBList.Add « 4013198 »
KBList.Add « 4013429 »

‘ Windows 10 and Windows Server 2016 updates are cumulative.
‘ The monthly security release includes all security fixes for vulnerabilities that affect Windows 10, in addition to non-security updates.

‘ Cumulative KBs for Windows 10 and Windows Server 2016:

‘ From KB4012606
‘ ref: http://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=6a38fe85-98ba-4ce2-b4eb-aed947d5c203
‘ As of May 17, 2017:

‘ 2017-05 Cumulative Update for Windows 10 for x86-based Systems (KB4019474)
‘ Cumulative Update for Windows 10 (KB4015221)
‘ Cumulative Update for Windows 10 (KB4016637)

KBList.Add « 4019474 »
KBList.Add « 4015221 »
KBList.Add « 4016637 »

‘ From KB4013198
‘ ref: http://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=6d9f75f7-d998-4188-a935-7603f4e51a4d
‘ As of May 17, 2017:

‘ Cumulative Update for Windows 10 Version 1511 (KB4015219)
‘ Cumulative Update for Windows 10 Version 1511 (KB4016636)
‘ Cumulative Update for Windows 10 Version 1511 (KB4019473)

KBList.Add « 4015219 »
KBList.Add « 4016636 »
KBList.Add « 4019473 »

‘ From KB4013429
‘ ref: http://www.catalog.update.microsoft.com/ScopedViewInline.aspx?updateid=724ee219-b949-4d44-9e02-e464c6062ae4
‘ As of May 17, 2017:

‘ 2017-05 Cumulative Update for Windows 10 Version 1607 for x86-based Systems (KB4019472)
‘ Cumulative Update for Windows 10 Version 1607 (KB4015217)
‘ Cumulative Update for Windows 10 Version 1607 (KB4015438)
‘ Cumulative Update for Windows 10 Version 1607 (KB4016635)

KBList.Add « 4019472 »
KBList.Add « 4015217 »
KBList.Add « 4015438 »
KBList.Add « 4016635 »

‘ From: WannaCrypt Ransomware Customer Guidance: https://static.spiceworks.com/attachments/post/0017/5996/CustomerReady_WannaCrypt_Guidance.pdf
‘ TODO: Get short list of KBs needed to check for EternalBlue patch

KBList.Add « 4015549 »
KBList.Add « 4015550 »
KBList.Add « 4015551 »
KBList.Add « 4019215 »
KBList.Add « 4019216 »
KBList.Add « 4019264 »

Set WshShell = CreateObject(« WScript.Shell »)

strComputer = « . »
Set objWMIService = GetObject(« winmgmts: » _
& « {impersonationLevel=impersonate}!\\ » & strComputer & « \root\cimv2 »)

Set colQuickFixes = objWMIService.ExecQuery _
(« Select * from Win32_QuickFixEngineering »)

Set oss = objWMIService.ExecQuery (« Select * from Win32_OperatingSystem »)

CreateObject(« WScript.Shell »).Popup « test windows 10 creator update installÈ », 3, « Vulnerable ‡ WannaCry? », vbOKOnly
‘check windows 10 1703
For Each os in oss
if Mid(os.version,6,5) = « 15063 » Then
MsgBox(« votre ordinateur est protÈgÈ contre la faille SMBv1 Wannacry car version OS =(« + os.version + ») »)
WScript.Quit
End If
next

CreateObject(« WScript.Shell »).Popup « Je recupËre la liste des KBs installÈs » & vbcrlf & vbcrlf & « patience… », 3, « Vulnerable ‡ WannaCry? », vbOKOnly

 » » » » » »’boucle recherche kbs
For Each objQuickFix in colQuickFixes

If KBList.Contains(Mid(objQuickFix.HotFixID,3,7)) Then
MsgBox(« votre ordinateur est protÈgÈ contre la faille SMBv1 Wannacry (« + objQuickFix.HotFixID + ») »)
WScript.Quit
End If
Next
 » » » » » » » »fin boucle KBs

MsgBox(« votre ordinateur n est pas protÈgÈ contre la faille SMBv1 Wannacry, mettre a jour suivant os »)

About the author:

Ingénieur ENSEA, 15 ans Manager IT Support pour des grands comptes, maintenant Indépendant au sein de FRENCHYTECH, conseil en SI pour PME/TPE

Laisser un commentaire

retour en haut