jeb2 demo keygen.md

如果demo版本过期了,可以尝试用这个keygen

import java.io.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.Scanner;

/**
 * description: jeb2 keygen
 * author: xiaobai
 * data: 2016/9/1
 */
public class Keygen {
    private long[] getMachineSerialNumber() {
        long l[] = new long[2];
        String platform = System.getProperty("os.name", "");
        if (platform.startsWith("Windows")) {
            String string = getWinSerialNumber("wmic csproduct get uuid", "UUID");
            string += "__";
            String SerialNumber = getWinSerialNumber("wmic bios get serialnumber", "SerialNumber");
            string += SerialNumber;
            l[0] = getStringMd5(string);
            l[1] = getStringMd5(SerialNumber);
            return l;
        } else if (platform.startsWith("Mac")) {
            l[0] = getStringMd5(getMacSerialNumber());
            l[1] = 0;
            return l;
        } else if (platform.startsWith("Linux")) {
            l[0] = getStringMd5(getLinuxSerialNumber());
            l[1] = 0;
            return l;
        }
        return null;
    }


    private long getStringMd5(String str) {
        final MessageDigest instance;
        try {
            instance = MessageDigest.getInstance("MD5");
            instance.update(str.getBytes());
            final ByteBuffer wrap;
            (wrap = ByteBuffer.wrap(instance.digest())).order(ByteOrder.LITTLE_ENDIAN);
            return wrap.getLong() & Long.MAX_VALUE;
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return 0;
    }

    private String getMacSerialNumber() {
        try {
            Process exec = Runtime.getRuntime().exec("/usr/sbin/system_profiler SPHardwareDataType".split(" "));
            OutputStream outputStream = exec.getOutputStream();
            InputStream inputStream = exec.getInputStream();
            try {
                String readLine;
                String str;
                outputStream.close();
                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                String IP = "Serial Number";
                while (true) {
                    try {
                        readLine = bufferedReader.readLine();
                        if (readLine != null) {
                            if (readLine.indexOf(IP) >= 0) {
                                break;
                            }
                        }
                        break;
                    } catch (IOException e) {
                        str = e.toString();
                        return null;
                    } finally {
                        try {
                            inputStream.close();
                        } catch (IOException e2) {
                            return null;
                        }
                    }
                }
                str = readLine.split(IP)[1];
                int indexOf = str.indexOf(58);
                if (indexOf >= 0) {
                    str = str.substring(indexOf + 1).trim();
                    return str;
                }
                return str;
            } catch (IOException e3) {
                return null;
            }
        } catch (IOException e4) {
            return null;
        }
    }

    private String getLinuxSerialNumber() {
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("/var/lib/dbus/machine-id")));
            String readLine;
            try {
                readLine = bufferedReader.readLine();
                if (readLine != null) {
                    readLine = readLine.trim();
                } else {
                    readLine = null;
                }
                return readLine;
            } catch (IOException e) {
                readLine = e.toString();
                return null;
            } finally {
                try {
                    bufferedReader.close();
                } catch (IOException e2) {
                    return null;
                }
            }
        } catch (FileNotFoundException e3) {
            return null;
        }
    }

    private String getWinSerialNumber(String str, String str2) {
        String str3 = null;
        try {
            Process execd = Runtime.getRuntime().exec(str.split(" "));
            OutputStream outputStream = execd.getOutputStream();
            InputStream inputStream = execd.getInputStream();
            outputStream.close();
            Scanner scanner = new Scanner(inputStream);
            do {
                try {
                    if (!scanner.hasNext()) {
                        break;
                    }
                } catch (Throwable th) {
                    scanner.close();
                }
            } while (!str2.equals(scanner.next()));
            str3 = scanner.next().trim();
            scanner.close();
        } catch (IOException e2) {
            System.out.println(e2.toString());
        }
        return str3;
    }

    public String getKeys() {
        Random random = new Random(System.currentTimeMillis());
        long time = 1624054740 + random.nextInt(10000000);
        int n1 = (int) (time ^ 0x56739ACD);//有效期
        int i = n1;
        int n = 0;//有效期验证
        while (i > 0) {
            n += (i & 0xF);
            i >>= 4;
        }
        long[] md5s = getMachineSerialNumber();
        long md5 = 0;//取其中一个即可
        if (md5s[0] != 0) {
            md5 = md5s[0];
        } else {
            md5 = md5s[1];
        }
        int n3 = (int) md5;//取long后八位
        int n4 = (int) (md5 >> 32);//前八位
        int n8 = n4 - 28363537 + 1432778632 & Integer.MAX_VALUE;//前八位最终结果
        int n7 = n3 + 1173498386 + 287454020;//后八位最终结果
        String test = String.format("%x", n8) + String.format("%x", n7);//拼接
        String keys = Long.parseLong(test, 16) + "Z" + n1 + n % 10;
        //System.out.println(keys);
        return keys;
    }

    public static void main(String[] args) {
        Keygen keygen = new Keygen();
        String key= keygen.getKeys();
        System.out.println("key:"+key);
    }

}

测试了win下的,linux mac下没条件测试

posted @ 2016-09-17 12:59 xiaobaiyey 阅读(...) 评论(...) 编辑 收藏