Nan*_*ada 37 java oracle jdeveloper oracle-sqldeveloper
因为我需要实现类似的解决方案,所以我非常感兴趣的是要了解这里使用哪种技术来保存合理的数据.这是一个示例连接配置和生成的导出片段:
Oracle SQL Developer Connections http://i44.tinypic.com/2lcwpkg.gif
<?xml version = '1.0' encoding = 'UTF-8'?>
<References xmlns="http://xmlns.oracle.com/adf/jndi">
<Reference name="My Connection" className="oracle.jdeveloper.db.adapter.DatabaseProvider" xmlns="">
<Factory className="oracle.jdeveloper.db.adapter.DatabaseProviderFactory"/>
<RefAddresses>
<StringRefAddr addrType="user">
<Contents>username</Contents>
</StringRefAddr>
<StringRefAddr addrType="password">
<Contents>054D4844D8549C0DB78EE1A98FE4E085B8A484D20A81F7DCF8</Contents>
</StringRefAddr>
<SKIPPED />
</RefAddresses>
</Reference>
</References>
Run Code Online (Sandbox Code Playgroud)
任何建议都会非常感激.
Ada*_*ter 46
对于好奇的人,你实际看到的是与加密密码连接的密钥.例如,我尝试使用以下方法加密密码"SAILBOAT":
DatabaseProviderHelper.goingOut("SAILBOAT")
Run Code Online (Sandbox Code Playgroud)
在这个特定的例子中,结果是:
0527C290B40C41D71139B5E7A4446E94D7678359087249A463
第一个字节是常量:
05
接下来的8个字节表示随机生成的密钥(对于DES密码):
27C290B40C41D711
其余字节是加密密码:
39B5E7A4446E94D7678359087249A463
因此,要解密密码,您只需使用:
public static byte[] decryptPassword(byte[] result) throws GeneralSecurityException {
byte constant = result[0];
if (constant != 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);
}
Run Code Online (Sandbox Code Playgroud)
Kor*_*rny 11
请注意,Tim上面的密码哈希不适用于"apps_ro" - 可能是他剪切并粘贴在错误的地方......我不会发布真实密码,以防万一他不想共享!
我遇到了类似的问题,试图集中存储我的数据库凭据(对于非安全数据库!),然后导出sql developer xml文件.我不知道算法是什么 - 但是,你真的不需要知道算法,因为你可以自己调用Oracle java API.如果您有SQLDeveloper,只需获取正确的Jar文件:
cp /Applications/SQLDeveloper.App/Contents/Resources/sqldeveloper/BC4J/lib/db-ca.jar .
cp /Applications/SQLDeveloper.App/Contents/Resources/sqldeveloper/jlib/ojmisc.jar .
Run Code Online (Sandbox Code Playgroud)
然后在Java应用程序中加载它们,或像我一样使用类似JRuby的东西:
$jirb
> require 'java'
> require 'ojmisc.jar'
> require 'db-ca.jar'
> Java::oracle.jdevimpl.db.adapter.DatabaseProviderHelper.goingOut("password")
=> "059D45F5EB78C99875F6F6E3C3F66F71352B0EB4668D7DEBF8"
> Java::oracle.jdevimpl.db.adapter.DatabaseProviderHelper.goingOut("password")
=> "055CBB58B69B477714239157A1F95FDDD6E5B453BEB69E5D49"
> Java::oracle.jdevimpl.db.adapter.DatabaseProviderHelper.comingIn("059D45F5EB78C99875F6F6E3C3F66F71352B0EB4668D7DEBF8")
=> "password"
> Java::oracle.jdevimpl.db.adapter.DatabaseProviderHelper.comingIn("055CBB58B69B477714239157A1F95FDDD6E5B453BEB69E5D49")
=> "password"
Run Code Online (Sandbox Code Playgroud)
请注意,算法,无论它是什么,都有一个随机因子,因此使用两次相同的密码可以生成两个不同的十六进制字符串.
这个解决方案对我很有用...复制自: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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
鉴于解决方案太旧,只适用于版本2.x但现在不适用.因为Oracle SQL Developer在版本3.x和4.x中更改了加密算法.
版本3
密码以加密方式存储在以下位置的connections.xml文件中:
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
Run Code Online (Sandbox Code Playgroud)
版本4
密码以前面提到的connections.xml文件加密存储,但加密密钥在product-preferences.xml文件中使用机器唯一值db.system.id,可在此处访问:
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
Run Code Online (Sandbox Code Playgroud)
要解密最新的加密文件,您可以使用为SQL Developer 显示密码扩展名.或使用SQL Developer密码解密器解密文件
小智 5
与kornelissietsma相同的代码已经给出了,但写在java上:
import oracle.jdevimpl.db.adapter.DatabaseProviderHelper;
class Decode {
String pass = "";
public Decode() {
pass = DatabaseProviderHelper.comingIn("HASH");
System.out.println(pass);
}
public static void main(String[] args){
new Decode();
}
}
Run Code Online (Sandbox Code Playgroud)
可以执行如下:
# javac -classpath .:/full/path/to/sqldeveloper/BC4J/lib/db-ca.jar:/full/path/to/sqldeveloper/jlib/ojmisc.jar sqldeveloper_hash_decode.java
# java -classpath .:/full/path/to/sqldeveloper/BC4J/lib/db-ca.jar:/full/path/to/sqldeveloper/jlib/ojmisc.jar Decode
Run Code Online (Sandbox Code Playgroud)
遗憾的是,其他答案中描述的方法在SQL Developer 4.x中不起作用.有适用于3.x和4.x版本的扩展,它非常易于使用:
https://github.com/tomecode/show-me-password-sqldev-jdev