Created
May 31, 2017 10:15
-
-
Save shivamg7/dbb85b46aff01fa657170961fa12072d to your computer and use it in GitHub Desktop.
Cracks a three character password which is encrytped usinf DES useed in linux systems. Uses a generate program which creates all the combinations possible for the three characer password.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _XOPEN_SOURCE | |
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
#include <ctype.h> | |
#include <unistd.h> | |
//char name[7312000][5]; | |
int generate(char hash[]) | |
{ | |
//sFILE *f; | |
char name[5]; | |
int i,j,k,l; | |
int num[52]={65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83, | |
84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108, | |
109,110,111,112,113,114,115,116,117,118,119,120,121,122}; | |
name[1]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
// printf("%s\n",crypt(name,"50")); | |
if(strcmp(hash,crypt(name,"50"))==0) | |
{ | |
printf("%s\n",name); | |
return 0; | |
} | |
} | |
name[2]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
for(j=0;j<52;j++) | |
{ | |
name[1]=num[j]; | |
if(strcmp(hash,crypt(name,"50"))==0) | |
{ | |
printf("%s\n",name); | |
return 0; | |
} | |
} | |
} | |
name[3]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
for(j=0;j<52;j++) | |
{ | |
name[1]=num[j]; | |
for(k=0;k<52;k++) | |
{ | |
name[2]=num[k]; | |
if(strcmp(hash,crypt(name,"50"))==0) | |
{ | |
printf("%s\n",name); | |
return 0; | |
} | |
} | |
} | |
} | |
name[4]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
for(j=0;j<52;j++) | |
{ | |
name[1]=num[j]; | |
for(k=0;k<52;k++) | |
{ | |
name[2]=num[k]; | |
for(l=0;l<52;l++) | |
{ | |
name[3]=num[l]; | |
if(strcmp(hash,crypt(name,"50"))==0) | |
{ | |
printf("%s\n",name); | |
return 0; | |
} | |
} | |
} | |
} | |
} | |
// fclose(f); | |
return 0; | |
} | |
int main(int argc, char* argv[]) | |
{ | |
//Ensure proper usage | |
if(argc!=2) | |
{ | |
printf("Usage: crack HashPassword\n"); | |
return 1; | |
} | |
// printf("%s",argv[1]); | |
generate(argv[1]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
FILE *f; | |
char name[5]; | |
int i,j,k;//,l; | |
int num[52]={65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83, | |
84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108, | |
109,110,111,112,113,114,115,116,117,118,119,120,121,122}; | |
if ((f = fopen("feed.txt", "w")) == NULL) | |
{ | |
printf("Error"); | |
return 1; | |
} | |
name[1]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
fprintf(f,"%s\n",name); | |
} | |
name[2]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
for(j=0;j<52;j++) | |
{ | |
name[1]=num[j]; | |
fprintf(f,"%s\n",name); | |
} | |
} | |
name[3]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
for(j=0;j<52;j++) | |
{ | |
name[1]=num[j]; | |
for(k=0;k<52;k++) | |
{ | |
name[2]=num[k]; | |
fprintf(f,"%s\n",name); | |
} | |
} | |
} | |
/* name[4]='\0'; | |
for(i=0;i<52;i++) | |
{ | |
name[0]=num[i]; | |
for(j=0;j<52;j++) | |
{ | |
name[1]=num[j]; | |
for(k=0;k<52;k++) | |
{ | |
name[2]=num[k]; | |
for(l=0;l<52;l++) | |
{ | |
name[3]=num[l]; | |
fprintf(f,"%s\n",name); | |
} | |
} | |
} | |
} | |
*/ | |
fclose(f); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment