Does anybody know what encrypting technique is JDeveloper/SQL Developer using to persist credentials?

后端 未结 11 2100
广开言路
广开言路 2020-12-22 18:46

I\'d be more than interesting for me to understand which technique is being used here to persist sensible data since I\'m needing to implement a similar solution. Here\'s a

相关标签:
11条回答
  • 2020-12-22 19:40

    This solution works great for me... Copied from: http://www.mischiefblog.com/?p=912

    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.security.*;
    
    /**
     * Decrypt passwords stored in Oracle SQL Developer. This is intended for
     * password recovery.
     * 
     * Passwords are stored in
     * ~/.sqldeveloper/system2.1.1.64.39/o.jdeveloper.db.connection
     * .11.1.1.2.36.55.30/connections.xml
     */
    public class Decrypt {
        public static byte[] decryptPassword(byte[] result)
                throws GeneralSecurityException {
            byte constant = result[0];
            if (constant != (byte) 5) {
                throw new IllegalArgumentException();
            }
    
            byte[] secretKey = new byte[8];
            System.arraycopy(result, 1, secretKey, 0, 8);
    
            byte[] encryptedPassword = new byte[result.length - 9];
            System.arraycopy(result, 9, encryptedPassword, 0,
                    encryptedPassword.length);
    
            byte[] iv = new byte[8];
            for (int i = 0; i < iv.length; i++) {
                iv[i] = 0;
            }
    
            Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(secretKey, "DES"),
                    new IvParameterSpec(iv));
            return cipher.doFinal(encryptedPassword);
        }
    
        public static void main(String[] args) {
            if (args.length != 1) {
                System.err.println("Usage:  java Decrypt <password>");
                System.exit(1);
            }
    
            if (args[0].length() % 2 != 0) {
                System.err
                        .println("Password must consist of hex pairs.  Length is odd (not even).");
                System.exit(2);
            }
    
            byte[] secret = new byte[args[0].length() / 2];
            for (int i = 0; i < args[0].length(); i += 2) {
                String pair = args[0].substring(i, i + 2);
                secret[i / 2] = (byte) (Integer.parseInt(pair, 16));
            }
    
            try {
                System.out.println(new String(decryptPassword(secret)));
            } catch (GeneralSecurityException e) {
                e.printStackTrace();
                System.exit(3);
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-22 19:40

    I don't know, but I wouldn't be surprised if it was DBMS_OBFUSCATION_TOOLKIT being used something like this:

    l_hash := dbms_obfuscation_toolkit.md5(input_string=>:username||:password);
    
    0 讨论(0)
  • 2020-12-22 19:44

    Given solution is too old and only works with version 2.x but not now. because Oracle SQL Developer, changed the encryption algorithm in version 3.x and 4.x.

    Version 3

    Passwords are stored encrypted in the connections.xml file in those locations:

    Windows: C:\Users\<USER>\AppData\Roaming\SQL Developer\system<VERSION>\o.jdeveloper.db.connection.<VERSION>\connections.xml
    Linux: ~/.sqldeveloper/system<VERSION>/o.jdeveloper.db.connection.<VERSION>/connections.xml
    

    Version 4

    Passwords are stored encrypted in the aforementioned connections.xml file but the encryption key uses a machine-unique value db.system.id in the product-preferences.xml file accessible here:

    Windows: C:\Users\<USER>\AppData\Roaming\SQL Developer\system<VERSION>\o.sqldeveloper.<VERSION>\product-preferences.xml
    Linux: ~/.sqldeveloper/system<VERSION>/o.sqldeveloper.<VERSION>/product-preferences.xml
    

    To decrypt latest encrypted file you can use Show me password extension for SQL Developer. Or decrypt file with SQL Developer password decryptor

    0 讨论(0)
  • 2020-12-22 19:46

    Methods described in other answers unfortunately doesn’t work in SQL Developer 4.x. There’s extension that works on both 3.x and 4.x versions and it’s very easy to use:

    https://github.com/tomecode/show-me-password-sqldev-jdev

    0 讨论(0)
  • 2020-12-22 19:46

    FYI the password 'apps_ro' encrypts as:

         <StringRefAddr addrType="password">
            <Contents>051DC8A88C574538CC4AEE32D326E9480659C06CEC271EA6D7</Contents>
         </StringRefAddr>
    
    0 讨论(0)
提交回复
热议问题