Advertisement
EddyCZ

crc

Sep 28th, 2019
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. nt CheckSn(const char* input)
  2. {
  3.     //Encrypted key for RC4;
  4.     int k[24] = {
  5.     -2028,
  6. -1927,
  7. -1978,
  8. 2014,
  9. 1964,
  10. 2047,
  11. -2011,
  12. 2019,
  13. 1988,
  14. -2022,
  15. 2020,
  16. -2020,
  17. -2021,
  18. 1991,
  19. 1992,
  20. -1968,
  21. -2025,
  22. 2012,
  23. -1964,
  24. -1964,
  25. 1944,
  26. -2012,
  27. 1990,
  28. 1993,
  29.     };
  30.     char kbuff[24];
  31.     for (int i = 0; i < sizeof(kbuff); i++)
  32.     {
  33.         kbuff[i] = (char)0x7c9 ^ k[i];
  34.     }
  35.  
  36.     char* kDec = rc4.Decrypt(kbuff, input);
  37.  
  38.     //Genrate RSA seed
  39.     int seed = 0; //RSA seed
  40.     for (int i = 0; i < 24; i++)
  41.     {
  42.         seed ^= (int)kDec[i] << 8;
  43.     }
  44.  
  45.     //Encrypted flag
  46.     unsigned __int64 flEnc[38] = {
  47. 1366097814,
  48. 2120983132,
  49. 11313650,
  50. 11313650,
  51. 1147720706,
  52. 1381141506,
  53. 534044772,
  54. 2120983132,
  55. 11313650,
  56. 1000603513,
  57. 1147720706,
  58. 2141013828,
  59. 2120983132,
  60. 1381141506,
  61. 166339272,
  62. 397371820,
  63. 1381141506,
  64. 2141013828,
  65. 1424449630,
  66. 1381141506,
  67. 336182013,
  68. 1303618044,
  69. 584361135,
  70. 1381141506,
  71. 534044772,
  72. 1147720706,
  73. 336182013,
  74. 11313650,
  75. 1273651409,
  76. 1381141506,
  77. 1828599282,
  78. 1273651409,
  79. 1273651409,
  80. 1424449630,
  81. 303606192,
  82. 1732470655,
  83. 1925038450,
  84.     };
  85.  
  86.     //RSA
  87.     RSA_PARAM r;
  88.     r = RsaGetParam(seed);
  89.     char decoded[38];
  90.     for (int i = 0; i < sizeof(decoded); i++)
  91.     {
  92.         decoded[i] = (char)(PowMod(flEnc[i], r.d, r.n));
  93.     }
  94.     char* flDec = (char*)decoded;
  95.  
  96.     if (Crc32(flDec, 38, 0x7c9) == -622969371)
  97.     {
  98.         strcpy(flagCorrect, flDec);
  99.         return 1;
  100.     }
  101.  
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement