-
Notifications
You must be signed in to change notification settings - Fork 1
/
decryptCf11Dsn.java
45 lines (32 loc) · 1.32 KB
/
decryptCf11Dsn.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import coldfusion.util.PasswordUtils;
import java.io.*;
import java.util.Properties;
import fr.prados.xpath4sax.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
public class decryptCf11Dsn {
static String pass="";
public static void main(String[] args) throws FileNotFoundException,IOException,XPathSyntaxException,ParserConfigurationException,SAXException{
String pth=args[0] + File.separatorChar + "lib" + File.separatorChar + "seed.properties";
File seedFile = new File( pth );
Properties prop = new Properties();
prop.load(new FileInputStream(seedFile));
if( args[1].indexOf("-p") == -1 ){
XPathXMLHandler handler=new XPathXMLHandler()
{
@Override
public void findXpathNode(SAXXPath xpath, Object node)
{
pass= ((ElementWrapper)node).getFirstChild().getTextContent();
}
};
handler.setXPaths(XPathXMLHandler.toXPaths("//var[@name='"+args[1]+"']/struct/var[@name='password']/string"));
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(new FileInputStream( new File( args[0] + File.separatorChar + "lib" + File.separatorChar + "neo-datasource.xml" ) ) , handler);
}else{
pass=args[2];
}
String str= PasswordUtils.decryptPassword( pass, prop.getProperty("seed") );
System.out.println( str );
}
}