一个N久的服务,维护的人换了好几个了,今天忽然想进去看看里面datasource,一问没人知道密码。。。因而就上网小抄了一段程序,用于破解weblogic console的用户名和密码。html
首先在weblogic安装目录下找到两个文件SerializedSystemIni.dat、 boot.properties,位置你们能够本身搜索一下。java
而后上代码:node
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.*; /** * * weblogic密码忘记破解方法 * 获取到weblogic安装目录下的两个文件 SerializedSystemIni.dat、 boot.properties * (weblogic8上面两个文件在的bea/user_projects/domains/mydomain 目录下) * (welogic10 SerializedSystemIni.dat在bea/user_projects/domains/base_domain/security中) * (welogic10 boot.properties在bea/user_projects/domains/base_domain/servers/AdminServer/security中) * 加入weblogic.jar (weblogic安装目录中寻找,不一样版本有可能不一样)文件添加至构建路径, * welogic10若是运行还缺乏别的类能够把weblogic的/wlserver_10.3/server/lib下的jar都添加到构建路径 * @author * */ public class WebLogicDecryptor { private static final String PREFIX = "{AES}";//查看boot.properties文件 加密方式{3DES}或者{AES} 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 { //E:/weblogic10 中的SerializedSystemIni.dat存放目录 ces = new ClearOrEncryptedService(SerializedSystemIni.getEncryptionService(new File("E:/weblogic10").getAbsolutePath())); File file = new File("E:/weblogic10/boot.properties"); if (file.getName().endsWith(".xml")) {//有些多是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"); } }
以上代码来自http://www.cnblogs.com/alfredxiao/archive/2010/09/16/weblogic_lost_password2.html稍加修改。web
直接运行代码(注意代码中需加入weblogic.jar包,weblogic版本不同可能加的jar包不一样)dom
查看打印结果:ui
其实 boot.properties里面存放的就是加密过的用户名密码,SerializedSystemIni.dat里面存放的是加解密的密匙来的。加密
若是能在weblogic环境下运行上面代码就最好了,若是不能则要注意SerializedSystemIni.dat的拷贝了,特别是从Linux环境下拷贝过来的时候。lua
上面方法试过weblogic8和10都是没有问题的。code