Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package xyz.terrific;
- import javax.crypto.BadPaddingException;
- import javax.crypto.Cipher;
- import javax.crypto.IllegalBlockSizeException;
- import javax.crypto.NoSuchPaddingException;
- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.math.BigInteger;
- import java.security.*;
- import java.util.Arrays;
- import java.util.Base64;
- import java.util.Objects;
- public class Main {
- public static void main(String[] args) throws NoSuchAlgorithmException {
- String[] hwids = new String[16];
- KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
- keyGen.initialize(1024*4);
- KeyPair pair = keyGen.generateKeyPair();
- for (int i=0; i < 16; i++) {
- try {
- hwids[i] = genHWID(pair);
- System.out.printf("%d: %s\n", i, hwids[i]);
- } catch (NoSuchPaddingException | IllegalBlockSizeException | NoSuchAlgorithmException |
- BadPaddingException | InvalidKeyException e) {
- throw new RuntimeException(e);
- }
- }
- for (String hwid : hwids) {
- for (String hwid2 : hwids) {
- if (!Objects.equals(hwid, hwid2)) {
- System.out.printf("hwid (%d): %s\nhwid2 (%d): %s\nNot equal", findIndex(hwid, hwids), hwid, findIndex(hwid2, hwids), hwid2);
- break;
- }
- }
- }
- }
- public static int findIndex(String a, String[] b) {
- int i = 0;
- for (String c : b) {
- if (a.equals(c))
- return i;
- i++;
- }
- return -1;
- }
- public static String genHWID(KeyPair pair) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
- String command = "wmic baseboard get serialnumber";
- StringBuilder serialNumber = new StringBuilder();
- try {
- Process SerialNumberProcess = Runtime.getRuntime().exec(command);
- InputStreamReader ISR = new InputStreamReader(SerialNumberProcess.getInputStream());
- BufferedReader br = new BufferedReader(ISR);
- String line;
- while ((line = br.readLine()) != null) {
- serialNumber.append(line);
- }
- SerialNumberProcess.waitFor();
- br.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- StringBuilder hwid_builder = new StringBuilder();
- hwid_builder.append(pair.getPublic());
- hwid_builder.append(hash(Arrays.toString(add(hwid_builder.toString().getBytes(), serialNumber.toString().getBytes())), "SHA-512"));
- String hashText = hash(new String(foreach(hwid_builder.toString().getBytes())), "SHA-512");
- 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");
- return hwid.replace("null", hwid);
- }
- private static byte[] add(byte[] a, byte[] b) {
- int aLen = a.length;
- int bLen = b.length;
- int cLen = aLen + bLen;
- byte[] c = new byte[cLen];
- for (int i=0; i < cLen; i++)
- c[i] = (byte) (a[i % aLen] ^ b[i % bLen]);
- return c;
- }
- private static char[] foreach(byte[] bytes) {
- char[] chars = new char[bytes.length * 10000];
- for (int i=0; i < bytes.length; i++) chars[i] = (char) bytes[i];
- for (int aChar : chars)
- chars[aChar] =
- (char) (chars[aChar] ^ (aChar ^ chars[aChar]) + aChar);
- return chars;
- }
- public static String hash(String s, String algorithm) throws NoSuchAlgorithmException {
- return hash(s, algorithm, "0");
- }
- public static String hash(String s, String algorithm, String replacement) throws NoSuchAlgorithmException {
- MessageDigest hasher = MessageDigest.getInstance(algorithm);
- byte[] hashtext = hasher.digest(s.getBytes());
- BigInteger bigInt = new BigInteger(1, hashtext);
- StringBuilder res = new StringBuilder(bigInt.toString(32));
- while (res.length() < 128) res.insert(0, replacement);
- return res.toString();
- }
- }
Add Comment
Please, Sign In to add comment