-
-
Save jon-strayer/86114e8dc2669c2b5288f2ae988941b6 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}'" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment