· 6 years ago · Mar 12, 2019, 03:36 PM
1package ru.dudkoliza;
2
3import java.nio.charset.StandardCharsets;
4import java.security.InvalidAlgorithmParameterException;
5import java.security.InvalidKeyException;
6import java.security.NoSuchAlgorithmException;
7import java.security.spec.InvalidKeySpecException;
8import java.security.spec.KeySpec;
9import java.util.Base64;
10import javax.crypto.BadPaddingException;
11import javax.crypto.Cipher;
12import javax.crypto.IllegalBlockSizeException;
13import javax.crypto.NoSuchPaddingException;
14import javax.crypto.SecretKey;
15import javax.crypto.SecretKeyFactory;
16import javax.crypto.spec.IvParameterSpec;
17import javax.crypto.spec.PBEKeySpec;
18import javax.crypto.spec.SecretKeySpec;
19
20public class Main {
21
22 public static void main(String[] args) throws Exception {
23 String token = "cWKz2Ajf8LPntPBqGdwIZT-3TxXKw40wCahYJRPGKzWzz2mHacBCTnoy43LOc1bZ0OoaVK734Azc_LsQd--Hl_VI_tCjF4-67-7-frheoK5m5ViaShI9n--nfAex2Jin";
24 for (int i = 0; i < 10; ++i) {
25 for (int j = 0; j < 10; ++j) {
26 for (int k = 0; k < 10; ++k) {
27 for (int l = 0; l < 10; ++l) {
28 try {
29 byte[] a = decrypt(Base64.getUrlDecoder().decode(token), Integer.toString(i) + Integer.toString(j) + Integer.toString(k) + Integer.toString(l));
30 System.out.println(new String(a, StandardCharsets.UTF_8));
31 } catch (BadPaddingException e) {
32
33 }
34 }
35 }
36 }
37 }
38 }
39
40 private static byte[] decrypt(byte[] encrypted_bytes, String password) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
41 byte[] iv_bytes = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
42 byte[] salt = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
43 SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
44 KeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 1024, 128);
45 SecretKey tmp = factory.generateSecret(spec);
46 SecretKeySpec secret_key = new SecretKeySpec(tmp.getEncoded(), "AES");
47 Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
48 IvParameterSpec iv_parameter_spec = new IvParameterSpec(iv_bytes);
49 cipher.init(Cipher.DECRYPT_MODE, secret_key, iv_parameter_spec);
50 return cipher.doFinal(encrypted_bytes);
51 }
52
53}