-
-
Save Hamleyburger/59754b89c40284437b28a1287c065c62 to your computer and use it in GitHub Desktop.
#include <cs50.h> | |
#include <stdio.h> | |
#include <crypt.h> | |
#include <string.h> | |
#include <math.h> | |
void allpossible1(string hash, string salt); | |
void allpossible2(string hash, string salt); | |
void allpossible3(string hash, string salt); | |
void allpossible4(string hash, string salt); | |
void allpossible5(string hash, string salt); | |
bool checkarg(int argc); | |
bool comparekey(string chars, string hash, string salt); | |
int main(int argc, string argv[]) | |
{ | |
if (!checkarg(argc)) | |
{ | |
printf("Usage: ./crack hash\n"); | |
return 1; | |
} | |
// Two strings are given as arguments | |
printf("to test for word %s, copy paste: %s\n", "Aa", crypt("Aa", argv[1])); | |
allpossible1(argv[1], argv[1]); | |
allpossible2(argv[1], argv[1]); | |
allpossible3(argv[1], argv[1]); | |
allpossible4(argv[1], argv[1]); | |
allpossible5(argv[1], argv[1]); | |
} | |
bool comparekey(string chars, string hash, string salt) | |
{ | |
if (strcmp(crypt(chars, salt), hash) == 0) | |
{ | |
printf("%s\n", chars); | |
exit(0); | |
return true; | |
} | |
return false; | |
} | |
bool checkarg(int argc) | |
{ | |
if (argc != 2) | |
{ | |
return false; | |
} | |
else | |
{ | |
return true; | |
} | |
} | |
void allpossible1(string hash, string salt) | |
{ | |
int places = 1; | |
char chars[places]; | |
char letters[] = {'e', 'E', 't', 'T', 'a', 'A', 'o', 'O', 'i', 'I', 'n', 'N', 's', 'S', 'r', 'R', 'h', 'H', 'l', 'L', 'd', 'D', 'c', 'C', 'u', 'U', 'm', 'M', 'f', 'F', 'p', 'P', 'g', 'G', 'w', 'W', 'y', 'Y', 'b', 'B', 'v', 'V', 'k', 'K', 'x', 'X', 'j', 'J', 'q', 'Q', 'z', 'Z'}; | |
int alphalength = 52; | |
// "Forever" loop. | |
for (int i = 0; i < alphalength; i++) | |
{ | |
// Keep looping first char through alphabet and print each iteration | |
chars[0] = letters[i]; | |
if(comparekey(chars, hash, salt) == true) | |
{ | |
exit(0); | |
} | |
//printf("%s\n", chars); | |
} | |
} | |
void allpossible2(string hash, string salt) | |
{ | |
int places = 2; | |
char chars[places]; | |
char letters[] = {'e', 'E', 't', 'T', 'a', 'A', 'o', 'O', 'i', 'I', 'n', 'N', 's', 'S', 'r', 'R', 'h', 'H', 'l', 'L', 'd', 'D', 'c', 'C', 'u', 'U', 'm', 'M', 'f', 'F', 'p', 'P', 'g', 'G', 'w', 'W', 'y', 'Y', 'b', 'B', 'v', 'V', 'k', 'K', 'x', 'X', 'j', 'J', 'q', 'Q', 'z', 'Z'}; | |
int alphalength = 52; // Der må være en bedre måde at definere længden på letters. | |
// Ved ikke om jeg skal bruge dem | |
int iterations[places]; | |
// Fill interations with 0s for starters | |
for (int y = 0; y < places; y++) | |
{ | |
iterations[y] = 0; | |
} | |
for (int i = 0; i < alphalength; i++) | |
{ | |
// Keep looping first char through alphabet and print each iteration | |
chars[0] = letters[i]; | |
for (int j = 0; j < alphalength; j++) | |
{ | |
chars[1] = letters[j]; | |
if(comparekey(chars, hash, salt) == true) | |
{ | |
exit(0); | |
} | |
//printf("%s\n", chars); | |
} | |
} | |
} | |
void allpossible3(string hash, string salt) | |
{ | |
int places = 3; | |
char chars[places]; | |
char letters[] = {'e', 'E', 't', 'T', 'a', 'A', 'o', 'O', 'i', 'I', 'n', 'N', 's', 'S', 'r', 'R', 'h', 'H', 'l', 'L', 'd', 'D', 'c', 'C', 'u', 'U', 'm', 'M', 'f', 'F', 'p', 'P', 'g', 'G', 'w', 'W', 'y', 'Y', 'b', 'B', 'v', 'V', 'k', 'K', 'x', 'X', 'j', 'J', 'q', 'Q', 'z', 'Z'}; | |
int alphalength = 52; // Der må være en bedre måde at definere længden på letters. | |
// Ved ikke om jeg skal bruge dem | |
int iterations[places]; | |
// Fill interations with 0s for starters | |
for (int y = 0; y < places; y++) | |
{ | |
iterations[y] = 0; | |
} | |
for (int i = 0; i < alphalength; i++) | |
{ | |
// Keep looping first char through alphabet and print each iteration | |
chars[0] = letters[i]; | |
for (int j = 0; j < alphalength; j++) | |
{ | |
chars[1] = letters[j]; | |
for (int k = 0; k < alphalength; k++) | |
{ | |
chars[2] = letters[k]; | |
if(comparekey(chars, hash, salt) == true) | |
{ | |
exit(0); | |
} | |
//printf("%s\n", chars); | |
} | |
} | |
} | |
} | |
void allpossible4(string hash, string salt) | |
{ | |
int places = 4; | |
char chars[places]; | |
char letters[] = {'e', 'E', 't', 'T', 'a', 'A', 'o', 'O', 'i', 'I', 'n', 'N', 's', 'S', 'r', 'R', 'h', 'H', 'l', 'L', 'd', 'D', 'c', 'C', 'u', 'U', 'm', 'M', 'f', 'F', 'p', 'P', 'g', 'G', 'w', 'W', 'y', 'Y', 'b', 'B', 'v', 'V', 'k', 'K', 'x', 'X', 'j', 'J', 'q', 'Q', 'z', 'Z'}; | |
int alphalength = 52; // Der må være en bedre måde at definere længden på letters. | |
// Ved ikke om jeg skal bruge dem | |
int iterations[places]; | |
// Fill interations with 0s for starters | |
for (int y = 0; y < places; y++) | |
{ | |
iterations[y] = 0; | |
} | |
for (int i = 0; i < alphalength; i++) | |
{ | |
// Keep looping first char through alphabet and print each iteration | |
chars[0] = letters[i]; | |
for (int j = 0; j < alphalength; j++) | |
{ | |
chars[1] = letters[j]; | |
for (int k = 0; k < alphalength; k++) | |
{ | |
chars[2] = letters[k]; | |
for (int l = 0; l < alphalength; l++) | |
{ | |
chars[3] = letters[l]; | |
if(comparekey(chars, hash, salt) == true) | |
{ | |
exit(0); | |
} | |
//printf("%s\n", chars); | |
} | |
} | |
} | |
} | |
} | |
void allpossible5(string hash, string salt) | |
{ | |
int places = 5; | |
char chars[places]; | |
char letters[] = {'e', 'E', 't', 'T', 'a', 'A', 'o', 'O', 'i', 'I', 'n', 'N', 's', 'S', 'r', 'R', 'h', 'H', 'l', 'L', 'd', 'D', 'c', 'C', 'u', 'U', 'm', 'M', 'f', 'F', 'p', 'P', 'g', 'G', 'w', 'W', 'y', 'Y', 'b', 'B', 'v', 'V', 'k', 'K', 'x', 'X', 'j', 'J', 'q', 'Q', 'z', 'Z'}; | |
int alphalength = 52; // Der må være en bedre måde at definere længden på letters. | |
// Ved ikke om jeg skal bruge dem | |
int iterations[places]; | |
// Fill interations with 0s for starters | |
for (int y = 0; y < places; y++) | |
{ | |
iterations[y] = 0; | |
} | |
for (int i = 0; i < alphalength; i++) | |
{ | |
// Keep looping first char through alphabet and print each iteration | |
chars[0] = letters[i]; | |
for (int j = 0; j < alphalength; j++) | |
{ | |
chars[1] = letters[j]; | |
for (int k = 0; k < alphalength; k++) | |
{ | |
chars[2] = letters[k]; | |
for (int l = 0; l < alphalength; l++) | |
{ | |
chars[3] = letters[l]; | |
for (int m = 0; m < alphalength; m++) | |
{ | |
chars[4] = letters[m]; | |
if(comparekey(chars, hash, salt) == true) | |
{ | |
exit(0); | |
} | |
//printf("%s\n", chars); | |
} | |
} | |
} | |
} | |
} | |
} |
i think you are really clever
and i think that you forget to
but the header for
line 49 >>>>exit
which is #include <stdlib.h>
i think i will be really thankful if i have a friend that helps me to learn programming and dimintions me to the correct way
if you agreed (my name is Ahmed , i m learning programming alone ("online ....") , im the only one of my friend who love programming from i started to learn hacking when i was young but ya i found that it is not my way , so can you be my programmer friend and thanks
im waiting for your answer! )
Hi! ^^ I'm very flattered. I don't know if I'd be of a lot of help though. I'm still working on my final project. I'm taking all the time that I want to learn as much as I can from the situation. Also I only have time for coding a few hours a week because I'm actually working with something completely different. But feel free to write me anytime :D
OK, thanks alot and im same thing im on the last final project :) as i have only one friend who is learning programming
and while im solving problems or learning i find things i cant understand but he is learning some different languages
but i have one problem here :(
i don't open GitHub a lot and maybe i dont know how to use it so if you have any popular communication way that i can communicate with you on it
and thanks ,for a new friend
and
Of course, you will be a great help even if you help me with something small. I also spend all my spare time in programming, I have about two hours a day for programming
but i need any other communication way
and
Of course, you will be a great help even if you help me with something small. I also spend all my spare time in programming, I have about two hours a day for programming
Hey! Sure. Discord id: Alma#0240
ok, i sent you a request on Discord Agree it
and if it didnt come so my
Discord id: HOK4AWII#6770
i think i will be really thankful if i have a friend that helps me to learn programming and dimintions me to the correct way
if you agreed (my name is Ahmed , i m learning programming alone ("online ....") , im the only one of my friend who love programming from i started to learn hacking when i was young but ya i found that it is not my way , so can you be my programmer friend and thanks
im waiting for your answer! )