av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

python 獲取谷歌瀏覽器保存的密碼

瀏覽:2日期:2022-06-30 11:06:41

由于谷歌瀏覽器80以后版本采用了新的加密方式,所以記錄在這里

# -*- coding:utf-8 -*-import osimport jsonimport base64import sqlite3from win32crypt import CryptUnprotectDatafrom 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?q=OSCrypt&ss=chromiumclass Chrome: def __init__(self): self.local_state = os.environ[’LOCALAPPDATA’] + r’GoogleChromeUser DataLocal State’ self.cookie_path = os.environ[’LOCALAPPDATA’] + r'GoogleChromeUser DataDefaultLogin 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 獲取谷歌瀏覽器保存的密碼的詳細(xì)內(nèi)容,更多關(guān)于python 獲取瀏覽器密碼的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 国产精品久久久久永久免费观看 | 中文字幕视频三区 | 久久久久久久久久影视 | 亚洲国产精品久久久 | 午夜影院在线观看 | 玖操| 亚洲91av | 亚洲精品在线观看视频 | 欧美精品tv | 精品国产黄a∨片高清在线 www.一级片 国产欧美日韩综合精品一区二区 | 亚洲激精日韩激精欧美精品 | 久久国产综合 | 一级a爱片性色毛片免费 | 国产精品123区 | 久久久精品黄色 | 国产精品国产精品国产专区不卡 | 在线日韩欧美 | 久草欧美视频 | 97av在线| 久久久不卡网国产精品一区 | 91av小视频| 国产精品不卡视频 | 日韩精品专区在线影院重磅 | 国产一区二区免费电影 | 日本a网站 | 欧美一区二区成人 | 国产婷婷色综合av蜜臀av | av无遮挡| 欧美三区在线观看 | 亚洲性视频在线 | 九九综合| 成人欧美日韩一区二区三区 | 男人天堂网址 | 国产精品不卡一区 | www成人啪啪18 | 蜜桃视频在线观看免费视频网站www | 99福利在线观看 | 欧美a在线观看 | 久久成人高清视频 | www.99热.com| 欧美亚洲综合久久 |