【问题标题】:Python3 CryptUnprotectData() TypeError expected an object with a buffer interfacePython3 CryptUnprotectData() TypeError 期望一个具有缓冲区接口的对象
【发布时间】:2011-07-04 09:47:49
【问题描述】:

我正在网上浏览有关 CryptUnprotectData 和 WZC 的一些信息。我发现了这个用于解密 Vista 上存储的无线密码的小脚本。我尝试使用 Python3(它可能是为 Python 2.X 编写的),但它给了我:TypeError 期望一个具有缓冲区接口的对象。我不太确定如何解决它。 这是简单的脚本:

    import win32crypt
    mykey = "Insert keyMaterial"
    binout = []
    for i in range(len(mykey)):
        if i % 2 == 0:
            binout.append(chr(int(mykey[i:i+2],16)))
    pwdHash=''.join(binout)

    output = win32crypt.CryptUnprotectData(pwdHash,None,None,None,0)

    print ("hex:", "".join(["%02X" % ord(char) for char in output[1]]))

    print ("ascii:", output[1])

脚本来自here

【问题讨论】:

    标签: winapi python-3.x wireless


    【解决方案1】:

    当它期望二进制/字节数据时,您正在给它字符串/unicode 数据。

    如果它是为 Python 2 编写的,那么在没有一些修改的情况下不太可能在 Python 3 上工作。使用 Python 2(或修复它)。

    【讨论】:

    • 好的,谢谢,当我知道这意味着什么时,我认为 bytes(pwdHash, 'UTF-8') 应该为 Python3 修复它。
    • @J91321:值得一试。但如果它不起作用,请切换到 Python 2。
    猜你喜欢
    • 1970-01-01
    • 2012-09-17
    • 2023-03-29
    • 2019-11-27
    • 1970-01-01
    • 1970-01-01
    • 2017-04-18
    相关资源
    最近更新 更多