Need help reversing a serial

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Need help reversing a serial

Post by geft on Mon Aug 29, 2011 9:03 pm
([msg=61311]see Need help reversing a serial[/msg])

I'm just starting to learn to reverse java applications, but coming from a simple C/C++ background, many of the functions don't seem to make sense. For instance, in the registerSerialNumber function, the first while loop immediately returns a value. Wouldn't this render anything else in that loop useless? Then there are bunches of hexadecimals and arrows (>>>) which I've never seen in typical programs. Or perhaps I'm just a noob at this. I just want to know what each function does. Any help is appreciated.

Code: Select all
package com.slovoed.engine;

public class sldRegistration
{
  private int BaseDictID;
  private boolean bundle;
  private int[] registrationData;

  private void CRCAndIndexDemix(int paramInt, char[] paramArrayOfChar1, char[] paramArrayOfChar2)
  {
    int i = 1;
    paramArrayOfChar1[0] = '\000';
    paramArrayOfChar2[0] = '\000';
    for (int j = 0; ; j = (char)(j + 1))
    {
      if (j >= 16)
        return;
      int k = paramArrayOfChar1[0];
      int m = (paramInt & i) >> j;
      int n = (char)(k | m);
      paramArrayOfChar1[0] = n;
      int i1 = i << 1;
      int i2 = paramArrayOfChar2[0];
      int i3 = paramInt & i1;
      int i4 = j + 1;
      int i5 = i3 >> i4;
      int i6 = (char)(i2 | i5);
      paramArrayOfChar2[0] = i6;
      i = i1 << 1;
    }
  }

  private void Decimal2Long(byte[] paramArrayOfByte, int paramInt1, char[] paramArrayOfChar, int paramInt2)
  {
    int i = 0;
    while (i < paramInt2)
    {
      paramArrayOfChar[i] = '\000';
      i += 1;
    }
    int j = paramInt1 - 1;
    while (true)
    {
      if (j < 0)
        return;
      int k = paramArrayOfByte[j] - 48;
      int m = 0;
      i = 0;
      while (i < paramInt2)
      {
        int n = paramArrayOfChar[i] * '\n' + m + k;
        k = 0;
        m = n >> 8;
        int i1 = (char)(n & 0xFF);
        paramArrayOfChar[i] = i1;
        int i2 = i + 1;
      }
      j += -1;
    }
  }

  private int QuasiCRC32(int paramInt)
  {
    int i = 10;
    if (i > 0)
    {
      if ((paramInt & 0x1) != 0)
        paramInt = paramInt >>> 1 ^ 0xEDB85364;
      while (true)
      {
        i += -1;
        break;
        paramInt >>>= 1;
      }
    }
    return paramInt;
  }

  char CRCcount(char paramChar)
  {
    int i = 0;
    if (i < 8)
    {
      int j;
      if ((paramChar & 0x1) != 0)
        j = paramChar >> '\001' ^ 0x3DB5;
      for (paramChar = (char)(0xFFFF & j); ; paramChar = (char)(paramChar >> '\001'))
      {
        i = (char)(i + 1);
        break;
      }
    }
    return paramChar;
  }

  int[] decodeKeyData(byte[] paramArrayOfByte, int paramInt)
  {
    int i = this.registrationData[1];
    int j = QuasiCRC32(i);
    int[] arrayOfInt = new int[paramInt / 4];
    int k = decrypt(j, paramArrayOfByte, 0, arrayOfInt);
    return arrayOfInt;
  }

  int decrypt(int paramInt1, byte[] paramArrayOfByte, int paramInt2, int[] paramArrayOfInt)
  {
    if (paramInt1 == 0);
    int j;
    for (int i = paramInt1; ; i = j)
    {
      return i;
      j = paramInt1;
      int k = 0;
      while (true)
      {
        int m = paramArrayOfInt.length;
        if (k >= m)
          break;
        int n = k + j;
        j = QuasiCRC32(n);
        int i1 = k * 4 + paramInt2;
        int i2 = HexUtils.readInt(paramArrayOfByte, i1);
        paramArrayOfInt[k] = i2;
        int i3 = paramArrayOfInt[k] - j;
        paramArrayOfInt[k] = i3;
        k += 1;
      }
    }
  }

  public int getBaseDictID()
  {
    return this.BaseDictID;
  }

  public int[] getRegistrationData()
  {
    return this.registrationData;
  }

  public boolean isBundle()
  {
    return this.bundle;
  }

  public boolean registerSerialNumber(String paramString1, String paramString2)
  {
    char[] arrayOfChar1 = new char[1];
    char[] arrayOfChar2 = new char[1];
    char[] arrayOfChar3 = new char[8];
    int[] arrayOfInt1 = new int[2];
    int i;
    if ((paramString2 == null) || (paramString1 == null))
      i = 0;
    while (true)
    {
      return i;
      int j = paramString1.length();
      int k = 24;
      if (j != k)
      {
        i = 0;
        continue;
      }
      int m = paramString2.length();
      int n = 2;
      if (m != n)
      {
        i = 0;
        continue;
      }
      String str1 = paramString1;
      int i1 = 0;
      int i2 = str1.charAt(i1);
      String str2 = paramString2;
      int i3 = 0;
      int i4 = str2.charAt(i3);
      int i5 = i2;
      int i6 = i4;
      if (i5 != i6)
      {
        String str3 = paramString1;
        int i7 = 1;
        int i8 = str3.charAt(i7);
        String str4 = paramString2;
        int i9 = 1;
        int i10 = str4.charAt(i9);
        int i11 = i8;
        int i12 = i10;
        if (i11 == i12);
      }
      else
      {
        i = 0;
        continue;
      }
      String str5 = paramString1;
      int i13 = 6;
      int i14 = str5.charAt(i13);
      int i15 = 45;
      if (i14 == i15)
      {
        String str6 = paramString1;
        int i16 = 12;
        int i17 = str6.charAt(i16);
        int i18 = 45;
        if (i17 == i18)
        {
          String str7 = paramString1;
          int i19 = 18;
          int i20 = str7.charAt(i19);
          int i21 = 45;
          if (i20 == i21)
            break label262;
        }
      }
      i = 0;
      continue;
      label262: int i22 = 0;
      this.BaseDictID = i22;
      int i23 = 0;
      while (i23 < 4)
      {
        int i24 = this.BaseDictID;
        int i25 = i23 + 2;
        String str8 = paramString1;
        int i26 = i25;
        int i27 = str8.charAt(i26) & 0xFF;
        int i28 = (i23 + 1) * 8;
        int i29 = 32 - i28;
        int i30 = i27 << i29;
        int i31 = i24 | i30;
        this.BaseDictID = i31;
        i23 += 1;
      }
      String str9 = paramString1;
      int i32 = 7;
      int i33 = 12;
      String str10 = str9.substring(i32, i33);
      String str11 = paramString1;
      int i34 = 13;
      int i35 = 18;
      String str12 = str11.substring(i34, i35);
      String str13 = paramString1;
      int i36 = 19;
      int i37 = 24;
      String str14 = str13.substring(i36, i37);
      String str15 = str12.concat(str14);
      String str16 = str10.concat(str15);
      byte[] arrayOfByte1 = str16.getBytes();
      int i38 = str16.length();
      sldRegistration localsldRegistration1 = this;
      byte[] arrayOfByte2 = arrayOfByte1;
      int i39 = i38;
      char[] arrayOfChar4 = arrayOfChar3;
      int i40 = 8;
      localsldRegistration1.Decimal2Long(arrayOfByte2, i39, arrayOfChar4, i40);
      arrayOfInt1[0] = 0;
      arrayOfInt1[1] = 0;
      int i41 = 0;
      while (i41 < 4)
      {
        int i42 = arrayOfInt1[0];
        int i43 = arrayOfChar3[i41] & 0xFF;
        int i44 = i41 * 8;
        int i45 = i43 << i44;
        int i46 = i42 | i45;
        arrayOfInt1[0] = i46;
        i41 += 1;
      }
      int i47 = 0;
      while (i47 < 4)
      {
        int i48 = arrayOfInt1[1];
        int i49 = i47 + 4;
        int i50 = arrayOfChar3[i49] & 0xFF;
        int i51 = i47 * 8;
        int i52 = i50 << i51;
        int i53 = i48 | i52;
        arrayOfInt1[1] = i53;
        i47 += 1;
      }
      int i54 = arrayOfInt1[1];
      sldRegistration localsldRegistration2 = this;
      int i55 = i54;
      char[] arrayOfChar5 = arrayOfChar1;
      char[] arrayOfChar6 = arrayOfChar2;
      localsldRegistration2.CRCAndIndexDemix(i55, arrayOfChar5, arrayOfChar6);
      int i56 = arrayOfChar2[0];
      arrayOfInt1[1] = i56;
      int i57 = arrayOfInt1[0];
      int i58 = arrayOfInt1[1];
      sldRegistration localsldRegistration3 = this;
      int i59 = i58;
      int i60 = localsldRegistration3.QuasiCRC32(i59);
      int i61 = i57 - i60;
      arrayOfInt1[0] = i61;
      int i62 = 39006;
      int i63 = 0;
      while (i63 < 7)
      {
        String str17 = paramString1;
        int i64 = i63;
        char c1 = str17.charAt(i64);
        sldRegistration localsldRegistration4 = this;
        char c2 = c1;
        i62 = (char)(localsldRegistration4.CRCcount(c2) + i62);
        i63 += 1;
      }
      int i65 = 0;
      while (i65 < 4)
      {
        int i66 = arrayOfInt1[0];
        int i67 = i65 * 8;
        char c3 = (char)(i66 >>> i67 & 0xFF);
        sldRegistration localsldRegistration5 = this;
        char c4 = c3;
        i62 = (char)(localsldRegistration5.CRCcount(c4) + i62);
        i65 += 1;
      }
      int i68 = 0;
      while (i68 < 4)
      {
        int i69 = arrayOfInt1[1];
        int i70 = i68 * 8;
        char c5 = (char)(i69 >>> i70 & 0xFF);
        sldRegistration localsldRegistration6 = this;
        char c6 = c5;
        i62 = (char)(localsldRegistration6.CRCcount(c6) + i62);
        i68 += 1;
      }
      int i71 = i62 & 0x1FF;
      int i72 = (char)(0xFFFF & i71);
      if (arrayOfChar1[0] == i72)
        break;
      i = 0;
    }
    int i73 = (arrayOfInt1[0] & 0xFE000000) >>> 9;
    int i74 = (arrayOfInt1[0] & 0x1FE00) >>> 1;
    int i75 = i73 | i74;
    int i76 = arrayOfInt1[1] & 0xFF;
    int i77 = i75 | i76;
    int i78 = (arrayOfInt1[0] & 0x1FE0000) >>> 9;
    int i79 = (arrayOfInt1[0] & 0x1FE) >>> 1;
    int i80 = (char)(i78 | i79);
    if ((arrayOfInt1[0] & 0x1) != 0);
    for (boolean bool1 = true; ; bool1 = false)
    {
      boolean bool2 = bool1;
      this.bundle = bool2;
      int[] arrayOfInt2 = new int[3];
      this.registrationData = arrayOfInt2;
      this.registrationData[0] = i77;
      this.registrationData[1] = i80;
      this.registrationData[2] = 300;
      i = 1;
      break;
    }
  }

  int restoreDictID(int paramInt)
  {
    byte[] arrayOfByte = new byte[4];
    int i = 0;
    if (i < 4)
    {
      int j = i * 4;
      int k = 12 - j;
      int m = (byte)(paramInt >> k & 0xF);
      if (m < 10)
      {
        int n = (byte)(m + 48);
        arrayOfByte[i] = n;
      }
      while (true)
      {
        i += 1;
        break;
        int i1 = (byte)(m - 10 + 65);
        arrayOfByte[i] = i1;
      }
    }
    return HexUtils.readIntPrc(arrayOfByte, 0);
  }
}
geft
New User
New User
 
Posts: 3
Joined: Wed Jun 22, 2011 7:25 am
Blog: View Blog (0)


Re: Need help reversing a serial

Post by martyj2009 on Wed Oct 26, 2011 12:30 am
([msg=62607]see Re: Need help reversing a serial[/msg])

I assume this is from a decompiler?

As far as the return in the loop. Yes it would. This could be an attempt at protecting their code from people finding a way to generate a serial. It could also be a decompile error.

As far as the hex for the most part you can use hex in any language (I believe don't quote me). Usually looks like 0xHEX_VALUE s to indicate to the compiler that it is hex and not an integer.

The <<, >>, and >>> operators in java are bit shift operators. For example. You have a variable where the binary is 10001001

>> 3 would shift the bits to the right by 3 making it 10001
<< 3 would shift the bits to the left by 3 making it 10001001000
martyj2009
New User
New User
 
Posts: 5
Joined: Sun Aug 07, 2011 12:24 am
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests