1

Hi I was learning reverse engineering by doing some crackme(s) found online using IDA and x64dbg.

I'm quite confused on the below decompiled code.

bool Logic()
{
    char CODE[] = "RAND_STRING", *lpString1, *v13, v14;
    char CONST_STRING1[] = "XZULKBBXOK";
    char CONST_STRING3[] = "ZXHYGKLQ9867WEPRCDSANMJBVFTU5342";
    int* v10 = CONST_STRING1;
    int* a2 = CONST_STRING1;
    int* v2 = a2;
    int* a1 = CODE;
    int v3;
    char v4, v6;
    char v7;
    int v8;
    char v9;
    char v10;
    char v11;
    v3 = lstrlenA(CONST_STRING3);
    if ( *a2 )
    {
        v4 = CONST_STRING3[0];
        do
        {
            v6 = *a1;
            if ( !*a1 )
                break;
            if ( v6 < 48 || v6 > 122 )
            {
                ++a1;
            }
            else
            {
                v7 = TO_UPPER(*a1);
                v8 = 0;
                if ( v4 )
                {
                    v9 = v4;
                    do
                    {
                        if ( v9 == v7 )
                        break;
                        v9 = CONST_STRING3[++v8];
                    }
                    while ( v9 );
                }
                v10 = TO_UPPER(*v2);
                if ( v10 % v3 != v8 )
                return 0;
                ++a1;
                ++v2;
            }
        }
        while ( *v2 );
    }
    return *v2 == 0;
}

Basically it checks whether the initial character of CODE falls inside CONST_STRING3, what puzzles me is the next condition following it

if ( v10 % v3 != v8 )
return 0;

What does this code snippet mean? Why is modulus operation done between the ASCII value of first string in CONST_STRING1 and strlen(CONST_STRING3) and then compared with the index upon the loop break?

Some help to understand this is much appreciated.

Nimrod
  • 375
  • 1
  • 12

0 Answers0