Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()))) : 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");
- return hwid.replace("null", hwid);
- }
- public static String repeat(String in, int x) {
- for (int i=0; i < x; i++) in += in;
- return in;
- }
- 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