Advertisement
Guest User

Minecraft lastlogin decryptor

a guest
Jun 19th, 2012
2,540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. package decryptmc;
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5. import javax.crypto.*;
  6. import javax.crypto.spec.*;
  7.  
  8. public class DecryptMC {
  9.     public static void main(String[] args) throws Exception {
  10.         System.out.println(DecryptMC());
  11.     }
  12.  
  13.     public static String DecryptMC() throws Exception {
  14.         String output = null;
  15.         Random random = new Random(43287234L);
  16.         byte[] salt = new byte[8];
  17.         random.nextBytes(salt);
  18.         PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
  19.         SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES")
  20.                 .generateSecret(new PBEKeySpec("passwordfile".toCharArray()));
  21.         Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
  22.         cipher.init(2, pbeKey, pbeParamSpec);
  23.         if (getWorkingDirectory().exists()) {
  24.             File lastLogin = new File(getWorkingDirectory(), "lastlogin");
  25.             DataInputStream dis = new DataInputStream(new CipherInputStream(
  26.                     new FileInputStream(lastLogin), cipher));
  27.             output = dis.readUTF() + " | " + dis.readUTF();
  28.             dis.close();
  29.         }
  30.         return output;
  31.     }
  32.  
  33.     public static File getWorkingDirectory() {
  34.         String userHome = System.getProperty("user.home", ".");
  35.         File workingDirectory;
  36.         switch (getPlatform()) {
  37.         case 1:
  38.         case 2:
  39.             workingDirectory = new File(userHome, ".minecraft/");
  40.             break;
  41.         case 3:
  42.             String applicationData = System.getenv("APPDATA");
  43.             if (applicationData != null)
  44.                 workingDirectory = new File(applicationData, ".minecraft/");
  45.             else
  46.                 workingDirectory = new File(userHome, ".minecraft/");
  47.             break;
  48.         case 4:
  49.             workingDirectory = new File(userHome,
  50.                     "Library/Application Support/minecraft");
  51.             break;
  52.         default:
  53.             workingDirectory = new File(userHome, ".minecraft/");
  54.         }
  55.         return workingDirectory;
  56.     }
  57.  
  58.     private static int getPlatform() {
  59.         String osName = System.getProperty("os.name").toLowerCase();
  60.         if (osName.contains("linux"))
  61.             return 1;
  62.         if (osName.contains("unix"))
  63.             return 1;
  64.         if (osName.contains("solaris"))
  65.             return 2;
  66.         if (osName.contains("sunos"))
  67.             return 2;
  68.         if (osName.contains("win"))
  69.             return 3;
  70.         if (osName.contains("mac"))
  71.             return 4;
  72.         return 5;
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement