[Python] How to verifying whether a file has valid signature in python?

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I want to verify signature code in python with the only input is path/to/file

    All other sources I've consulted need individual signature files but I only want to take as input a single file (can be .exe or .dll)

    I've tried to write code purpose to verify if a file has a valid signature via window powershell

    def is_valid_Sig(path:str):
    if os.path.exists(path):
    command = f"Get-AuthenticodeSignature \"{path}\""
    result = subprocess.run(["powershell.exe", command], capture_output=True)
    result = str(str(result.stdout) + str(result.stderr))

    if " Valid " in result:
    return 1
    else: return 0
    else: return -1


    Is there anyway to do it without using cmd or powershell ? Please help me, thank you very much :>

    Continue reading...

Compartilhe esta Página