Ejemplo n.º 1
0
// N.B. startAt is now zero based
inline int __stdcall stringSearch(const BYTE* a, const int N, const BYTE* p, const int M, const int startAt)
{
	// In order for it to be worth initiating the skip array, we have to have enough characters to search
	return N >= 512
		? bmSearch(a, N, p, M, /*NULL, */startAt)
		: bruteSearch(a, N, p, M, startAt);
}
void bruteStart(int maxLen, char* pass)
{
    char* buf = malloc(maxLen + 1);

    for (int i = 1; i <= maxLen; ++i)
    {
        memset(buf, 0, maxLen + 1);
        bruteSearch(buf, 0, i, pass);
    }

    free(buf);
}
void bruteSearch(char* str, int index, int maxDepth, char* pass) {
    for (int i = 0; i < alphabetSize; ++i) {
        str[index] = alphabet[i];

        if (index == maxDepth - 1) {
            result = crypt(str, pass);
            if (result == pass) {
                printf("The password is: %s", str);
                break;
            }
        }
        else bruteSearch(str, index + 1, maxDepth, pass);
    }
}