码迷,mamicode.com
首页 > 其他好文 > 详细

查看谷歌浏览器保存在本地的密码

时间:2020-01-23 00:20:53      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:sign   查看   pywin32   win   gbk   select   pop   存在   exec   

# 查看谷歌浏览器保存在本地的密码

import os
import shutil
import sqlite3

try:
    import win32crypt
except ImportError as e:
    os.popen('pip install pywin32')
    import win32crypt

db_file_path = os.path.join(os.environ['LOCALAPPDATA'], r'Google\Chrome\User Data\Default\Login Data')

tmp_file = os.path.join(os.environ['LOCALAPPDATA'], 'sqlite_file')
print(tmp_file)
if os.path.exists(tmp_file):
    os.remove(tmp_file)
shutil.copyfile(db_file_path, tmp_file)

conn = sqlite3.connect(tmp_file)
for row in conn.execute('select signon_realm,username_value,password_value from logins'):
    ret = win32crypt.CryptUnprotectData(row[2], None, None, None, 0)
    print('网站:%-50s,用户名:%-20s,密码:%s' % (row[0][:50], row[1], ret[1].decode('gbk')))

conn.close()
os.remove(tmp_file)

查看谷歌浏览器保存在本地的密码

标签:sign   查看   pywin32   win   gbk   select   pop   存在   exec   

原文地址:https://www.cnblogs.com/ruhai/p/12229757.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!