Created
June 19, 2017 11:52
-
-
Save marcgeld/e484fe918d8cc14358edadd3f3ad3295 to your computer and use it in GitHub Desktop.
Decode DbVisualizer settings password. (https://www.dbvis.com/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
import javax.crypto.SecretKeyFactory | |
import javax.crypto.SecretKey | |
import javax.crypto.Cipher | |
import javax.crypto.spec.PBEParameterSpec | |
import javax.crypto.spec.PBEKeySpec | |
import java.util.Base64 | |
import java.util.Base64.Decoder | |
import static java.nio.charset.StandardCharsets.UTF_8 | |
String password = "qinda" | |
int iterations = 10 | |
// -114, 18, 57, -100, 7, 114, 111, 90] | |
def salt = [ -114, 18, 57, -100, 7, 114, 111, 90] as byte[] | |
PBEKeySpec keySpec = new PBEKeySpec( password.toCharArray() ) | |
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance( "PBEWithMD5AndDES" ) | |
SecretKey key = keyFactory.generateSecret( keySpec ) | |
//Create parameters from the salt and an arbitrary number of iterations: | |
PBEParameterSpec pbeParamSpec = new PBEParameterSpec( salt, iterations ) | |
Cipher cipher = Cipher.getInstance( "PBEWithMD5AndDES" ) | |
cipher.init( Cipher.DECRYPT_MODE, key, pbeParamSpec ) | |
Closure<String> decryptPw = { String encryptedPw -> | |
byte[] decodedTmp = Base64.getDecoder().decode( encryptedPw ) | |
byte[] decryptedbytes = cipher.doFinal( decodedTmp ) | |
return new String ( decryptedbytes, UTF_8 ) | |
} | |
def dbvis_config = "${System.getProperty('user.home')}/.dbvis/config70/dbvis.xml" | |
def xml = new XmlSlurper().parse( dbvis_config ) | |
xml."Databases".children().each { node -> | |
encryptedPassword = decryptPw( node.Password as String ) | |
println "'${node.Alias}', UserId: '${node.Userid}', Password: '${encryptedPassword}', url: '${node.Url}'" | |
} |
Yes, it is quite useful. Thanks for confirming it works with newer versions of DbVis.
I'm happy to report that it also works with DbVis v12.0.7 on macOS Catalina (v10.15.7). Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works with DbVis v11.0.3. Thank you!