0

This is how I am generating all of the keys and checking them (for debugging purposes I'm printing them out too)

char salt[] = "50";
char key[4] = { 0 };
char alphabet[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";


for (int i = 0; i < 52; i++)
{
    key[0] = alphabet[i];
    printf("%s\n", key);
    if (strcmp(argv[1], crypt(key, salt)) == 0)
    {
        printf("%s\n", key);
        return 0;
    }

    for (int j = 0; j < 52; j++)
    {
        key[1] = alphabet[j];
        printf("%s\n", key);
        if (strcmp(argv[1], crypt(key, salt)) == 0)
        {
            printf("%s\n", key);
            return 0;
        }

        for (int k = 0; k < 52; k++)
        {
            key[2] = alphabet[k];
            printf("%s\n", key);
            if (strcmp(argv[1], crypt(key, salt)) == 0)
            {
                printf("%s\n", key);
                return 0;
            }

            for (int l = 0; l < 52; l++)
            {
                key[3] = alphabet[l];
                printf("%s\n", key);
                if (strcmp(argv[1], crypt(key, salt)) == 0)
                {
                    printf("%s\n", key);
                    return 0;
                }

            }
            key[3] = '\0';
        }
        key[2] = '\0';
    }
    key[1] = '\0';
}

this is the generated output, for the keys that should be 4 in length, all of them have a "50" at the end.

djEZ50 djF djFa50 djFb50 djFc50 djFd50 djFe50 djFf50 djFg50 djFh50 djFi50 djFj50 djFk50 djFl50 djFm50 djFn50 djFo50 djFp50 djFq50 djFr50 djFs50 djFt50 djFu50 djFv50 djFw50 djFx50 djFy50 djFz50 djFA50 djFB50 djFC50 djFD50 djFE50 djFF50 djFG50 djFH50 djFI50 djFJ50 djFK50 djFL50 djFM50 djFN50 djFO50 djFP50 djFQ50 djFR50 djFS50 djFT50 djFU50 djFV50 djFW50 djFX50 djFY50 djFZ50 djG djGa50

3 length ones seem to be ok.

0

ok, I need to initialize "key" like this

char key[5] = { 0 };

when I had it 4 length I guess I was overwriting the '\0' at the end and it joined together with the "salt" array in memory?

All of this is still very hazy to me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .