def main()

in cortado/rtas/wuauclt_image_load.py [0:0]


def main():
    exe_file = _common.get_resource_path("bin/renamed_posh.exe")
    ps1_file = _common.get_resource_path("bin/Invoke-ImageLoad.ps1")
    renamer = _common.get_resource_path("bin/rcedit-x64.exe")

    wuauclt = "C:\\Users\\Public\\wuauclt.exe"
    user32 = "C:\\Windows\\System32\\user32.dll"
    dll = "C:\\Users\\Public\\unsigned.dll"
    ps1 = "C:\\Users\\Public\\Invoke-ImageLoad.ps1"
    rcedit = "C:\\Users\\Public\\rcedit.exe"
    _common.copy_file(exe_file, wuauclt)
    _common.copy_file(user32, dll)
    _common.copy_file(ps1_file, ps1)
    _common.copy_file(renamer, rcedit)

    # Modify the originalfilename to invalidate the code sig
    log.info("Modifying the OriginalFileName attribute")
    _ = _common.execute_command([rcedit, dll, "--set-version-string", "OriginalFilename", "unsigned.exe"])

    log.info("Loading unsigned.dll into fake wuauclt")
    _ = _common.execute_command(
        [
            wuauclt,
            "-c",
            f"Import-Module {ps1}; Invoke-ImageLoad {dll}",
            ";echo",
            "/RunHandlerComServer",
            ";echo",
            "/UpdateDeploymentProvider",
        ],
        timeout_secs=10,
    )

    _common.remove_files([wuauclt, dll, ps1, rcedit])