如何找回存儲在DBeaver連接中數(shù)據(jù)庫密碼
一、拿到 credentials-config.json 文件
1、打開 Dbeaver 后,點擊 “窗口 — 首選項”

2、找到worksapce path

3、進入 workspace path 的文件夾,再進入到 \General.dbeaver 文件夾,找到文件 credentials-config.json (可以備份一下這個文件,萬一不小心改了內(nèi)容)。

二、對 credentials-config.json 文件解碼
1、方法一:
如果你有安裝 ubuntu、centos 等這些 linux 操作系統(tǒng),并且系統(tǒng)上安裝了 openssl,則可以使用 openssl 對credentials-config.json文件解碼(以 centos 系統(tǒng)為例):
(1)先把文件復(fù)制到 centos 系統(tǒng)某個目錄下

(2)還是在這個目錄下,使用如下命令
openssl aes-128-cbc -d \ -K babb4a9f774ab853c96c2d653dfe544a \ -iv 00000000000000000000000000000000 \ -in credentials-config.json | \ dd bs=1 skip=16 2>/dev/null

(3)命令執(zhí)行后,就得到解碼后的json字符串(為了方便查看 json 串,可以借助工具 http://tools.jb51.net/code/json 查看)
2、方法二:
如果沒有 linux 系統(tǒng)和 openssl ,可以用 windows 系統(tǒng)和 java
(1)在某個文件夾新建文件 DefaultValueEncryptor.txt ,把下面這段代碼粘貼進去保存。
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
public class DefaultValueEncryptor {
public static final String CIPHER_NAME = "AES/CBC/PKCS5Padding";
public static final String KEY_ALGORITHM = "AES";
private final SecretKey secretKey;
private final Cipher cipher;
public DefaultValueEncryptor(SecretKey secretKey) {
this.secretKey = secretKey;
try {
this.cipher = Cipher.getInstance(CIPHER_NAME);
} catch (Exception e) {
System.out.println("Internal error during encrypted init" + e);
throw new RuntimeException(e);
}
}
public byte[] decryptValue(byte[] value) {
try (InputStream byteStream = new ByteArrayInputStream(value)) {
byte[] fileIv = new byte[16];
byteStream.read(fileIv);
cipher.init(Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(fileIv));
try (CipherInputStream cipherIn = new CipherInputStream(byteStream, cipher)) {
ByteArrayOutputStream resultBuffer = new ByteArrayOutputStream();
int bufferSize = 100;
byte[] buffer = new byte[bufferSize];
while ((bufferSize = cipherIn.read(buffer)) != -1) {
resultBuffer.write(buffer, 0,bufferSize);
}
return resultBuffer.toByteArray();
}
} catch (Exception e) {
System.out.println("Error decrypting value" + e);
throw new RuntimeException(e);
}
}
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("plese input param1: full path to your credentials-config.json file");
System.exit(1);
}
final byte[] LOCAL_KEY_CACHE = new byte[]{-70, -69, 74, -97, 119, 74, -72, 83, -55, 108, 45, 101, 61, -2, 84, 74};
SecretKey aes = new SecretKeySpec(LOCAL_KEY_CACHE, KEY_ALGORITHM);
DefaultValueEncryptor encryptor = new DefaultValueEncryptor(aes);
byte[] credentialsConfigBytesSecret = Files.readAllBytes(Paths.get(args[0]));
byte[] credentialsConfigBytesPlain = encryptor.decryptValue(credentialsConfigBytesSecret);
System.out.println(new String(credentialsConfigBytesPlain));
}
}(2)然后再把文件名的后綴從 .txt 改為 .java ,并把之前的 credentials-config.json 文件也復(fù)制到同個目錄下。

(3)cmd 命令行進入到該目錄,然后依次執(zhí)行命令 ,即可。
javac DefaultValueEncryptor.java java DefaultValueEncryptor credentials-config.json

總結(jié)
到此這篇關(guān)于如何找回存儲在DBeaver連接中數(shù)據(jù)庫密碼的文章就介紹到這了,更多相關(guān)找回DBeaver數(shù)據(jù)庫密碼內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
關(guān)于關(guān)系數(shù)據(jù)庫如何快速查詢表的記錄數(shù)詳解
這篇文章主要給大家介紹了關(guān)于關(guān)系數(shù)據(jù)庫如何快速查詢表的記錄數(shù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學(xué)習(xí)或者使用關(guān)系數(shù)據(jù)庫具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
8種主流NoSQL數(shù)據(jù)庫系統(tǒng)特性對比和最佳應(yīng)用場景
這篇文章主要介紹了8種主流NoSQL數(shù)據(jù)庫系統(tǒng)特性對比和最佳應(yīng)用場景,對選擇一個NoSQL數(shù)據(jù)庫來說是一個不錯的參考文章,需要的朋友可以參考下2014-06-06
梧桐數(shù)據(jù)庫與GBase日期函數(shù)比較代碼示例
這篇文章主要介紹了梧桐數(shù)據(jù)庫和Gbase數(shù)據(jù)庫的日期函數(shù)使用方法,包括日期加減、時間戳加減和其他日期函數(shù),雖然兩個數(shù)據(jù)庫的函數(shù)名不同,但功能相似,為開發(fā)提供了便利,需要的朋友可以參考下2025-02-02
一個查詢的SQL語句請教,希望能夠用一條SQL語句得到結(jié)果
一個查詢的SQL語句請教,希望能夠用一條SQL語句得到結(jié)果...2007-06-06

