Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

[C++] Bruteforcer core

Since some people have asked for a bruteforcer source I decided to write a bruteforcer core. This generates all possible combinations with the specified length. Character set can be customized with the createCharSet function(a-z, A-Z, 0-9). The example usage in the main function demonstrates combinations with lengths 1-4 and a character set of a-z.

Code
#include <iostream>
#include <cstring>

void generator(char* charSet, unsigned char targetLength, char* buffer, unsigned char length);
char* createCharSet(bool charSet_az, bool charSet_AZ, bool charSet_09);

int main(void)
{
    char* charSet = createCharSet(true, false, false);
    char* buffer = new char[10];
    memset(buffer, '\0', 10);

    for (unsigned char i = 1; i <= 4; i++)
    {
        generator(charSet, i, buffer, 0);
    }

    delete [] charSet;
    charSet = 0;
    delete [] buffer;
    buffer = 0;

    std::cout << "DONE." << std::endl;

    std::cin.sync();
    std::cin.get();
    return 0;
}

void generator(char* charSet, unsigned char targetLength, char* buffer, unsigned char length)
{
    if (length == targetLength)
    {
        std::cout << buffer << std::endl;
    }
    else
    {
        for (unsigned char i = 0; i < 62; i++)
        {
            if (charSet[i] != '\0')
            {
                buffer[length] = charSet[i];
                generator(charSet, targetLength, buffer, length + 1);
            }
            else
            {
                break;
            }
        }
    }
}

char* createCharSet(bool charSet_az, bool charSet_AZ, bool charSet_09)
{
    char* charSet = new char[62];
    memset(charSet, '\0', 62);
    unsigned char index = 0;

    if (charSet_az)
    {
        for (char i = 'a'; i <= 'z'; i++)
        {
            charSet[index] = i;
            index++;
        }
    }

    if (charSet_AZ)
    {
        for (char i = 'A'; i <= 'Z'; i++)
        {
            charSet[index] = i;
            index++;
        }
    }

    if (charSet_09)
    {
        for (char i = '0'; i <= '9'; i++)
        {
            charSet[index] = i;
            index++;
        }
    }

    return charSet;
}
bro can you suggest me how to learn C++ professionally as i have bookish knowledge but no practical exp..
(Mar 24, 2011 01:22 PM)Raheelmarwat Wrote:  bro can you suggest me how to learn C++ professionally as i have bookish knowledge but no practical exp..

Use the search functionality of these forums. 😉
(Mar 24, 2011 11:43 PM)Navigator Wrote:  Use the search functionality of these forums. 😉

yes that will be help full but i need to say that which steps should i follow..
That's so fucking fast! =D
Good job, dude, keep it up!