Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PROGRAM TO CRACK PASSWORD MADE FROM C's DES bases crypt function
- //importing libraries
- #define _XOPEN_SOURCE
- #include <unistd.h>
- #include <stdio.h>
- #include <cs50.h>
- #include <ctype.h>
- #include <string.h>
- int main(int argc, string argv[])
- {
- if (argc != 2) //to check if only two arguments are given
- {
- printf("Give only two arguments, the filename and hashed password.\n");
- return 1;
- }
- char key[] = {argv[1][0], argv[1][1]}; //to etract key from hashed password
- char pass[6]; //making a temporary array to hold 5 characters
- string testpass; //string to hold testing password
- while (true)
- {
- for (pass[0] = 'A'; pass[0] <= 'z'; pass[0]++) //condition to crack one lettered password
- {
- if (isalpha(pass[0]))
- {
- pass[1] = '\0';
- testpass = pass;
- if (strcmp(crypt(testpass, key), argv[1]) == 0)
- {
- printf("%s\n", testpass);
- return 0;
- break;
- }
- }
- }
- for (pass[0] = 'A'; pass[0] <= 'z'; pass[0]++) //condition to crack two lettered password
- {
- if(isalpha(pass[0]))
- {
- for (pass[1] = 'A'; pass[1] <= 'z'; pass[1]++)
- {
- if (isalpha(pass[1]))
- {
- pass[2] = '\0';
- testpass = pass;
- if (strcmp(crypt(testpass, key), argv[1]) == 0)
- {
- printf("%s\n", testpass);
- return 0;
- break;
- }
- }
- }
- }
- }
- for (pass[0] = 'A'; pass[0] <= 'z'; pass[0]++) //condition to crack three lettered password
- {
- if (isalpha(pass[0]))
- {
- for (pass[1] = 'A'; pass[1] <= 'z'; pass[1]++)
- {
- if (isalpha(pass[1]))
- {
- for (pass[2] = 'A'; pass[2] <= 'z'; pass[2]++)
- {
- if (isalpha(pass[2]))
- {
- pass[3] = '\0';
- testpass = pass;
- if (strcmp(crypt(testpass, key), argv[1]) == 0)
- {
- printf("%s\n", testpass);
- return 0;
- break;
- }
- }
- }
- }
- }
- }
- }
- for (pass[0] = 'A'; pass[0] <= 'z'; pass[0]++) //condition to crack four lettered password
- {
- if (isalpha(pass[0]))
- {
- for (pass[1] = 'A'; pass[1] <= 'z'; pass[1]++)
- {
- if (isalpha(pass[1]))
- {
- for (pass[2] = 'A'; pass[2] <= 'z'; pass[2]++)
- {
- if (isalpha(pass[2]))
- {
- for (pass[3] = 'A'; pass[3] <= 'z'; pass[3]++)
- {
- if (isalpha(pass[3]))
- {
- pass[4] = '\0';
- testpass = pass;
- if (strcmp(crypt(testpass, key), argv[1]) == 0)
- {
- printf("%s\n", testpass);
- return 0;
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- for (pass[0] = 'A'; pass[0] <= 'z'; pass[0]++) //condition to crack five lettered password
- {
- if (isalpha(pass[0]))
- {
- for (pass[1] = 'A'; pass[1] <= 'z'; pass[1]++)
- {
- if (isalpha(pass[1]))
- {
- for (pass[2] = 'A'; pass[2] <= 'z'; pass[2]++)
- {
- if (isalpha(pass[2]))
- {
- for (pass[3] = 'A'; pass[3] <= 'z'; pass[3]++)
- {
- if (isalpha(pass[3]))
- {
- for (pass[4] = 'A'; pass[4] <= 'z'; pass[4]++)
- {
- if (isalpha(pass[4]))
- {
- pass[5] = '\0';
- testpass = pass;
- if (strcmp(crypt(testpass, key), argv[1]) == 0)
- {
- printf("%s\n", testpass);
- return 0;
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment