TerrificTable55

Untitled

Oct 15th, 2022 (edited)
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.97 KB | None | 0 0
  1. public static String genHWID(KeyPair pair) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
  2.         String command = "wmic baseboard get serialnumber";
  3.         StringBuilder serialNumber = new StringBuilder();
  4.  
  5.         try {
  6.             Process SerialNumberProcess = Runtime.getRuntime().exec(command);
  7.             InputStreamReader ISR = new InputStreamReader(SerialNumberProcess.getInputStream());
  8.             BufferedReader br = new BufferedReader(ISR);
  9.             String line;
  10.             while ((line = br.readLine()) != null) {
  11.                 serialNumber.append(line);
  12.             }
  13.             SerialNumberProcess.waitFor();
  14.             br.close();
  15.         } catch (Exception e) {
  16.             e.printStackTrace();
  17.         }
  18.  
  19.         StringBuilder hwid_builder = new StringBuilder();
  20.  
  21.         hwid_builder.append(pair.getPublic());
  22.         hwid_builder.append(hash(Arrays.toString(add(hwid_builder.toString().getBytes(), serialNumber.toString().getBytes())), "SHA-512"));
  23.  
  24.         String hashText = hash(new String(foreach(hwid_builder.toString().getBytes())), "SHA-512");
  25.         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()))) : repeat((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(), 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");
  26.         return hwid.replace("null", hwid);
  27.     }
  28.  
  29.     public static String repeat(String in, int x) {
  30.         for (int i=0; i < x; i++) in += in;
  31.         return in;
  32.     }
  33.  
  34.  
  35.     private static byte[] add(byte[] a, byte[] b) {
  36.         int aLen = a.length;
  37.         int bLen = b.length;
  38.         int cLen = aLen + bLen;
  39.         byte[] c = new byte[cLen];
  40.         for (int i=0; i < cLen; i++)
  41.             c[i] = (byte) (a[i % aLen] ^ b[i % bLen]);
  42.         return c;
  43.     }
  44.  
  45.     private static char[] foreach(byte[] bytes) {
  46.         char[] chars = new char[bytes.length * 10000];
  47.         for (int i=0; i < bytes.length; i++) chars[i] = (char) bytes[i];
  48.         for (int aChar : chars)
  49.             chars[aChar] =
  50.                     (char) (chars[aChar] ^ (aChar ^ chars[aChar]) + aChar);
  51.         return chars;
  52.     }
  53.  
  54.     public static String hash(String s, String algorithm) throws NoSuchAlgorithmException {
  55.         return hash(s, algorithm, "0");
  56.     }
  57.  
  58.     public static String hash(String s, String algorithm, String replacement) throws NoSuchAlgorithmException {
  59.         MessageDigest hasher = MessageDigest.getInstance(algorithm);
  60.         byte[] hashtext = hasher.digest(s.getBytes());
  61.         BigInteger bigInt = new BigInteger(1, hashtext);
  62.         StringBuilder res = new StringBuilder(bigInt.toString(32));
  63.         while (res.length() < 128) res.insert(0, replacement);
  64.         return res.toString();
  65.     }
Add Comment
Please, Sign In to add comment