Attention : support for WAPT 1.8.2 ended on June the 30th 2022.

There are known vulnerabilities in WAPT dependencies in WAPT 1.8.2 branch. Please upgrade to the latest supported version. CVE listing (non exhaustive) :
  • * python engine : python 2.7 (CVE-2020-10735, CVE-2015-20107, CVE-2022-0391, CVE-2021-23336, CVE-2021-3177, CVE-2020-27619, CVE-2020-26116, CVE-2019-20907, CVE-2020-8492, etc.)
  • * cryptography : openssl : CVE-2022-2068, CVE-2022-1292, CVE-2022-0778, CVE-2021-4160, CVE-2021-3712, CVE-2021-23841, CVE-2021-23840, CVE-2021-23839, CVE-2020-1971, CVE-2020-1968, CVE-2019-1551
  • * python dependencies : cryptography (CVE-2020-36242, CVE-2020-25659), eventlet (CVE-2021-21419), jinja2 (CVE-2020-28493), psutil (CVE-2019-18874), waitress (CVE-2022-31015), lxml (CVE-2021-4381, CVE-2021-28957, CVE-2020-27783, CVE-2018-19787), ujson (CVE-2022-31117, CVE-2022-31116, CVE-2021-45958), python-ldap (CVE-2021-46823)

Packaging Windows Update .msu packages

Hint

Pre-requisites: to build WAPT packages, the WAPT development environment must be installed;

Between Patch Tuesday releases, Microsoft may release additional KBs or critical updates that will need to be pushed to hosts quickly.

For that purpose, WAPT provides a package template for *.msu files.

In that example, we use the KB4522355 downloaded from Microsoft Catalog website.

Creating a MSU package template from the WAPT console

  • create a WAPT package Template from the downloaded MSU file;

    In the WAPT console, click on Tools ‣ Package Wizard;

    Pyscripter - WAPT console window for creating a package template

    Pyscripter - WAPT console window for creating a package template

  • select the downloaded MSU package and fill in the required fields;

    Informations required for creating the package

    Informations required for creating the MSU package

  • click on Make and edit …. (recommended) to launch package customization;

  • WAPT package IDE is launched using the source code from the pre-defined MSU template.

  • as usual with WAPT packages, test - build - sign - upload - affect to hosts and it is done!!

  • if the KB becomes bundled with the following Patch Tuesday, you can select the hosts onto which the package has been applied and forget the KB package on the hosts;

Creating a MSU package template from command line

  • launch a Windows Command Line utility cmd.exe as Local Administrator;

    Windows Command Line utility launched as Local Administrator

    Windows Command Line utility launched as Local Administrator

  • instantiate a package from the pre-defined MSU template;

    wapt-get make-template c:\download\file.msu <yourprefix>-kb4522355
    
  • output example with KB4522355:

    C:\WINDOWS\system32>wapt-get make-template C:\windows10.0-kb4522355-x64_af588d16a8fbb572b70c3b3bb34edee42d6a460b.msu tis-kb4522355
    Using config file: C:\Users\user-adm\AppData\Local\waptconsole\waptconsole.ini
    
    Template created. You can build the WAPT package by launching
      C:\Program Files (x86)\wapt\wapt-get.exe build-package c:\waptdev\tis-kb4522355-wapt
    
    You can build and upload the WAPT package by launching
      C:\Program Files (x86)\wapt\wapt-get.exe build-upload c:\waptdev\tis-kb4522355-wapt
    
  • WAPT package IDE is launched, here is an example source code from the pre-defined MSU template:

    # -*- coding: utf-8 -*-
    from setuphelpers import *
    import re
    
    uninstallkey = []
    
    def is_kb_installed(hotfixid):
        installed_update = installed_windows_updates()
        if [kb for kb in installed_update if kb['HotFixID' ].upper() == hotfixid.upper()]:
            return True
        return False
    
    def waiting_for_reboot():
        # Query WUAU from the registry
        if reg_key_exists(HKEY_LOCAL_MACHINE,r"SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") or \
            reg_key_exists(HKEY_LOCAL_MACHINE,r"SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") or \
            reg_key_exists(HKEY_LOCAL_MACHINE,r'SOFTWARE\Microsoft\Updates\UpdateExeVolatile'):
            return True
        return False
    
    def install():
        kb_files = [
            'windows10.0-kb4522355-x64_af588d16a8fbb572b70c3b3bb34edee42d6a460b.msu',
            ]
        with EnsureWUAUServRunning():
          for kb_file in kb_files:
              kb_guess = re.findall(r'^.*-(KB.*)-',kb_file)
              if not kb_guess or not is_kb_installed(kb_guess[0]):
                  print('Installing {}'.format(kb_file))
                  run('wusa.exe "{}" /quiet /norestart'.format(kb_file),accept_returncodes=[0,3010,2359302,-2145124329],timeout=3600)
              else:
                  print('{} already installed'.format(kb_file))
    
          if waiting_for_reboot():
              print('A reboot is needed!')