Guest User

Untitled

a guest
Mar 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #define _XOPEN_SOURCE
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <cs50.h>
  6.  
  7. int main(int argc,string argv[])
  8. {
  9. if(argc!=2)//argc must be 2
  10. {
  11. printf("Usage: ./crack hash");
  12. return 1;
  13. }
  14. //password is a-z or A-Z
  15. string x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  16. int i=0;
  17. char s[2]="50",psw[5];//salt=50,password is 4 alphabet
  18. for(i=0;i<52;i++)
  19. {
  20. psw[0]=x[i];
  21. psw[1]='\0';
  22. if(strcmp(argv[1],crypt(psw,s))==0)
  23. {
  24. printf("%s\n",psw);
  25. break;
  26. }
  27. }
  28. for(i=0;i<52;i++)
  29. {
  30. psw[0]=x[i];
  31. for(int j=0;j<52;j++)
  32. {
  33. psw[0]=x[i];
  34. psw[1]=x[j];
  35. psw[2]='\0';
  36. if(strcmp(argv[1],crypt(psw,s))==0)
  37. {
  38. printf("%s\n",psw);
  39. break;
  40. }
  41. }
  42. }
  43. for(i=0;i<52;i++)
  44. {
  45. psw[0]=x[i];
  46. for(int j=0;j<52;j++)
  47. {
  48. psw[1]=x[j];
  49. for(int k=0;k<52;k++)
  50. {
  51. psw[0]=x[i];
  52. psw[1]=x[j];
  53. psw[2]=x[k];
  54. psw[3]='\0';
  55. if(strcmp(argv[1],crypt(psw,s))==0)
  56. {
  57. printf("%s\n",psw);
  58. break;
  59. }
  60. }
  61. }
  62. }
  63.  
  64. for(i=0;i<52;i++)
  65. {
  66. psw[0]=x[i];
  67. for(int j=0;j<52;j++)
  68. {
  69. psw[1]=x[j];
  70. for(int k=0;k<52;k++)
  71. {
  72. psw[2]=x[k];
  73. for(int l=0;l<52;l++)
  74. {
  75. psw[0]=x[i];
  76. psw[1]=x[j];
  77. psw[2]=x[k];
  78. psw[3]=x[l];
  79. psw[4]='\0';
  80. if(strcmp(argv[1],crypt(psw,s))==0)
  81. {
  82. printf("%s\n",psw);
  83. break;
  84. }
  85. }
  86. }
  87. }
  88. }
  89.  
  90. }
Add Comment
Please, Sign In to add comment