Git*_*gal 43 database encryption passwords dbeaver
我忘记了开发实例的密码(不负责任......是的,我正在研究它).我使用密码保存在我的DBeaver中的连接.我仍然可以使用该连接进行连接.DBeaver没有以纯文本显示它.无论如何我可以检索密码吗?要求DBA重置密码是最后的手段.我试图将粘贴复制到记事本中,显然禁用了复制.
so-*_*ude 128
我最近遇到了这个问题.请按照以下步骤操作(我的DBeaver版本是3.5.8,它是在Mac OSX El Capitan上)
~/.dbeaver/General/.dbeaver-data-sources.xml
.此文件是隐藏的,因此在您查找时请记住这一点.在第13行,只需替换OwEKLE4jpQ==
您在.dbeaver-data-sources.xml
感兴趣的数据源文件中找到的任何加密密码.编译并运行它,它将打印纯文本密码.
https://github.com/so-random-dude/oneoffcodes/blob/master/SimpleStringEncrypter.java
显然,这是一个"流行"的错误.所以我已经使用上述代码部署了一个AWS lambda函数.使用此风险需要您自担风险,您永远不会知道我是否记录了您的密码:D
curl https://lmqm83ysii.execute-api.us-west-2.amazonaws.com/prod/dbeaver-password-decrypter \
-X POST --data "OwEKLE4jpQ=="
Run Code Online (Sandbox Code Playgroud)
更好的是,这里是用户界面http://dbeaver-password-decrypter.s3-website-us-west-2.amazonaws.com/.不言而喻,使用此风险需要您自担风险.非Https是你最不担心的!:)
Fia*_*eid 67
对于 Windows 用户(测试版本 7.3.4,还测试了 22.2.3)
按文件 > 导出 > DBeaver > 项目
将导出文件的名称更改为.zip,然后解压
下载OpenSSL,并复制\projects\General\.dbeaver\credentials-config.json
到openssl的bin目录同一个文件夹中
然后运行:
openssl aes-128-cbc -d -K babb4a9f774ab853c96c2d653dfe544a -iv 00000000000000000000000000000000 -in "credentials-config.json"
Run Code Online (Sandbox Code Playgroud)
which openssl
如果您安装了 WSL,则还可以从 Linux 安装中运行此命令,并且可从 Linux 安装内的任何目录中使用 openssl ( )(在 WSL2 上使用 Ubuntu 进行测试,将文件复制到\\wsl$\Ubuntu\home\me\dbeaver\credentials
)。
它将默认输出到终端,如果您需要在文件中添加 > chosen_filename.json
到命令中。
Tat*_*tsh 49
这可以通过 OpenSSL 完成:
openssl aes-128-cbc -d \
-K babb4a9f774ab853c96c2d653dfe544a \
-iv 00000000000000000000000000000000 \
-in credentials-config.json | \
dd bs=1 skip=16 2>/dev/null
Run Code Online (Sandbox Code Playgroud)
一行中的 macOS 示例:
openssl aes-128-cbc -d -K babb4a9f774ab853c96c2d653dfe544a -iv 00000000000000000000000000000000 -in "${HOME}/Library/DBeaverData/workspace6/General/.dbeaver/credentials-config.json" | dd bs=1 skip=16 2>/dev/null
Run Code Online (Sandbox Code Playgroud)
对于 Linux,将上述路径更改为~/.local/share/DBeaverData/workspace6/General/.dbeaver/credentials-config.json
.
密钥来自源代码并转换为十六进制。这可以在 Python 中完成:
>>> import struct
>>> struct.pack('<16b', -70, -69, 74, -97, 119, 74, -72, 83, -55, 108, 45, 101, 61, -2, 84, 74).hex()
'babb4a9f774ab853c96c2d653dfe544a'
Run Code Online (Sandbox Code Playgroud)
fel*_*pou 17
DBeaver 6.1.3+ 版本的 Python 解密脚本,基于@rogerdpack 的回答:
https://gist.github.com/felipou/50b60309f99b70b1e28f6d22da5d8e61
对于较旧的 DBeaver 版本,还有另一个基于 @so-random-dude 回答的脚本:
https://gist.github.com/felipou/f5472ad5f6a414528b44beb102e17fb4
lew*_*s4u 11
对于 Linux 操作系统用户,请在终端中运行以下命令:
openssl aes-128-cbc -d -K babb4a9f774ab853c96c2d653dfe544a -iv 00000000000000000000000000000000 -in "path_to/credentials-config.json" | dd bs=1 skip=16 2>/dev/null
Run Code Online (Sandbox Code Playgroud)
只需将字符串“path_to/credentials-config.json”替换为该文件的实际路径,您将得到如下内容:
{"mysql8-17e009389a8-5fc414bd64e183f4":{"#connection":{"user":"root","password":"root"}},"mysql8-18099236fdf-3c3fc761c6fdde":{"#connection":{"user":"user.name","password":"your_secret_password"},"network/ssh_tunnel":{"user":"sql","jumpServer0.password":""}}}%
Run Code Online (Sandbox Code Playgroud)
Tal*_*iqi 10
这是在所需目标路径上获取 dbeaver 凭据文件的解密版本的命令:
openssl aes-128-cbc -d \
-K babb4a9f774ab853c96c2d653dfe544a \
-iv 00000000000000000000000000000000 \
-in {path for the encrypted credentials file} > \
{your desired destination file}
Run Code Online (Sandbox Code Playgroud)
~/Desktop/dbeaver-credentials.json
您将在桌面上找到dbeaver-credentials.json
该文件。但此文件将仅包含带有某些连接节的用户名和密码的列表(例如mysql5-17be86ca5ea-294e2a427af47fc4
)。那里不会有数据库或服务器名称。您必须找到针对对象 ID 的连接。
对于 Ubuntusnap
软件包dbeaver-ce
,
~/snap/dbeaver-ce/current/.local/share/DBeaverData/workspace6/General/.dbeaver/credentials-config.json
对于DBeaver 6.1.3+,现在使用不同的加密将凭据存储在“ json”文件中。
这似乎为我完成了工作:
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.*;
public class DecryptDbeaver {
// from the DBeaver source 8/23/19 https://github.com/dbeaver/dbeaver/blob/57cec8ddfdbbf311261ebd0c7f957fdcd80a085f/plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/app/DefaultSecureStorage.java#L31
private static final byte[] LOCAL_KEY_CACHE = new byte[] { -70, -69, 74, -97, 119, 74, -72, 83, -55, 108, 45, 101, 61, -2, 84, 74 };
static String decrypt(byte[] contents) throws InvalidAlgorithmParameterException, InvalidKeyException, IOException, NoSuchPaddingException, NoSuchAlgorithmException {
try (InputStream byteStream = new ByteArrayInputStream(contents)) {
byte[] fileIv = new byte[16];
byteStream.read(fileIv);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
SecretKey aes = new SecretKeySpec(LOCAL_KEY_CACHE, "AES");
cipher.init(Cipher.DECRYPT_MODE, aes, new IvParameterSpec(fileIv));
try (CipherInputStream cipherIn = new CipherInputStream(byteStream, cipher)) {
return inputStreamToString(cipherIn);
}
}
}
static String inputStreamToString(java.io.InputStream is) {
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("syntax: param1: full path to your credentials-config.json file");
System.exit(1);
}
System.out.println(decrypt(Files.readAllBytes(Paths.get(args[0]))));
}
}
Run Code Online (Sandbox Code Playgroud)
在本地文件系统上将您的凭据-config.json文件的路径传递给我,
javac DecryptDbeaver.java # compile it
java DecryptDbeaver ~/Library/DBeaverData/workspace6/General/.dbeaver/credentials-config.json
Run Code Online (Sandbox Code Playgroud)
它将把用于连接的用户+密码输出到控制台。如果您不知道哪个密码进入哪个数据库,则必须交叉链接ID名称,该ID名称也会输出到同级data-sources.json
文件(该文件应该已经存在并且未加密)。