黑松山资源网 Design By www.paidiu.com
由于谷歌浏览器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.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2025年10月25日
2025年10月25日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]