Skip to content

Instantly share code, notes, and snippets.

@cwarden
Created March 30, 2012 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwarden/2253337 to your computer and use it in GitHub Desktop.
Save cwarden/2253337 to your computer and use it in GitHub Desktop.
/* de-obfuscate kettle passwords */
import java.math.BigInteger;
public class Decr {
private static final int RADIX = 16;
private static final String SEED = "0933910847463829827159347601486730416058";
public static void main(String[] args) {
if (args.length!=1) {
printOptions();
System.exit(9);
}
String obfuscated = args[0];
String password = Decr.decryptPassword(obfuscated);
System.out.println(password);
System.exit(0);
}
public static final String decryptPassword(String encrypted) {
if (encrypted==null) return "";
if (encrypted.length()==0) return "";
BigInteger bi_confuse = new BigInteger(SEED);
try {
BigInteger bi_r1 = new BigInteger(encrypted, RADIX);
BigInteger bi_r0 = bi_r1.xor(bi_confuse);
return new String(bi_r0.toByteArray());
} catch(Exception e) {
return "";
}
}
private static void printOptions() {
System.err.println("decr usage:\n");
System.err.println(" decr <obfuscated>");
System.err.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment