第一题
win10系统中本地cookie的存放位置为:
IE浏览器:%APPDATA%\Microsoft\Windows\Cookies\ 目录中的xxx.txt文件 (IE浏览器分开存放的);
火狐浏览器:%APPDATA%\Mozilla\Firefox\Profiles\ 目录中的???.default-release或???.default目录,名为cookies.sqlite的文件;
谷歌浏览器:%LOCALAPPDATA%\Google\Chrome\User Data\Default\ 目录中,名为Cookies的文件。
使用以下代码获取你所用机器的不同浏览器的cookie的文件夹,并打印输出。
只写了一个谷歌的例子
import os import json import base64 import sqlite3 import win32crypt from cryptography.hazmat.primitives.ciphers.aead import AESGCM # 读取chrome保存在json文件中的key(str) def GetString(LocalState): with open(LocalState, 'r', encoding='utf-8') as f: s = json.load(f)['os_crypt']['encrypted_key'] return s # base64解码,DPAPI解密,得到真实的AESGCM key(bytes) def pull_the_key(base64_encrypted_key): encrypted_key_with_header = base64.b64decode(base64_encrypted_key) encrypted_key = encrypted_key_with_header[5:] key = win32crypt.CryptUnprotectData(encrypted_key, None, None, None, 0)[1] return key # AESGCM解密 def DecryptString(key, data): nonce, cipherbytes = data[3:15], data[15:] aesgcm = AESGCM(key) plainbytes =