0

Brute-force programming part 2..

Now i managed to brute-force a string password but when i input a password like 'test' without quotes it just output the first or second letter of the password.. this is the code : #include <iostream> #include <string> using namespace std; int main() { string password; cout << "Enter a string password = "; cin >> password; const int alphabets = 26; const string alphabetslow = "abcdefghijklmnopqrstuvwxyz" ; string bruted; int countslow = 0; int i; do { for ( i = 0; i < 26; i++) { if (password[countslow] == alphabetslow[i]) { bruted += alphabetslow[i]; countslow++; } } } while (i < 25); cout << "Brute-Forced password is = "; cout << bruted << endl; return 0; } is there a problem with my code ??

17th Dec 2016, 6:39 PM
Fluffy Rabbit
Fluffy Rabbit - avatar
5 Respuestas
+ 2
Thank you very much! Now my brute-force is working very fast !! This is the full code : #include <iostream> #include <string> using namespace std; int main() { string password; cout << "Enter a string password = "; cin >> password; string alphabetslow = "abcdefghijklmnopqrstuvwxyz" ; string alphabetsup = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string numerics = "0123456789" ; string bruted; int counts = 0; int i; do { cout << "Brute-forcing... \n"; for ( i = 0; i < 26; i++) { if (password[counts] == alphabetsup[i]) { bruted += alphabetsup[i]; counts++; } else if (password[counts] == alphabetslow[i]) { bruted += alphabetslow[i]; counts++; } else if (i < 10 && password[counts] == numerics[i]) { bruted += numerics[i]; counts++; } } } while (password != bruted); cout << "Brute-Forced password is = "; cout << bruted << endl; return 0; } Also I've asked for help at another forum and this is what I learnt from him.. #include <iostream> #include <string> using namespace std; int main() { string password,bruted; cout << "Enter A Password : "; cin >> password; string charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+=-'"; int char_len = charset.length(); int pass_len = password.length(); int a,b; for (a = 0; a < pass_len; a++) { for (b= 0; b < char_len; b++) { if (password[a] == charset[b]) { bruted += charset[b]; break; } } } cout << "The Brute-forced password is = " << bruted << endl; return 0; } Much simpler huh xD
19th Dec 2016, 12:12 AM
Fluffy Rabbit
Fluffy Rabbit - avatar
+ 1
Try to add 'break' after 'countslow++'. And think: what will happen if password contains 'z'?
18th Dec 2016, 3:14 PM
Daniil Fomichev
+ 1
Ok. Then try to add: else if (i < 10 && password[counts] == numerics[i]){ bruted += numerics[i]; counts++; } And 'numerics' should contain '0'. With these fixes your code must work (not tested).
18th Dec 2016, 6:05 PM
Daniil Fomichev
+ 1
And it would be better if there was only one string with all chars possible for a password
18th Dec 2016, 6:07 PM
Daniil Fomichev
0
yeah i fixed the code and now my code worked with lower and uppercase letter..but i don't know how to handle passwords that contain some numbers..i need some hint on making a code that can crack any passwords that contain numbers :) here is my code http://pastebin.com/ipJnA1XJ ..
18th Dec 2016, 3:58 PM
Fluffy Rabbit
Fluffy Rabbit - avatar