由于谷歌浏览器80以后版本采用了新的加密方式,所以记录在这里
# -*- coding:utf-8 -*- import os import json import base64 import sqlite3 from win32crypt import CryptUnprotectData from cryptography.hazmat.primitives.ciphers.aead import AESGCM # pip install pywin32 # pip install cryptography # 文档:https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_win.cc"\Google\Chrome\User Data\Default\Login Data" def get_key(self): with open(self.local_state, 'r', encoding='utf-8') as f: base64_encrypted_key = json.load(f)['os_crypt']['encrypted_key'] encrypted_key_with_header = base64.b64decode(base64_encrypted_key) # 去掉开头的DPAPI encrypted_key = encrypted_key_with_header[5:] key_ = CryptUnprotectData(encrypted_key, None, None, None, 0)[1] return key_ @staticmethod def decrypt_string(key, secret, salt=None): """ 解密 """ # 去掉'v10' nonce, cipher_bytes = secret[3:15], secret[15:] aes_gcm = AESGCM(key) return aes_gcm.decrypt(nonce, cipher_bytes, salt).decode('utf-8') @staticmethod def encrypt_string(key, data, salt=None): """ 加密 """ aes_gcm = AESGCM(key) prefix = "v10".encode("utf-8") # 随机生成12位字符串,拼接"v10" 共15位 nonce = os.urandom(12) cipher_bytes = data.encode("utf-8") return prefix + nonce + aes_gcm.encrypt(nonce, cipher_bytes, salt) def get_password(self, host): sql = f"select username_value,password_value from logins where signon_realm ='{host}';" with sqlite3.connect(self.cookie_path) as conn: cu = conn.cursor() res = cu.execute(sql).fetchall() cu.close() result = [] key = self.get_key() for name, encrypted_value in res: if encrypted_value[0:3] == b'v10' or encrypted_value[0:3] == b'v11': password = self.decrypt_string(key, encrypted_value) else: password = CryptUnprotectData(encrypted_value)[1].decode() result.append({'user_name': name, 'password': password}) return result def set_password(self, host, username, password): key = self.get_key() encrypt_secret = self.encrypt_string(key, password) sq = f"""update logins set password_value=x'{encrypt_secret.hex()}' where signon_realm ='{host}' and username_value='{username}';""" with sqlite3.connect(self.cookie_path) as conn: cu = conn.cursor() cu.execute(sq) conn.commit() if __name__ == '__main__': a = Chrome() aa = a.get_password("https://baidu.com") print(aa)
以上就是python 获取谷歌浏览器保存的密码的详细内容,更多关于python 获取浏览器密码的资料请关注其它相关文章!
风云阁资源网 Design By www.bgabc.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
风云阁资源网 Design By www.bgabc.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- 《张国荣 首首动听经典不容错过 追忆的风 2CD》[WAV+CUE][870MB]
- 《腾格尔 容中尔甲 亚东 高原三星 男人篇 3CD》[WAV/分轨][1GB]
- 命运圣契公测实测可用兑换码大全 命运圣契最新兑换码分享
- 黑神话悟空上品疾蝠精魄获取方法一览|上品疾蝠精魄收集攻略
- 《七龙珠电光炸裂!ZERO》GT角色预告片曝光,15位新角色登场
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- NewViennaOctetViennaWindSoloists-TheDeccaRecordings(2024)18CD[24-48][FLAC]-7
- 雨果唱片-三角琴《俄罗斯民间音乐系列-梁祝(中国名曲)》wav
- 《塞尔达传说:智慧的再现》新实机!无之世界介绍
- 任天堂公布《塞尔达传说》系列时间线:野炊与王泪独立在外
- 任天堂更新网络投稿规范:打击影响他人游戏体验行为
- 冼佩瑾.2024-女儿Daughter(EP)【杰威尔】【FLAC分轨】
- 黑豹乐队.1993-光芒之神【摇音晨【WAV+CUE】
- 曾轶可.2011-一只猫的旅行【天娱传媒】【WAV+CUE】
- 黑神话悟空上品狼刺客精魄获取方法一览|上品狼刺客精魄收集攻略