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;
- public class Main {
- public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, 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();
- KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
- keyGen.initialize(1024*4);
- KeyPair pair = keyGen.generateKeyPair();
- hwid_builder.append(cipherEncrypt("HWID by TerrificTable", "RSA/ECB/PKCS1Padding", pair));
- 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 = Base64.getEncoder().encodeToString(Base64.getEncoder().encode(hashText.getBytes()));
- System.out.println(hwid);
- }
- public static String cipherEncrypt(String s, String algorithm, KeyPair pair) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
- Cipher cipher = Cipher.getInstance(algorithm);
- cipher.init(Cipher.ENCRYPT_MODE, pair.getPublic());
- return cipherEncrypt(s, cipher);
- }
- public static String cipherEncrypt(String s, Cipher cipher) throws IllegalBlockSizeException, BadPaddingException {
- return Arrays.toString(cipher.doFinal(s.getBytes()));
- }
- 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 * 100];
- 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]) + (int)(Math.random() * 100 / Math.random()));
- 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