獲取谷歌瀏覽器儲存的密碼

2022-06-08 01:39:07 字數 2499 閱讀 3987

由於谷歌瀏覽器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

# 文件:

class chrome:

def __init__(self):

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 ='';"

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()

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'' where signon_realm ='' and username_value='';"""

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("")

print(aa)

谷歌瀏覽器

熬了這麼久終於想弄第二彈,謝謝大家對我第一彈的支援,但是這次的第二彈的豬腳我選擇的是新興的谷歌遊覽器chrome,這裡不把其他基於谷歌遊覽器核心的其他極速版遊覽器列入考慮,因為早在第一彈我已經預見國內ie核心的遊覽器肯定要出雙核,現在事實證明不斷跟上技術的變革才是王道,但是他們的更新沒有chrome...

谷歌推出自己的瀏覽器谷歌瀏覽器chrome

chrom 化學名詞 鉻 個人覺得其有使用性的特點如下 1.一框多用,位址列可以當作搜尋欄,和其業務緊密結合。2.隱身模式,關掉隱身模式的頁面後,個人資訊會全面刪除,你的密碼,cookies等在關閉這個頁面後,就全部被瀏覽器刪除。不影響其他頁面 3.乙個瀏覽視窗崩潰,不會影響其他頁面。ie這點最讓人...

谷歌瀏覽器 chrome XML

引用 w3cschool的教程中提供過乙個loadxmldoc函式 function loadxmldoc url catch e catch e xmldoc.async false xmldoc.load url return xmldoc 不過在谷歌瀏覽器中會出現如下錯誤 object has...