Compare commits
9 Commits
37a51f183c
...
f25bb7cade
Author | SHA1 | Date |
---|---|---|
dependabot[bot] | f25bb7cade | |
簞純 | a55456f060 | |
簞純 | 04adbc3672 | |
簞純 | ef7491a097 | |
簞純 | d92489980c | |
簞純 | 0946cb1324 | |
簞純 | 628a58ce6c | |
簞純 | d871a413fd | |
簞純 | 665d193158 |
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
title: 无需登录,获取宝塔面板保存的数据库密码
|
||||
date: 2023-12-1 15:26:33
|
||||
categories:
|
||||
- Develop
|
||||
tags:
|
||||
- Decrypt
|
||||
---
|
||||
拿到装有宝塔面板的服务器后,在不登录面板的情况下不能直接查看数据库信息
|
||||
|
||||
为了解决这个问题,就制作了一个脚本去进行配置信息的解密
|
||||
|
||||
```python
|
||||
import os
|
||||
|
||||
#使用前pip3 install PyCryptodome
|
||||
|
||||
#下载/www/server/panel/data/div.pl文件,divtext为文件内容
|
||||
divtext = "3UOiALw6JWPa2F02dtN3+ynzUs9oXWcT5llyhivOBaI="
|
||||
|
||||
#下载/www/server/panel/data/default.db,此文件为sqlite数据库文件,打开数据库中databases表,encryptedpass为表中password的值
|
||||
encryptedpass = "BT-0x:tXeUcwJk+Lu5t+BTgGgLAIJbFXYxU84sZA8ak1yjvec="
|
||||
|
||||
def db_decrypt(data):
|
||||
try:
|
||||
key = __get_db_sgin()
|
||||
iv = __get_db_iv()
|
||||
str_arr = data.split('\n')
|
||||
res_str = ''
|
||||
for data in str_arr:
|
||||
if not data: continue
|
||||
res_str += __aes_decrypt(data, key, iv)
|
||||
except:
|
||||
res_str = data
|
||||
return res_str
|
||||
|
||||
def __get_db_sgin():
|
||||
keystr = '3gP7+k_7lSNg3$+Fj!PKW+6$KYgHtw#R'
|
||||
key = ''
|
||||
for i in range(31):
|
||||
if i & 1 == 0:
|
||||
key += keystr[i]
|
||||
return key
|
||||
|
||||
def __get_db_iv():
|
||||
div = __aes_decrypt_module(divtext)
|
||||
return div
|
||||
|
||||
def __aes_decrypt_module(data):
|
||||
key = 'Z2B87NEAS2BkxTrh'
|
||||
iv = 'WwadH66EGWpeeTT6'
|
||||
return __aes_decrypt(data, key, iv)
|
||||
|
||||
def __aes_decrypt(data, key, iv):
|
||||
from Crypto.Cipher import AES
|
||||
import base64
|
||||
encodebytes = base64.decodebytes(data.encode('utf-8'))
|
||||
aes = AES.new(key.encode('utf-8'), AES.MODE_CBC, iv.encode('utf-8'))
|
||||
de_text = aes.decrypt(encodebytes)
|
||||
unpad = lambda s: s[0:-s[-1]]
|
||||
de_text = unpad(de_text)
|
||||
return de_text.decode('utf-8')
|
||||
|
||||
|
||||
temptext = db_decrypt(encryptedpass[6:])
|
||||
print(temptext)
|
||||
```
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1048,13 +1048,36 @@ links:
|
|||
link: "https://www.sy4.top/",
|
||||
avatar: "/img/avatar.png"
|
||||
}
|
||||
|
||||
- {
|
||||
title: "Zy143L",
|
||||
intro: "宁宁's Blog",
|
||||
link: "https://momoe.link/",
|
||||
avatar: "https://momoe.link/img/tx.png"
|
||||
}
|
||||
- {
|
||||
title: "蚊子",
|
||||
intro: "幸福往往是摸得透彻,而堇业的心却常常隐藏",
|
||||
link: "https://mozz.ie/",
|
||||
avatar: "https://mozz.ie/assets/icon-circle.png"
|
||||
}
|
||||
- {
|
||||
title: "Sp4ce",
|
||||
intro: "不傲不畏,不卑不亢,不骄不躁,不气不馁",
|
||||
link: "https://0x20h.com/",
|
||||
avatar: "https://0x20h.com/img/avatar.jpg"
|
||||
}
|
||||
- {
|
||||
title: "MiaoTony",
|
||||
intro: "仰望星空,脚踏实地,未来可期",
|
||||
link: "https://miaotony.xyz/",
|
||||
avatar: "https://miaotony.xyz/medias/avatar.jpg"
|
||||
}
|
||||
- {
|
||||
title: "九世",
|
||||
intro: "九世's Blog",
|
||||
link: "https://jiushill.github.io/",
|
||||
avatar: "https://jiushill.github.io/img/avatar.jpg"
|
||||
}
|
||||
- {
|
||||
title: "To Add",
|
||||
intro: "No Intro",
|
||||
|
|
Loading…
Reference in New Issue