示例#1
0
  /** Creates a new instance of War3Decode */
  public War3Decode(String cdkey) {
    byte[] table = new byte[W3_BUFLEN];
    int[] values = new int[4];
    tableLookup(cdkey.toUpperCase(), table);

    for (int i = W3_BUFLEN; i > 0; i--) Mult(4, 5, values, values, table[i - 1]);

    // -------------

    decodeKeyTablePass1(values);

    decodeKeyTablePass2(values);

    product = values[0] >> 0x0a;
    // val1 = ((values[0] & 0x03FF) << 0x10) | (values[1] >> 0x10);
    // val1 = IntFromByteArray.LITTLEENDIAN.getInteger(values, 0);
    val1 = ((values[0] & 0x03FF) << 0x10) | (values[1] >>> 0x10);

    val2 = new byte[10];
    val2[0] = (byte) ((values[1] & 0x00FF) >> 0);
    val2[1] = (byte) ((values[1] & 0xFF00) >> 8);

    IntFromByteArray.LITTLEENDIAN.insertInteger(val2, 2, values[2]);
    IntFromByteArray.LITTLEENDIAN.insertInteger(val2, 6, values[3]);
  }
示例#2
0
  public int[] getKeyHash(int clientToken, int serverToken) {
    try {
      MessageDigest digest = MessageDigest.getInstance("SHA-1");

      byte[] warBuf = new byte[26];

      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 0, clientToken);
      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 4, serverToken);
      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 8, getProduct());
      IntFromByteArray.LITTLEENDIAN.insertInteger(warBuf, 12, getVal1());

      for (int i = 16; i < 26; i++) warBuf[i] = getWar3Val2()[i - 16];

      digest.update(warBuf);
      return IntFromByteArray.LITTLEENDIAN.getIntArray(digest.digest());

    } catch (java.security.NoSuchAlgorithmException e) {
      System.out.println("Could not find SHA1 library " + e);
      System.exit(1);
      return new int[1];
    }
  }
示例#3
0
  void decodeKeyTablePass2(int[] keyTable) {
    int eax, edx, ecx, edi, esi, ebp;
    byte[] Copy = ByteFromIntArray.LITTLEENDIAN.getByteArray(keyTable);
    esi = 0;

    for (edi = 0; edi < 120; edi++) {
      eax = edi & 0x1F;
      ecx = esi & 0x1F;
      edx = 3 - (edi >>> 5);

      //            ebp = *(DWORD *)((BYTE *)(Copy+3) - ((esi >> 5) << 2));  <-- original c++ code
      // could you convert that line to java?
      int location = 12 - ((esi >>> 5) << 2);
      ebp = IntFromByteArray.LITTLEENDIAN.getInteger(Copy, location);

      // System.out.print(PadString.padHex(ebp, 8) + " ");

      ebp = (ebp & (1 << ecx)) >>> ecx;
      keyTable[edx] = ((ebp & 1) << eax) | (~(1 << eax) & keyTable[edx]);
      esi += 0x0B;
      if (esi >= 120) esi -= 120;
    }
  }