Advertisement
Guest User

Untitled

a guest
Jul 7th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <windows.h>
  4.  
  5. unsigned char state[11] = {0};
  6. unsigned char state2[11] = {0};
  7.  
  8. unsigned char enc[11] = {0x56, 0x4B, 0x53, 0x2E, 0x38, 0x31, 0x3C, 0x34, 0x47, 0x51, 0};
  9. //unsigned char dec[11] = {0x57, 0x43, 0x52, 0x2D, 0x31, 0x31, 0x36, 0x36, 0x44, 0x53, 0x00};
  10. unsigned char dec[11] = {'W','C','R','-','1','1','6','6','D','S', 0};
  11.  
  12. unsigned char chk[11] = {0};
  13.  
  14. unsigned char dec2[11] = {0};
  15.  
  16. void dumpState()
  17. {
  18. printf("0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n", state2[0], state2[1], state2[2], state2[3], state2[4], state2[5], state2[6], state2[7], state2[8], state2[9], state2[10]);
  19. }
  20.  
  21. void bcrypt_process()
  22. {
  23. unsigned long len=11;
  24. unsigned long state_len = 11;
  25. unsigned char i, j;
  26. unsigned long k;
  27.  
  28. i = 0;
  29. j=0;
  30.  
  31. for (k = 0; k < len; k++) {
  32. unsigned char t;
  33.  
  34. i = (i + 1) % state_len;
  35. j = (j + state[i]) % state_len;
  36. t = state[j];
  37. state[j] = state[i];
  38. state[i] = t;
  39.  
  40. dec2[k] = enc[k] ^ state[(state[i] + state[j]) % state_len];
  41. }
  42. }
  43.  
  44. bool check()
  45. {
  46. memcpy(state, state2, 11);
  47. bcrypt_process();
  48. if(memcmp(dec2, dec, 11)==0)
  49. {
  50. dumpState();
  51. return true;
  52. }
  53. return false;
  54. }
  55. void allState(int i = 0)
  56. {
  57. if(i==11)
  58. {
  59. //dumpState();
  60. if(check())
  61. {
  62. //exit(1);
  63. }
  64. }
  65. for(int k=0;k<11;k++)
  66. {
  67. if(i==0)
  68. {
  69. printf("k = %d\n", k);
  70. }
  71. if(chk[k]>0)continue;
  72. state2[i]=k;
  73. chk[k]++;
  74. allState(i+1);
  75. chk[k]--;
  76. }
  77. }
  78.  
  79. int main(int argc, char* argv[])
  80. {
  81. //dumpState();
  82. allState();
  83. printf("%X\n", enc[1]);
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement