[Python] WindowsDowndate tool error: AttributeError: type object 'PathEx' has no attribute...

Discussão em 'Python' iniciado por Stack, Agosto 23, 2025.

  1. Stack

    Stack Membro Participativo

    I've been trying to use a python tool called WindowsDowndate from github (for educational purposes, I've been given the task to demonstrate some Windows exploit) but running the code just does not work.

    Windows_downdate.py imports numerous methods from another file called filesystem_utils.py, where the error takes place:

    from windows_downdate.filesystem_utils import PathEx, is_file_contents_equal, is_path_exists, read_file, write_file


    The PathEx class is defined in filesystem_utils as follows:

    import filecmp
    import os
    from typing import Union, List, Any, TypeVar, Type, Self
    from pathlib import WindowsPath, _from_parts


    class PathEx(WindowsPath):
    """
    Extended WindowsPath class that supports NT path
    """

    TPathEx = TypeVar("TPathEx")

    def __new__(cls: Type[TPathEx], path: str, *args: Any, **kwargs: Any) -> TPathEx:
    """
    Create a new instance of PathEx, expanding environment variables in the provided path

    :param path: The initial path
    :param args: Additional positional arguments
    :param kwargs: Additional keyword arguments
    :return: A new instance of PathEx
    """
    expanded_path = os.path.expandvars(path)
    args = (expanded_path, ) + args
    self = cls._from_parts(args)
    return self

    @property
    def nt_path(self: Self) -> str:
    """
    :return: The NT path as string
    """
    return f"\\??\\{self.full_path}"

    @property
    def full_path(self: Self) -> str:
    """
    :return: The full path as string
    """
    return str(self)


    I am a very amateur programmer so please forgive my ignorance, I don't quite know how to handle someone else's code.

    Repository link: WindowsDowndate

    Continue reading...

Compartilhe esta Página