diff --git a/crack.c b/crack.c index ba536d03696d322b29c7f7f1d11d290f7fa3b8aa..6b0e76b6f637619702b888feb3dc9da204357186 100644 --- a/crack.c +++ b/crack.c @@ -10,6 +10,7 @@ int exist[30]; BYTE old[6]; int count = 0; +int exist3[10000]; //function to generate lower character strings of length 6 for random brute force: Got 8 passwords @@ -265,13 +266,13 @@ int main(int argc, char * argv[]) { int i, a = 0, b = 0; fseek(password_file, 0L, SEEK_END); int sz = ftell(password_file); - rewind(password_file); int hashes[sz / 32][32]; unsigned char buff[sz]; + fread(buff, sizeof(buff), 1, password_file); for (i = 0; i < sz; i++) { - if (i % 32 == 0) { + if (i % 32 == 0 && i>0) { a++; b = 0; @@ -281,6 +282,34 @@ int main(int argc, char * argv[]) { b++; } + bool cracked=true; + FILE *word_list; + SHA256_CTX ctx; + BYTE buffer[SHA256_BLOCK_SIZE]; + word_list=fopen(argv[2],"rb"); + while( fscanf(word_list, "%s", word) != EOF ){ + sha256_init(&ctx); + sha256_update(&ctx, word, strlen(word)); + sha256_final(&ctx, buffer); + for (int i = 0; i < sz/32; i++) { + cracked = true; + for (int j = 0; j < 32; j++) { + if (buffer[j] != hashes[i][j]) { + cracked = false; + break; + } + } + if (cracked == true && exist3[i+1]!=1) { + count++; + ctx.data[strlen(word)] = '\0'; + exist3[i+1]=1; + printf("%s %d\n", ctx.data, i+1); + } + } + + } + + } return 0;