generate password using brute algo?
-
hi all, I am using
static /*const*/ char alphabet[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";static /*const*/ int alphabet_size = sizeof(alphabet) - 1;
CString str_val=_T("");
void brute_impl(char * str, int index, int max_depth)
{
int i;
for (i = 0; i < alphabet_size; ++i)
{
str[index] = alphabet[i];if (index == max\_depth - 1) { str\_val.Format("%s", str); //check the password here } else { brute\_impl(str, index + 1, max\_depth); } }
}
void brute_sequential(int max_len)
{
char * buf = new char[max_len + 1];//buf = malloc(max\_len + 1); int i=0; while(buf\[i\] != NULL) { if(i==max\_len+1) break; buf\[i\]='\\0'; i++; } CString str=\_T(""); str.Format("size of array is %d\\n", i); for (i = 1; i <= max\_len; ++i) { memset(buf, 0, max\_len + 1); brute\_impl(buf, 0, i); } free(buf);
}
but its time consuming and very slow anybody have more efficient and fast method for this. thanks.
-
hi all, I am using
static /*const*/ char alphabet[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";static /*const*/ int alphabet_size = sizeof(alphabet) - 1;
CString str_val=_T("");
void brute_impl(char * str, int index, int max_depth)
{
int i;
for (i = 0; i < alphabet_size; ++i)
{
str[index] = alphabet[i];if (index == max\_depth - 1) { str\_val.Format("%s", str); //check the password here } else { brute\_impl(str, index + 1, max\_depth); } }
}
void brute_sequential(int max_len)
{
char * buf = new char[max_len + 1];//buf = malloc(max\_len + 1); int i=0; while(buf\[i\] != NULL) { if(i==max\_len+1) break; buf\[i\]='\\0'; i++; } CString str=\_T(""); str.Format("size of array is %d\\n", i); for (i = 1; i <= max\_len; ++i) { memset(buf, 0, max\_len + 1); brute\_impl(buf, 0, i); } free(buf);
}
but its time consuming and very slow anybody have more efficient and fast method for this. thanks.
Use a passwords list; you can find them freely on the web.