Skip to content

Instantly share code, notes, and snippets.

@barneygale
Created September 30, 2011 21:11
Show Gist options
  • Select an option

  • Save barneygale/1254983 to your computer and use it in GitHub Desktop.

Select an option

Save barneygale/1254983 to your computer and use it in GitHub Desktop.
import java.io.*;
import javax.crypto.*;
import java.util.*;
import javax.crypto.spec.*;
import java.net.*;
public class decrypt {
public decrypt() {
}
public static void main(String[] args) {
try {
//Part 1: Grab the username and password from lastlogin
File lastLogin = new File(args[0]);
String DESpassword = "passwordfile";
byte[] salt = { 12, -99, 74, -28, 30, -125, 21, -4 };
PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(DESpassword.toCharArray()));
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
cipher.init(2, pbeKey, pbeParamSpec);
DataInputStream dis;
dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
String username = dis.readUTF();
String password = dis.readUTF();
dis.close();
//Part 2: Log in
URL url = new URL ("https://login.minecraft.net/");
String postdata = "user="+URLEncoder.encode(username, "UTF-8")+"&password="+URLEncoder.encode(password, "UTF-8")+"&version=1000";
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
//Write post data
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
out.write(postdata);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String result = in.readLine();
System.out.println(result.replace(":", "\n"));
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment