├── img └── 1.png ├── src └── main │ └── java │ └── me │ └── gv7 │ └── woodpecker │ ├── plugin │ └── WoodpeckerPluginManager.java │ └── helper │ ├── DBeaverPasswdDcrypter.java │ └── PasswdDecryptHelper.java ├── README.md └── pom.xml /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuyan-sec/DBeaver-decrypter/HEAD/img/1.png -------------------------------------------------------------------------------- /src/main/java/me/gv7/woodpecker/plugin/WoodpeckerPluginManager.java: -------------------------------------------------------------------------------- 1 | package me.gv7.woodpecker.plugin; 2 | 3 | import me.gv7.woodpecker.helper.DBeaverPasswdDcrypter; 4 | 5 | public class WoodpeckerPluginManager implements IPluginManager { 6 | public void registerPluginManagerCallbacks(IPluginManagerCallbacks iPluginManagerCallbacks) { 7 | DBeaverPasswdDcrypter echoTextConverter = new DBeaverPasswdDcrypter(); 8 | iPluginManagerCallbacks.registerHelperPlugin(echoTextConverter); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 0x01 简介 2 | 3 | DBeaver-decrypter 是一款用于解密DBeaver数据库软件保存的密码的 woodpecker 插件。 4 | 5 | ## 0x02 演示 6 | 7 | Windows 默认配置 8 | 9 | ``` 10 | 密码文件: 11 | C:\Users\Administrator\AppData\Roaming\DBeaverData\workspace6\General.dbeaver\credentials-config.json 12 | 13 | 连接信息: 14 | C:\Users\Administrator\AppData\Roaming\DBeaverData\workspace6\General.dbeaver\data-sources.json 15 | ``` 16 | 17 | MacOS 默认配置 18 | 19 | ``` 20 | /Users//Library/DBeaverData/workspace6/General/.dbeaver/credentials-config.json 21 | /Users//Library/DBeaverData/workspace6/General/.dbeaver/data-sources.json 22 | ``` 23 | 24 | Linux 默认配置 25 | 26 | ``` 27 | /home//.local/share/DBeaverData/workspace6/General/.dbeaver/credentials-config.json 28 | /home//.local/share/DBeaverData/workspace6/General/.dbeaver/data-sources.json 29 | ``` 30 | 31 | 32 | 33 | ![](./img/1.png) 34 | 35 | ## 0x03 参考文献 36 | 37 | - https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection/57630312#57630312 -------------------------------------------------------------------------------- /src/main/java/me/gv7/woodpecker/helper/DBeaverPasswdDcrypter.java: -------------------------------------------------------------------------------- 1 | package me.gv7.woodpecker.helper; 2 | 3 | import me.gv7.woodpecker.plugin.IHelper; 4 | import me.gv7.woodpecker.plugin.IHelperPlugin; 5 | import me.gv7.woodpecker.plugin.IHelperPluginCallbacks; 6 | import me.gv7.woodpecker.plugin.IPluginHelper; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class DBeaverPasswdDcrypter implements IHelperPlugin { 12 | public static IHelperPluginCallbacks callbacks; 13 | public static IPluginHelper pluginHelper; 14 | 15 | public DBeaverPasswdDcrypter() { 16 | } 17 | 18 | @Override 19 | public void HelperPluginMain(IHelperPluginCallbacks iHelperPluginCallbacks) { 20 | callbacks = iHelperPluginCallbacks; 21 | pluginHelper = callbacks.getPluginHelper(); 22 | callbacks.setHelperPluginName("DBeaver password Decrypter"); 23 | callbacks.setHelperPluginVersion("0.1.0"); 24 | callbacks.setHelperPluginAutor("yuyan-sec"); 25 | callbacks.setHelperPluginDescription("DBeaver解密"); 26 | List helperList = new ArrayList(); 27 | helperList.add(new PasswdDecryptHelper()); 28 | callbacks.registerHelper(helperList); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | groupId 8 | DBeaver-decrypter 9 | 0.1.0 10 | 11 | 12 | UTF-8 13 | 8 14 | 8 15 | 16 | 17 | 18 | 19 | 20 | me.gv7.woodpecker 21 | woodpecker-sdk 22 | 0.3.0 23 | provided 24 | 25 | 26 | 27 | 28 | junit 29 | junit 30 | 4.13 31 | test 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.apache.maven.plugins 40 | maven-assembly-plugin 41 | 2.5.5 42 | 43 | 44 | jar-with-dependencies 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/main/java/me/gv7/woodpecker/helper/PasswdDecryptHelper.java: -------------------------------------------------------------------------------- 1 | package me.gv7.woodpecker.helper; 2 | 3 | import me.gv7.woodpecker.plugin.IArg; 4 | import me.gv7.woodpecker.plugin.IArgsUsageBinder; 5 | import me.gv7.woodpecker.plugin.IHelper; 6 | import me.gv7.woodpecker.plugin.IResultOutput; 7 | 8 | 9 | import javax.crypto.Cipher; 10 | import javax.crypto.CipherInputStream; 11 | import javax.crypto.SecretKey; 12 | import javax.crypto.spec.IvParameterSpec; 13 | import javax.crypto.spec.SecretKeySpec; 14 | import java.io.ByteArrayInputStream; 15 | import java.io.InputStream; 16 | import java.nio.file.Files; 17 | import java.nio.file.Paths; 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | public class PasswdDecryptHelper implements IHelper { 23 | 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 }; 24 | 25 | public PasswdDecryptHelper() { 26 | } 27 | 28 | public String getHelperTabCaption() { 29 | return "DBeaver password Decrypter"; 30 | } 31 | 32 | public IArgsUsageBinder getHelperCutomArgs() { 33 | IArgsUsageBinder argsUsageBinder = DBeaverPasswdDcrypter.pluginHelper.createArgsUsageBinder(); 34 | List args = new ArrayList(); 35 | IArg argPassword = DBeaverPasswdDcrypter.pluginHelper.createArg(); 36 | argPassword.setName("file"); 37 | argPassword.setDefaultValue("C:\\Users\\administrator\\AppData\\Roaming\\DBeaverData\\workspace6\\General\\.dbeaver\\credentials-config.json"); 38 | argPassword.setDescription("需要解密的连接文件"); 39 | argPassword.setRequired(true); 40 | args.add(argPassword); 41 | 42 | argsUsageBinder.setArgsList(args); 43 | return argsUsageBinder; 44 | } 45 | 46 | public void doHelp(Map customArgs, IResultOutput iResultOutput) throws Throwable { 47 | String filename = (String) customArgs.get("file"); 48 | // String customKey = (String) customArgs.get("key"); 49 | // long key = 1231234234; 50 | // if (customKey != null) { 51 | // key = Long.parseLong(customKey); 52 | // } 53 | try { 54 | // Encode encoder = new Encode(); 55 | // String plainText = encoder.decode(password, key); 56 | 57 | String plainText = Decrypt(Files.readAllBytes(Paths.get(filename))); 58 | iResultOutput.successPrintln("Decrypt result:"); 59 | iResultOutput.rawPrintln("\n" + plainText + "\n"); 60 | } catch (Exception var6) { 61 | iResultOutput.errorPrintln(DBeaverPasswdDcrypter.pluginHelper.getThrowableInfo(var6)); 62 | } 63 | } 64 | 65 | public static String Decrypt(byte[] contents){ 66 | try (InputStream byteStream = new ByteArrayInputStream(contents)) { 67 | byte[] fileIv = new byte[16]; 68 | byteStream.read(fileIv); 69 | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); 70 | SecretKey aes = new SecretKeySpec(LOCAL_KEY_CACHE, "AES"); 71 | cipher.init(Cipher.DECRYPT_MODE, aes, new IvParameterSpec(fileIv)); 72 | try (CipherInputStream cipherIn = new CipherInputStream(byteStream, cipher)) { 73 | return inputStreamToString(cipherIn); 74 | } catch (Exception e){ 75 | return e.getMessage(); 76 | } 77 | } catch (Exception e){ 78 | return e.getMessage(); 79 | } 80 | } 81 | 82 | static String inputStreamToString(java.io.InputStream is) { 83 | java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A"); 84 | return s.hasNext() ? s.next() : ""; 85 | } 86 | } 87 | --------------------------------------------------------------------------------