Brute force password cracker.
Hi
I am currently building a brute force password cracker, currently I have a program that allows the user to enter a password (Only in lowercase) and the program will run through all possible options for this password, for example a password of 5 characters is entered it will start with (aaaaa) then (aaaab) then (aaaac) and the so. However, I currently unsure of how to incorporate uppercase characters and special characters into this process so the user can enter a password with all 3 of these and the program will attempt to solve it.
Here is the code i currently have
Code:
#include "stdafx.h"
#include <iostream>
#include <limits>
using namespace std;
# include "string"
int main()
{
string password;
string programPass;
cout << "Please enter a password to test" << endl;
cin >> password;
char lowerDigitArray[] = { 'a' - 1,'a','a','a','a','a','a','a','a','a' };
while (password.compare(programPass) != 0) {
lowerDigitArray[0]++;
for (int x = 0; x <password.length(); x++) {
if (lowerDigitArray[x] == 'z' + 1)
{
lowerDigitArray[x] = 'a';
lowerDigitArray[x + 1]++;
}
}
// creating the string with those digits
programPass = lowerDigitArray[password.length() - 1]; // i set the first one here
for (int i = password.length() - 2; i >= 0; i--)
programPass += lowerDigitArray[i]; // now i add other digits to next to first digit
cout << programPass << endl; // i put it to test how it looks
}
cout << "This is your password " << programPass << endl; // gives the result
return 0;
}
Thanks for any help you offer.
Re: Brute force password cracker.
Based upon your algorithm one extension to cater for any required chars is to have a string of these and then to make lowerDigitArray into an array of indexes into the string. The idea is something like this
Code:
const char allowchars[] = "abcdABCD!£$0123";
...
int charIndex[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
So the elements of charIndex are indexes into allowchars. So in this exmaple, 0 would be a, 4 would be A etc. So the lowest valid value would be 0 (for a) and the highest valid value would be (sizeof(allowchars) / sizeof(allowchars[0]) - 1) (calculate once after allowchars has been defined). With a few minor changes the algorithm would be the same.
Re: Brute force password cracker.
Hi, thanks for your reply I'm not sure I completely understand what you mean,
Code:
const char allowchars[] = "abcdABCD!£$0123";
Are you suggesting that this line of code replace my current lowerdigitalarray.
Also for the second line of code you suggested would this function in the same way where it begins at lowercase and through the while loop, I have added 1 each loop so it goes to b then c and so on.
Cheers
Re: Brute force password cracker.
Code:
const char allowchars[] = "abcdABCD!£$0123";
const size_t allowSize = sizeof(allowchars) / sizeof(allowchars[0]);
allowchars contains the characters you want allowed. The index starts at 0 and ends at allowSize - 1.
In your code in post #1, the array lowerDigitArray contains chars representing the password to try. Each element is incremented by 1 (to get b, c, d etc) . Once it reaches after z it is reset to a and the next element is then incremented. This is fine if the required chars are sequential (like all the lower case chars etc). But for the set of chars you want they are not. So instead of having an array that contains the chars, you have an array that contains indexes into allowchars. So the first element starts at 0 (for a), then is incremented which would be b etc. In the example 14 would be 3. When the value exceeds allowSize it is reset to 0 and the next element in the array is incremented as in your original code.
Code:
for (int i = password.length() - 2; i >= 0; i--)
programPass += lowerDigitArray[i]; // now i add other digits to next to first digi
would become
Code:
for (int i = password.length() - 2; i >= 0; i--)
programPass += allowchars[DigitArray[i]]; // now i add other digits to next to first digi
where DigitArray is the array of indexes into allowchars.
Re: Brute force password cracker.
Hi
thanks for your help so far, I have implemented the changes you suggested and it works great, however, is their a possibility of specifying the symbols inside that array the list preferably would just be limited to this list (" !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~?)
However its incorporated symbols such as these and other like smiley and angry face which wouldn't really be used in this program https://imgur.com/a/edt8T, so would it be possible to just specify the symbol list shown above.
Thanks
Re: Brute force password cracker.
Are you sure you want to help somebody with no history here write a password cracker?
Re: Brute force password cracker.
Hi
It's not for nefarious purposes its a college project my tutor suggested as I'm interested in this area of computing.
Re: Brute force password cracker.
Quote:
Originally Posted by
Alex1598540
Hi
thanks for your help so far, I have implemented the changes you suggested and it works great, however, is their a possibility of specifying the symbols inside that array the list preferably would just be limited to this list (" !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~?)
However its incorporated symbols such as these and other like smiley and angry face which wouldn't really be used in this program
https://imgur.com/a/edt8T, so would it be possible to just specify the symbol list shown above.
Thanks
allowchars can contain any symbol that can be represented as a type char (8 bits in this case). If you want to include a non-printable char, then just use its ascii code instead.
eg
Code:
const char allowchars[] = {250, 251, 252, 4, 6, 8, 'a', 'b', 'A', 'Z', '0'};
But then you have the issue of input....
PS If you want non-ascii chars then allowchars could be of type wchar_t (16 bits) to enable UCS2 chars to be used (see https://en.wikipedia.org/wiki/C_string_handling#wchar_t https://en.wikipedia.org/wiki/Univer..._Character_Set)