TerrificTable55

Untitled

Oct 15th, 2022 (edited)
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.51 KB | None | 0 0
  1. package xyz.terrific;
  2.  
  3. import javax.crypto.BadPaddingException;
  4. import javax.crypto.Cipher;
  5. import javax.crypto.IllegalBlockSizeException;
  6. import javax.crypto.NoSuchPaddingException;
  7. import java.io.BufferedReader;
  8. import java.io.InputStreamReader;
  9. import java.math.BigInteger;
  10. import java.security.*;
  11. import java.util.Arrays;
  12. import java.util.Base64;
  13. import java.util.Objects;
  14.  
  15. public class Main {
  16.     public static void main(String[] args) throws NoSuchAlgorithmException {
  17.  
  18.         String[] hwids = new String[16];
  19.  
  20.  
  21.         KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
  22.         keyGen.initialize(1024*4);
  23.         KeyPair pair = keyGen.generateKeyPair();
  24.  
  25.  
  26.         for (int i=0; i < 16; i++) {
  27.             try {
  28.                 hwids[i] = genHWID(pair);
  29.                 System.out.printf("%d: %s\n", i, hwids[i]);
  30.             } catch (NoSuchPaddingException | IllegalBlockSizeException | NoSuchAlgorithmException |
  31.                      BadPaddingException | InvalidKeyException e) {
  32.                 throw new RuntimeException(e);
  33.             }
  34.         }
  35.  
  36.         for (String hwid : hwids) {
  37.             for (String hwid2 : hwids) {
  38.                 if (!Objects.equals(hwid, hwid2)) {
  39.                     System.out.printf("hwid (%d): %s\nhwid2 (%d): %s\nNot equal", findIndex(hwid, hwids), hwid, findIndex(hwid2, hwids), hwid2);
  40.                     break;
  41.                 }
  42.             }
  43.         }
  44.  
  45.     }
  46.  
  47.     public static int findIndex(String a, String[] b) {
  48.         int i = 0;
  49.         for (String c : b) {
  50.             if (a.equals(c))
  51.                 return i;
  52.             i++;
  53.         }
  54.         return -1;
  55.     }
  56.  
  57.  
  58.     public static String genHWID(KeyPair pair) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
  59.         String command = "wmic baseboard get serialnumber";
  60.         StringBuilder serialNumber = new StringBuilder();
  61.  
  62.         try {
  63.             Process SerialNumberProcess = Runtime.getRuntime().exec(command);
  64.             InputStreamReader ISR = new InputStreamReader(SerialNumberProcess.getInputStream());
  65.             BufferedReader br = new BufferedReader(ISR);
  66.             String line;
  67.             while ((line = br.readLine()) != null) {
  68.                 serialNumber.append(line);
  69.             }
  70.             SerialNumberProcess.waitFor();
  71.             br.close();
  72.         } catch (Exception e) {
  73.             e.printStackTrace();
  74.         }
  75.  
  76.         StringBuilder hwid_builder = new StringBuilder();
  77.  
  78.         hwid_builder.append(pair.getPublic());
  79.         hwid_builder.append(hash(Arrays.toString(add(hwid_builder.toString().getBytes(), serialNumber.toString().getBytes())), "SHA-512"));
  80.  
  81.         String hashText = hash(new String(foreach(hwid_builder.toString().getBytes())), "SHA-512");
  82.         String hwid = (hash(new String(foreach(new String(new char[] { 0x48, 0x57, 0x49, 0x44, 0x20, 0x62, 0x79, 0x20, 0x54, 0x65, 0x72, 0x72, 0x69, 0x66, 0x69, 0x63, 0x54, 0x61, 0x62, 0x6C, 0x65 }).getBytes())), "SHA-512") + Base64.getEncoder().encodeToString(Base64.getEncoder().encode(hashText.getBytes()))).startsWith(hash(new String(foreach(new String(new char[] { 0x48, 0x57, 0x49, 0x44, 0x20, 0x62, 0x79, 0x20, 0x54, 0x65, 0x72, 0x72, 0x69, 0x66, 0x69, 0x63, 0x54, 0x61, 0x62, 0x6C, 0x65 }).getBytes())), "SHA-512")) ? (hash(new String(foreach(new String(new char[] { 0x48, 0x57, 0x49, 0x44, 0x20, 0x62, 0x79, 0x20, 0x54, 0x65, 0x72, 0x72, 0x69, 0x66, 0x69, 0x63, 0x54, 0x61, 0x62, 0x6C, 0x65 }).getBytes())), "SHA-512") + Base64.getEncoder().encodeToString(Base64.getEncoder().encode(hashText.getBytes()))) : (hash(new String(foreach(new String(new char[] { 0x48, 0x57, 0x49, 0x44, 0x20, 0x62, 0x79, 0x20, 0x54, 0x65, 0x72, 0x72, 0x69, 0x66, 0x69, 0x63, 0x54, 0x61, 0x62, 0x6C, 0x65 }).getBytes())), "SHA-512") + Base64.getEncoder().encodeToString(Base64.getEncoder().encode(hashText.getBytes()))).toLowerCase().repeat(10).replace(hash(new String(foreach(new String(new char[] { 0x48, 0x57, 0x49, 0x44, 0x20, 0x62, 0x79, 0x20, 0x54, 0x65, 0x72, 0x72, 0x69, 0x66, 0x69, 0x63, 0x54, 0x61, 0x62, 0x6C, 0x65 }).getBytes())), "SHA-512") + Base64.getEncoder().encodeToString(Base64.getEncoder().encode(hashText.getBytes())), "null");
  83.         return hwid.replace("null", hwid);
  84.     }
  85.  
  86.  
  87.     private static byte[] add(byte[] a, byte[] b) {
  88.         int aLen = a.length;
  89.         int bLen = b.length;
  90.         int cLen = aLen + bLen;
  91.         byte[] c = new byte[cLen];
  92.         for (int i=0; i < cLen; i++)
  93.             c[i] = (byte) (a[i % aLen] ^ b[i % bLen]);
  94.         return c;
  95.     }
  96.  
  97.     private static char[] foreach(byte[] bytes) {
  98.         char[] chars = new char[bytes.length * 10000];
  99.         for (int i=0; i < bytes.length; i++) chars[i] = (char) bytes[i];
  100.         for (int aChar : chars)
  101.             chars[aChar] =
  102.                     (char) (chars[aChar] ^ (aChar ^ chars[aChar]) + aChar);
  103.         return chars;
  104.     }
  105.  
  106.     public static String hash(String s, String algorithm) throws NoSuchAlgorithmException {
  107.         return hash(s, algorithm, "0");
  108.     }
  109.  
  110.     public static String hash(String s, String algorithm, String replacement) throws NoSuchAlgorithmException {
  111.         MessageDigest hasher = MessageDigest.getInstance(algorithm);
  112.         byte[] hashtext = hasher.digest(s.getBytes());
  113.         BigInteger bigInt = new BigInteger(1, hashtext);
  114.         StringBuilder res = new StringBuilder(bigInt.toString(32));
  115.         while (res.length() < 128) res.insert(0, replacement);
  116.         return res.toString();
  117.     }
  118. }
  119.  
  120.  
Add Comment
Please, Sign In to add comment