Chrome 43+浏览器 Cookies encrypted_value解密脚本
2015-12-23 13:48
239 查看
python 3.3.5
# -*- coding: utf-8 -*- # Used information from: # http://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=r'C:\Users\username\AppData\Local\Google\Chrome\User Data\Default\Cookies'; hostKey="court.gov.cn"; 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(); sql = "select host_key, name, value, path,encrypted_value from cookies where host_key like \'%" + hostKey+"%\'"; c.execute(sql); 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));
相关文章推荐
- 20.给UITextField添加一些小动画, 增强UI界面的趣味
- iOS UI-Lable标签、NStimer定时器和RunLoop超级死循环
- 19.制作自动切换滚动的图片轮播
- IOS学习笔记之UISwitch
- iOS UISearchDisplayController学习笔记
- 【ZSTU4215 2015年12月浙理工校赛 F】【Dijkstra最短路】Landlocked 到达海洋最少跨越国家数
- UI布局分析工具-视图工具(Hierarchy Viewer)
- 仿支付宝密码输入界面+随机键盘
- UITextField键盘类型
- UITextField键盘类型
- NGUI研究院之3D模型坐标转2D屏幕坐标-血条
- Handler-接受子线程数据更新UI主线程;非主线程通信--HandlerThread
- 317. Shortest Distance from All Buildings
- UGUI 制作Animation 死活都不播放的坑
- ios搜索栏 UISearchBarDelegate委托常用方法
- Arduino - RGB全彩LED模块
- UITextField与键盘returnSearch关联
- uefi与GPT
- 在iOS 8中使用UIAlertController
- iOS 在UILabel显示不同的字体和颜色