diff --git a/found_pwds.txt b/found_pwds.txt new file mode 100644 index 0000000000000000000000000000000000000000..b283ff659919c41ad5dbe7bf2be28d8a34d30986 --- /dev/null +++ b/found_pwds.txt @@ -0,0 +1,10 @@ +cane 1 +lskr 9 +oaa1 8 +papa 4 +xiao 5 +yaH* 6 +yaho 3 +zoNg 7 +zonG 10 +zong 2 \ No newline at end of file diff --git a/project2 b/project2 index 5cde6bbdd2e4d3a8a9726f666a8e9921b454c197..118862282b9d49b9d818bb17c1ba50f63726f063 100755 Binary files a/project2 and b/project2 differ diff --git a/project2.c b/project2.c index c80b3aa2b39e34fd885f01b084a5fdc8d0a74337..3070209897a94e07b5d50c0fd24a8c22666eb481 100644 --- a/project2.c +++ b/project2.c @@ -14,19 +14,53 @@ bool compare(); int main(int argc, char* argv[]){ //no arguements provided scenario + if(argc == 1){ + unsigned char target[PASSWORD_NUM][SHA256_BLOCK_SIZE]; + FILE* pwd4sha256 = fopen("pwd4sha256", "rb"); + for (int i = 0; i < PASSWORD_NUM; i++){ + fread(target[i], sizeof(target[i]), 1, pwd4sha256); + } - unsigned char target[PASSWORD_NUM][SHA256_BLOCK_SIZE]; - FILE* pwd4sha256 = fopen("pwd4sha256", "rb"); - for (int i = 0; i < PASSWORD_NUM; i++){ - fread(target[i], sizeof(target[i]), 1, pwd4sha256); - } + char test_word[6]; - char test_word[] = "xiao"; + for(int i = 32; i < 127; i++){ + for(int j = 32; j < 127; j++){ + for(int k = 32; k < 127; k++){ + for(int l = 32; l < 127; l++){ + test_word[0] = i; + test_word[1] = j; + test_word[2] = k; + test_word[3] = l; + test_word[4] = '\0'; + compare(test_word, target); + } + } + } + } + } - compare(test_word, target); //one arguement scenario + if( argc == 2){ + int count = atoi(argv[1]); + char guess[10]; + FILE* common_passwords; + common_passwords = fopen("common_passwords.txt", "r"); + + while(count){ + fgets(guess, 10, common_passwords); + guess[4]='\0'; + printf("%s\n", guess); + count--; + } + + fclose(common_passwords); + } + //two arguements scenarios + + + return 0; }