gpt4 book ai didi

google-chrome - Chrome 33 Beta 的 Cookie 问题

转载 作者:行者123 更新时间:2023-12-02 04:55:17 26 4
gpt4 key购买 nike

还有其他人在 Chrome 33 Beta 中读取 cookie 值时遇到问题吗?我们使用 SQLite 数据库浏览器并看到我们删除的 cookie 为空值。 IE、Firefox 和所有以前版本的 Chrome 都没有这个问题。

最佳答案

正如 eneuron 所说,Chrome v33+ 现在会对 cookie 进行加密。

仍然可以使用 SQLite 获取值(尽管不支持使用 SQLite 访问 cookie)。您可以通过在Windows机器上调用CryptUnprotectData来解密基于this discussion的数据。我相信您必须以创建 cookie 的同一用户身份登录。

下面是一个示例脚本,它基于用 python 3 编写的 previously asked question 代码:

# Used information from:
# https://stackoverflow.com/questions/463832/using-dpapi-with-python
# http://www.linkedin.com/groups/Google-Chrome-encrypt-Stored-Cookies-36874.S.5826955428000456708

from ctypes import *
from ctypes.wintypes import DWORD
import sqlite3;

cookieFile="C:/Users/your_user_name/AppData/Local/Google/Chrome/User Data/Default/Cookies";
hostKey="my_host_key";

LocalFree = windll.kernel32.LocalFree;
memcpy = cdll.msvcrt.memcpy;
CryptProtectData = windll.crypt32.CryptProtectData;
CryptUnprotectData = windll.crypt32.CryptUnprotectData;
CRYPTPROTECT_UI_FORBIDDEN = 0x01;

class DATA_BLOB(Structure):
_fields_ = [("cbData", DWORD), ("pbData", POINTER(c_char))];

def getData(blobOut):
cbData = int(blobOut.cbData);
pbData = blobOut.pbData;
buffer = c_buffer(cbData);
memcpy(buffer, pbData, cbData);
LocalFree(pbData);
return buffer.raw;

def encrypt(plainText):
bufferIn = c_buffer(plainText, len(plainText));
blobIn = DATA_BLOB(len(plainText), bufferIn);
blobOut = DATA_BLOB();

if CryptProtectData(byref(blobIn), u"python_data", None,
None, None, CRYPTPROTECT_UI_FORBIDDEN, byref(blobOut)):
return getData(blobOut);
else:
raise Exception("Failed to encrypt data");

def decrypt(cipherText):
bufferIn = c_buffer(cipherText, len(cipherText));
blobIn = DATA_BLOB(len(cipherText), bufferIn);
blobOut = DATA_BLOB();

if CryptUnprotectData(byref(blobIn), None, None, None, None,
CRYPTPROTECT_UI_FORBIDDEN, byref(blobOut)):
return getData(blobOut);
else:
raise Exception("Failed to decrypt data");

conn = sqlite3.connect(cookieFile);
c = conn.cursor();
c.execute("""\
SELECT
host_key,
name,
path,
value,
encrypted_value
FROM cookies
WHERE host_key = '{0}'
;
""".format(hostKey));

cookies = c.fetchmany(10);
c.close();

for row in cookies:
dc = decrypt(row[4]);
print( \
"""
host_key: {0}
name: {1}
path: {2}
value: {3}
encrpyted_value: {4}
""".format(row[0], row[1], row[2], row[3], dc));

关于google-chrome - Chrome 33 Beta 的 Cookie 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21496209/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com