Exetools  

Go Back   Exetools > General > Source Code

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-25-2014, 13:23
kheung kheung is offline
Friend
 
Join Date: Feb 2002
Location: China
Posts: 17
Rept. Given: 1
Rept. Rcvd 2 Times in 1 Post
Thanks Given: 0
Thanks Rcvd at 3 Times in 1 Post
kheung Reputation: 2
Keymaker for JxB v1.5 demo version (Windows)

Demo version download
Code:
import java.io.*;
import java.lang.Runtime;
import java.util.Scanner;
import java.nio.ByteBuffer;
import java.security.*;
import java.math.*;

class MakeKey
{
  private static String getSN()
  {
    String s = null;
    Runtime runtime = Runtime.getRuntime();
    Process process;
    try {
      String as[] = {"wmic", "bios", "get", "serialnumber"};
      process = runtime.exec(as);
    } catch(IOException _ex) {
      return null;
    }

    Scanner scanner = new Scanner(process.getInputStream());
    while(scanner.hasNext()) {
      if("SerialNumber".equals(scanner.next())) {
        s = scanner.next().trim();
        break;
      }
    }

    scanner.close();

    return s;
  }

  private static int sum(int i)
  {
    int j = 0;
    for(; i > 0; i >>= 4)
      j += i & 0xf;

    return j % 10;
  }

  private static byte[] reverseBytes(byte ab[])
  {
    byte [] aout = new byte[ab.length];
    for(int i=0; i < ab.length; ++i)
      aout[i] = ab[ab.length -i - 1];
    return aout;
  }

  private static String getKey(long machineId, long unixTime)
  {
    int i = (int)(machineId & -1);
    int j = (int)(machineId >> Integer.SIZE & -1);
    int i1 = i + 0xf5ef08cb + 0x11223344 & -1;
    int j1 = (j - 0xbb87db7) + 0x55667788 & Integer.MAX_VALUE;

    ByteBuffer bb = ByteBuffer.allocateDirect(8);
    bb.putInt(j1);
    bb.putInt(i1);
    bb.rewind();
    long l = bb.getLong();
    int d = (int)unixTime ^ 0x56739acd;

    return String.format("%dZ%d%d", l, d, sum(d));
  }

  public static void main(String [ ] args)
  {
    long machineId = 0;
    String sn = getSN();

    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      byte[] ba = reverseBytes(md.digest(sn.getBytes()));
      ByteBuffer bb = ByteBuffer.allocateDirect(ba.length);

      bb.put(ba);
      bb.rewind();
      machineId = bb.getLong(Long.SIZE / Byte.SIZE);
    } catch (Exception e) {
      System.out.println("Error: " + e);
    }
    System.out.println("Machine Serial: " + sn);
    long unixTime = System.currentTimeMillis() / 1000L + 86400 * 365 * 3 - 86400 * 13;
    System.out.println("Demo Key: " + getKey(machineId, unixTime));
  }
}
Reply With Quote
The Following 2 Users Gave Reputation+1 to kheung For This Useful Post:
papi (05-02-2014)
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On


Similar Threads
Thread Thread Starter Forum Replies Last Post
USB Audio demo version - any tips for patching a driver? an0rma1 General Discussion 7 03-11-2018 08:32


All times are GMT +8. The time now is 13:58.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )