Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _XOPEN_SOURCE
- #include <unistd.h>
- #include <stdio.h>
- #include <string.h>
- #include <cs50.h>
- int main(int argc,string argv[])
- {
- if(argc!=2)//argc must be 2
- {
- printf("Usage: ./crack hash");
- return 1;
- }
- //password is a-z or A-Z
- string x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- int i=0;
- char s[2]="50",psw[5];//salt=50,password is 4 alphabet
- for(i=0;i<52;i++)
- {
- psw[0]=x[i];
- psw[1]='\0';
- if(strcmp(argv[1],crypt(psw,s))==0)
- {
- printf("%s\n",psw);
- break;
- }
- }
- for(i=0;i<52;i++)
- {
- psw[0]=x[i];
- for(int j=0;j<52;j++)
- {
- psw[0]=x[i];
- psw[1]=x[j];
- psw[2]='\0';
- if(strcmp(argv[1],crypt(psw,s))==0)
- {
- printf("%s\n",psw);
- break;
- }
- }
- }
- for(i=0;i<52;i++)
- {
- psw[0]=x[i];
- for(int j=0;j<52;j++)
- {
- psw[1]=x[j];
- for(int k=0;k<52;k++)
- {
- psw[0]=x[i];
- psw[1]=x[j];
- psw[2]=x[k];
- psw[3]='\0';
- if(strcmp(argv[1],crypt(psw,s))==0)
- {
- printf("%s\n",psw);
- break;
- }
- }
- }
- }
- for(i=0;i<52;i++)
- {
- psw[0]=x[i];
- for(int j=0;j<52;j++)
- {
- psw[1]=x[j];
- for(int k=0;k<52;k++)
- {
- psw[2]=x[k];
- for(int l=0;l<52;l++)
- {
- psw[0]=x[i];
- psw[1]=x[j];
- psw[2]=x[k];
- psw[3]=x[l];
- psw[4]='\0';
- if(strcmp(argv[1],crypt(psw,s))==0)
- {
- printf("%s\n",psw);
- break;
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment