Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <crypt.h>
  3. #include <time.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7.  
  8. using namespace std;
  9.  
  10.  
  11. /**
  12. * Password numbers of letters
  13. */
  14. #define PASSWORD_MAX_LENGTH 5
  15.  
  16.  
  17. /**
  18. * Password salt generated
  19. */
  20. char password_salt[] = "$6$SRM3J9B1$";
  21.  
  22.  
  23. /**
  24. * Password hash code
  25. */
  26. char password_hash_code[] = "$6$SRM3J9B1$Fk7jQICjeGcPWbNM8FsHCoSQPQ/SjzK/dtzy14oT62haJji6539o9qfD7oMpdkZgfajsQSThHvEvhhATZtIb00";
  27.  
  28.  
  29. /**
  30. * Password posible letter array
  31. */
  32. char charset[] = {'@','#','$','%','^','&','*',',','0','1','2','3','4','5','6','7','8','9','!','a', 'b', 'c', 'd', 'e', 'f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\0'};
  33.  
  34.  
  35.  
  36. /**
  37. * The string used for searching the password
  38. */
  39. char *actual_password ;
  40.  
  41.  
  42. /**
  43. * Hash code number of bytes
  44. */
  45. unsigned short int hash_code_length ;
  46.  
  47.  
  48. /**
  49. * Password posible letter array length
  50. */
  51. unsigned short int charset_length;
  52.  
  53.  
  54. unsigned int cnt = 10000;
  55.  
  56.  
  57. int check_password_validity(char *verified_password)
  58. {
  59. char *password_valid_response = crypt( verified_password , password_salt ) ;
  60. unsigned int index;
  61.  
  62. cnt ++ ;
  63.  
  64. if( cnt > 10000 )
  65. {
  66. cout << verified_password << endl ;
  67.  
  68. cnt = 0;
  69. }
  70.  
  71. for( index = 0 ; index < hash_code_length ; index++ )
  72. {
  73. if( password_valid_response[index] != password_hash_code[index] )
  74. {
  75. return 0;
  76. }
  77. }
  78.  
  79. return 1;
  80. }
  81.  
  82.  
  83. void search(int current_pos)
  84. {
  85. unsigned int search_index ;
  86. char send_password[] = "<:linux_ 0319:>";
  87.  
  88. if( current_pos == PASSWORD_MAX_LENGTH )
  89. {
  90. strcat(send_password,actual_password);
  91.  
  92. if( check_password_validity(send_password) )
  93. {
  94. cout << "Done: " << actual_password << endl ;
  95.  
  96. while(1)
  97. {
  98. search_index = 9 ;
  99. }
  100. }
  101. }
  102. else
  103. {
  104. for(search_index = 0; search_index < charset_length ; search_index++)
  105. {
  106. actual_password[current_pos] = charset[search_index] ;
  107.  
  108. if( current_pos < PASSWORD_MAX_LENGTH )
  109. {
  110. search(current_pos + 1);
  111. }
  112. }
  113. }
  114. }
  115.  
  116.  
  117. int main( void )
  118. {
  119.  
  120. hash_code_length = strlen(password_hash_code);
  121. charset_length = strlen(charset);
  122. actual_password = new char[PASSWORD_MAX_LENGTH];
  123. actual_password[PASSWORD_MAX_LENGTH] = '\0' ;
  124.  
  125. search(0);
  126.  
  127.  
  128. return 0;
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement