TerrificTable55

HWID thing

Oct 15th, 2022
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.73 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.  
  14. public class Main {
  15.     public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException {
  16.  
  17.         String command = "wmic baseboard get serialnumber";
  18.         StringBuilder serialNumber = new StringBuilder();
  19.  
  20.         try {
  21.             Process SerialNumberProcess = Runtime.getRuntime().exec(command);
  22.             InputStreamReader ISR = new InputStreamReader(SerialNumberProcess.getInputStream());
  23.             BufferedReader br = new BufferedReader(ISR);
  24.             String line;
  25.             while ((line = br.readLine()) != null) {
  26.                 serialNumber.append(line);
  27.             }
  28.             SerialNumberProcess.waitFor();
  29.             br.close();
  30.         } catch (Exception e) {
  31.             e.printStackTrace();
  32.         }
  33.  
  34.  
  35.         StringBuilder hwid_builder = new StringBuilder();
  36.         KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
  37.         keyGen.initialize(1024*4);
  38.         KeyPair pair = keyGen.generateKeyPair();
  39.  
  40.         hwid_builder.append(cipherEncrypt("HWID by TerrificTable", "RSA/ECB/PKCS1Padding", pair));
  41.         hwid_builder.append(hash(Arrays.toString(add(hwid_builder.toString().getBytes(), serialNumber.toString().getBytes())), "SHA-512"));
  42.  
  43.         String hashText = hash(new String(foreach(hwid_builder.toString().getBytes())), "SHA-512");
  44.         String hwid = Base64.getEncoder().encodeToString(Base64.getEncoder().encode(hashText.getBytes()));
  45.  
  46.  
  47.         System.out.println(hwid);
  48.     }
  49.  
  50.  
  51.     public static String cipherEncrypt(String s, String algorithm, KeyPair pair) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
  52.         Cipher cipher = Cipher.getInstance(algorithm);
  53.         cipher.init(Cipher.ENCRYPT_MODE, pair.getPublic());
  54.         return cipherEncrypt(s, cipher);
  55.     }
  56.     public static String cipherEncrypt(String s, Cipher cipher) throws IllegalBlockSizeException, BadPaddingException {
  57.         return Arrays.toString(cipher.doFinal(s.getBytes()));
  58.     }
  59.  
  60.  
  61.     private static byte[] add(byte[] a, byte[] b) {
  62.         int aLen = a.length;
  63.         int bLen = b.length;
  64.         int cLen = aLen + bLen;
  65.         byte[] c = new byte[cLen];
  66.         for (int i=0; i < cLen; i++)
  67.             c[i] = (byte) (a[i % aLen] ^ b[i % bLen]);
  68.         return c;
  69.     }
  70.  
  71.     private static char[] foreach(byte[] bytes) {
  72.         char[] chars = new char[bytes.length * 100];
  73.         for (int i=0; i < bytes.length; i++) chars[i] = (char) bytes[i];
  74.         for (int aChar : chars)
  75.             chars[aChar] =
  76.                     (char) (chars[aChar] ^ (aChar ^ chars[aChar]) + (int)(Math.random() * 100 / Math.random()));
  77.         return chars;
  78.     }
  79.  
  80.     public static String hash(String s, String algorithm) throws NoSuchAlgorithmException {
  81.         return hash(s, algorithm, "0");
  82.     }
  83.  
  84.     public static String hash(String s, String algorithm, String replacement) throws NoSuchAlgorithmException {
  85.         MessageDigest hasher = MessageDigest.getInstance(algorithm);
  86.         byte[] hashtext = hasher.digest(s.getBytes());
  87.         BigInteger bigInt = new BigInteger(1, hashtext);
  88.         StringBuilder res = new StringBuilder(bigInt.toString(32));
  89.         while (res.length() < 128) res.insert(0, replacement);
  90.         return res.toString();
  91.     }
  92. }
  93.  
  94.  
Add Comment
Please, Sign In to add comment