Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _XOPEN_SOURCE /*note, this software is 99% completed or should work, but it doesn't, cause when I unput my key and the salt into an if statement to test the key, it outputs me a different hash. */
- #include <stdio.h>
- #include <cs50.h>
- #include <string.h>
- #include <ctype.h>
- #include <crypt.h>
- #include <unistd.h>
- void crackPassword(string hash);
- int main(int argc, string argv[])
- {
- if(argc == 2)
- {
- crackPassword(argv[1]);
- }
- else
- {
- printf("Error. \n");
- }
- }
- void crackPassword(string hash)
- {
- char key[6] = "\0\0\0\0\0\0"; //5 Characters starting from A.. // Out Data;
- char salt[2] = "";
- salt[0] = hash[0];
- salt[1] = hash[1];
- int a[5]; a[0] = 0; a[1] = 0; a[2] = 0; a[3] = 0; a[4] = 0; //defines ints assigned to numbers (1-25 : A-Z |||||| 26 - 50 : a - z)
- bool boolLoop = true;
- do
- {
- a[0]++; //loops through every letter possible
- for(int y = 0; y < 4; y++ ) //calculates the change of the letters;
- {
- if (a[y] > 52)
- {
- a[y + 1]++;
- a[0] = 1;
- }
- }
- for(int i = 0; i < 5; i++)
- {
- int typeIn;
- if (a[i] < 26 && a[i] > 0)
- {
- typeIn = 64 + a[i];
- key[i] = (char)typeIn;
- }
- else if(a[i] > 25)
- {
- typeIn = 96 + a[i] - 25;
- key[i] = (char)typeIn;
- }
- }
- if(strcmp(crypt(key, salt), hash) == 0)
- {
- boolLoop = false;
- }
- if (a[4] > 50){
- printf("hash is fake");
- boolLoop = false;
- }
- }
- while(boolLoop == true); //a[4] > 50 -statement means, that the program has checked all the possible passwords.
- printf("%s \n",key);
- }
Add Comment
Please, Sign In to add comment