Advertisement
Python253

cve_2024_21338_kernel

Apr 9th, 2024
1,205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.05 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Filename: cve_2024_21338_kernel.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6. # Vulnerability Source: https://nvd.nist.gov/vuln/detail/CVE-2024-21338
  7.  
  8. """
  9. Description:
  10. This script checks for the presence of vulnerable configurations related to the CVE-2024-21338 vulnerability
  11. on the user's machine. It retrieves a list of installed software using the WMI module and compares it with
  12. a predefined list of vulnerable Windows Kernel configurations associated with the CVE. If any vulnerable configurations
  13. are found, it displays a warning message to prompt the user to take immediate action to mitigate the vulnerability.
  14.  
  15. Requirements:
  16. - Python 3.x: The script is written in Python 3 and requires a Python interpreter of version 3 or higher to run.
  17. - WMI Module: The script uses the WMI module to interact with the Windows Management Instrumentation (WMI) API
  18.  to retrieve a list of installed software on a Windows system. Ensure that the WMI module is installed.
  19.  You can install it using pip: `pip install WMI`.
  20.  
  21. Usage:
  22. 1. Ensure Python 3.x is installed on your system.
  23. 2. Install the WMI module by running `pip install WMI`.
  24. 3. Run the script using the command `python cve_2024_21338_kernel.py`.
  25. 4. The script will verify if any vulnerable Windows Kernel configurations are installed on your machine
  26.   and provide instructions for mitigation if necessary.
  27.  
  28. Functions:
  29. - get_installed_software(): Retrieves a list of installed software on the user's machine using the WMI module.
  30. - check_for_vulnerabilities(): Compares the list of installed software with a predefined list of vulnerable
  31.  Windows Kernel configurations and displays a warning message if any vulnerable configurations are found.
  32.  
  33. Important Notes:
  34. - The predefined list of vulnerable Windows Kernel configurations in this script corresponds to the CVE-2024-21338 vulnerability.
  35. """
  36.  
  37. import wmi
  38.  
  39. def get_installed_software():
  40.     """
  41.    Retrieves a list of installed software on the user's machine using the WMI module.
  42.    
  43.    Returns:
  44.        list: A list containing the names of installed software.
  45.    """
  46.     c = wmi.WMI()
  47.     installed_software = []
  48.     for item in c.Win32_Product():
  49.         installed_software.append(item.Caption)
  50.     return installed_software
  51.  
  52. def check_for_vulnerabilities():
  53.     """
  54.    Compares the list of installed software with a predefined list of vulnerable Windows Kernel configurations
  55.    and displays a warning message if any vulnerable configurations are found.
  56.    """
  57.     installed_software = get_installed_software()
  58.     vulnerable_kernel_versions = [
  59.         "Microsoft Windows 10 1809 up to (excluding) 10.0.17763.5458",
  60.         "Microsoft Windows 10 21H2 up to (excluding) 10.0.19044.4046",
  61.         "Microsoft Windows 10 22H2 up to (excluding) 10.0.19045.4046",
  62.         "Microsoft Windows 11 21H2 up to (excluding) 10.0.22000.2777",
  63.         "Microsoft Windows 11 22H2 up to (excluding) 10.0.22621.3155",
  64.         "Microsoft Windows 11 23H2 up to (excluding) 10.0.22631.3155",
  65.         "Microsoft Windows Server 2019 up to (excluding) 10.0.17763.5458",
  66.         "Microsoft Windows Server 2022 up to (excluding) 10.0.20348.2322",
  67.         "Microsoft Windows Server 2022 23H2 up to (including) 10.0.25398.709"
  68.     ]
  69.     vulnerable_installed = [software for software in installed_software if software in vulnerable_kernel_versions]
  70.     if vulnerable_installed:
  71.         print("\nWarning:\nThe following vulnerable Windows Kernel configurations are installed on your machine:")
  72.         for software in vulnerable_installed:
  73.             print("- " + software)
  74.         print("\nPlease take immediate action to mitigate the vulnerability by applying updates per vendor instructions or discontinuing use of the product if mitigations are unavailable.\n")
  75.     else:
  76.         print("\nAll clear!\nNone of the vulnerable Windows Kernel configurations are installed on your machine.\n")
  77.  
  78. if __name__ == "__main__":
  79.     print("Verifying vulnerable Windows Kernel configurations...")
  80.     check_for_vulnerabilities()
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement