gordon_freeman
June 11th, 2005, 13:59
Hi all,
In order to make a keygen of a prog (a plugins for eclipse), I need to reverse
the following class:
The 'Decoder' class is used as follows :
My question is what is the reverse function of 'private int[] decipher(int v[])' ?
Thank you
In order to make a keygen of a prog (a plugins for eclipse), I need to reverse
the following class:
Code:
public class Decoder {
private int _key[];
private byte _keyBytes[];
public Decoder(byte key[]) {
int klen = key.length;
_key = new int[4];
if(klen != 16)
throw new ArrayIndexOutOfBoundsException("License Key is not 16 bytes: " + klen);
int i = 0;
for(int j = 0; j < klen{
_key[I] = key[j] << 24 | (key[j + 1] & 0xff) << 16 | (key[j + 2] & 0xff) << 8 | key[j + 3] & 0xff;
j += 4;
i++;
}
_keyBytes = key;
}
public Decoder(int key[]) {
_key = key;
}
public String Decrypt(String hexStr) {
byte dec[] = decode(hexStr);
return (new String(dec)).trim();
}
private byte[] decode(String hexStr) {
if(hexStr.length() == 0)
throw new InternalError("Cannot decode empty stringd";
char chars[] = hexStr.toCharArray();
int len = chars.length;
if(len % 2 == 1)
throw new InternalError("Cannot decode empty stringd";
byte result[] = new byte[hexStr.length() / 2];
int j = 0;
for(int i = 0; i < len; i++) {
char c = chars[I];
if((c < '0' || c > '9') && (c < 'A' || c > 'F'))
throw new InternalError("invalid key";
byte b1;
if(c >= '0' && c <= '9') {
b1 = (byte)(c - 48);
} else {
b1 = (byte)(c - 65);
b1 += 10;
}
i++;
c = chars[I];
if((c < '0' || c > '9') && (c < 'A' || c > 'F'))
throw new InternalError("invalid key";
byte b2;
if(c >= '0' && c <= '9') {
b2 = (byte)(c - 48);
} else {
b2 = (byte)(c - 65);
b2 += 10;
}
b1 <<= 4;
byte rb = (byte)(b1 + b2);
result[j++] = rb;
}
return decode(result, result.length);
}
private byte[] decode(byte b[], int count) {
int intCount = count / 4;
int ini[] = new int[intCount];
int i = 0;
for(int j = 0; i < intCount; j += 8) {
ini[I] = b[j] << 24 | (b[j + 1] & 0xff) << 16 | (b[j + 2] & 0xff) << 8 | b[j + 3] & 0xff;
ini[i + 1] = b[j + 4] << 24 | (b[j + 5] & 0xff) << 16 | (b[j + 6] & 0xff) << 8 | b[j + 7] & 0xff;
i += 2;
}
return decode(ini);
}
private byte[] decode(int b[]) {
int intCount = b.length;
byte outb[] = new byte[intCount * 4];
int tmp[] = new int[2];
int j = 0;
for(int i = 0; i < intCount{
tmp[0] = b[I];
tmp[1] = b[i + 1];
decipher(tmp);
outb[j] = (byte)(tmp[0] >>> 24);
outb[j + 1] = (byte)(tmp[0] >>> 16);
outb[j + 2] = (byte)(tmp[0] >>> 8);
outb[j + 3] = (byte)tmp[0];
outb[j + 4] = (byte)(tmp[1] >>> 24);
outb[j + 5] = (byte)(tmp[1] >>> 16);
outb[j + 6] = (byte)(tmp[1] >>> 8);
outb[j + 7] = (byte)tmp[1];
i += 2;
j += 8;
}
return outb;
}
private int[] decipher(int v[]) {
int y = v[0];
int z = v[1];
int sum = 0xc6ef3720;
int delta = 0x9e3779b9;
int a = _key[0];
int b = _key[1];
int c = _key[2];
int d = _key[3];
for(int n = 32; n-- > 0{
z -= (y << 4) + c ^ y + sum ^ (y >>> 5) + d;
y -= (z << 4) + a ^ z + sum ^ (z >>> 5) + b;
sum -= delta;
}
v[0] = y;
v[1] = z;
return v;
}
}
The 'Decoder' class is used as follows :
Code:
byte KEY[] = (new BigInteger("36af32b86df9b905a8c47c13d9ad529", 16)).toByteArray();
Decoder decoder = new Decoder(KEY);
String serial = decoder.Decrypt(crypted_serial);
My question is what is the reverse function of 'private int[] decipher(int v[])' ?
Thank you