diff --git a/crack.c b/crack.c index 6619f5cb603dd917b1a715a4c8c8e83d2f3b5dd3..430c85bb29bfa554aa7a79ec3659828a164d5029 100644 --- a/crack.c +++ b/crack.c @@ -13,6 +13,8 @@ #define OUTPUT_FILENAME "found_pwds.txt" #define PWD4_NUMBERS 10 #define PWD_NUMBERS 30 +#define PWD4_LEN 4 +#define PWD6_LEN 6 #define ASCII_FROM 32 #define ASCII_TO 126 @@ -73,45 +75,125 @@ int main(int argc, char** argv) { // create guess and check it SHA256_CTX ctx; BYTE buf[SHA256_BLOCK_SIZE]; + int checked[PWD_NUMBERS]; + int_array_init(checked, PWD4_NUMBERS); // open output file fp = fopen(OUTPUT_FILENAME, "w"); // violent crack PWD4 - char guess[5]; - guess[4] = '\0'; - int checked[PWD4_NUMBERS]; - int_array_init(checked, PWD4_NUMBERS); + char pw4guess[PWD4_LEN + 1]; + pw4guess[PWD4_LEN] = '\0'; int first, second, third, fourth; for (first = ASCII_FROM; first <= ASCII_TO; first++) { - guess[0] = first; - for (second = ASCII_FROM; second <= ASCII_TO; second++) { - guess[1] = second; - for (third = ASCII_FROM; third <= ASCII_TO; third++) { - guess[2] = third; - for (fourth = ASCII_FROM; fourth <= ASCII_TO; fourth++) { - guess[3] = fourth; - - // generate hash and check - sha256_init(&ctx); - sha256_update(&ctx, (BYTE*)guess, 4); - sha256_final(&ctx, buf); - - for (int i = 0; i < PWD4_NUMBERS; i++) { - if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) { - checked[i] = 1; - printf("%s %d\n", guess, i + 1); - fprintf(fp, "%s %d\n", guess, i + 1); - } - } - } + pw4guess[0] = first; + for (second = ASCII_FROM; second <= ASCII_TO; second++) { + pw4guess[1] = second; + for (third = ASCII_FROM; third <= ASCII_TO; third++) { + pw4guess[2] = third; + for (fourth = ASCII_FROM; fourth <= ASCII_TO; fourth++) { + pw4guess[3] = fourth; + + // generate hash and check + sha256_init(&ctx); + sha256_update(&ctx, (BYTE*)pw4guess, PWD4_LEN); + sha256_final(&ctx, buf); + + for (i = 0; i < PWD4_NUMBERS; i++) { + if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) { + checked[i] = 1; + printf("%s %d\n", pw4guess, i + 1); + fprintf(fp, "%s %d\n", pw4guess, i + 1); } } - } + }}}} // crack PWD6 + char pw6guess[PWD6_LEN + 1]; + pw6guess[PWD6_LEN] = '\0'; + int fifth, sixth; + + // guess pure number password + for (first = ASCII_NUM_FROM; first <= ASCII_NUM_TO; first++) { + pw6guess[0] = first; + for (second = ASCII_NUM_FROM; second <= ASCII_NUM_TO; second++) { + pw6guess[1] = second; + for (third = ASCII_NUM_FROM; third <= ASCII_NUM_TO; third++) { + pw6guess[2] = third; + for (fourth = ASCII_NUM_FROM; fourth <= ASCII_NUM_TO; + fourth++) { + pw6guess[3] = fourth; + for (fifth = ASCII_NUM_FROM; fifth <= ASCII_NUM_TO; + fifth++) { + pw6guess[4] = fifth; + for (sixth = ASCII_NUM_FROM; sixth <= ASCII_NUM_TO; + sixth++) { + pw6guess[5] = sixth; + + // generate hash and check + sha256_init(&ctx); + sha256_update(&ctx, (BYTE*)pw6guess, PWD6_LEN); + sha256_final(&ctx, buf); + + for (i = PWD4_NUMBERS; i < PWD_NUMBERS; i++) { + if (!checked[i] && + !memcmp(pwd[i], buf, + SHA256_BLOCK_SIZE)) { + checked[i] = 1; + printf("%s %d\n", pw6guess, i + 1); + fprintf(fp, "%s %d\n", pw6guess, i + 1); + } + } + }}}}}} + + // guess pure lowercase alphabets password, and first letter Capitalize + for (first = ASCII_LOWERCASE_FROM; first <= ASCII_LOWERCASE_TO; first++) { + pw6guess[0] = first; + for (second = ASCII_LOWERCASE_FROM; second <= ASCII_LOWERCASE_TO; second++) { + pw6guess[1] = second; + for (third = ASCII_LOWERCASE_FROM; third <= ASCII_LOWERCASE_TO; third++) { + pw6guess[2] = third; + for (fourth = ASCII_LOWERCASE_FROM; fourth <= ASCII_LOWERCASE_TO; + fourth++) { + pw6guess[3] = fourth; + for (fifth = ASCII_LOWERCASE_FROM; fifth <= ASCII_LOWERCASE_TO; + fifth++) { + pw6guess[4] = fifth; + for (sixth = ASCII_LOWERCASE_FROM; sixth <= ASCII_LOWERCASE_TO; + sixth++) { + pw6guess[5] = sixth; + + // generate hash and check + sha256_init(&ctx); + sha256_update(&ctx, (BYTE*)pw6guess, PWD6_LEN); + sha256_final(&ctx, buf); + + for (i = PWD4_NUMBERS; i < PWD_NUMBERS; i++) { + if (!checked[i] && + !memcmp(pwd[i], buf, + SHA256_BLOCK_SIZE)) { + checked[i] = 1; + printf("%s %d\n", pw6guess, i + 1); + fprintf(fp, "%s %d\n", pw6guess, i + 1); + } + } + // first lettle capitalize + pw6guess[0] = first - ASCII_LOWERCASE_FROM + ASCII_UPPERCASE_FROM; + // generate hash and check + sha256_init(&ctx); + sha256_update(&ctx, (BYTE*)pw6guess, PWD6_LEN); + sha256_final(&ctx, buf); + + for (i = PWD4_NUMBERS; i < PWD_NUMBERS; i++) { + if (!checked[i] && !memcmp(pwd[i], buf, SHA256_BLOCK_SIZE)) { + checked[i] = 1; + printf("%s %d\n", pw6guess, i + 1); + fprintf(fp, "%s %d\n", pw6guess, i + 1); + } + } + }}}}}} fclose(fp); } else if (argc == 2) { diff --git a/found_pwds.txt b/found_pwds.txt index 9cb17026acfbfdf6c0a40e069fd4661b79426374..4575b5b3228ea038ec93bb064f067b022377b72f 100644 --- a/found_pwds.txt +++ b/found_pwds.txt @@ -8,3 +8,4 @@ sp*t 1 spOt 4 spot 5 xunz 8 +Terenc 25