|
|
@@ -0,0 +1,38 @@ |
|
|
#!/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}'" |
|
|
} |