Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Windows.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. #define PASSWORD ".RACKME$4c"
  6.  
  7. typedef void(__fastcall* CodeFunc_t)(char* password, char* key);
  8.  
  9. #define CODE_SIZE 48
  10.  
  11. char decryptionCode[CODE_SIZE] = {
  12.     0x77, 0x30, 0x77, 0x29, 0x47, 0xfe, 0xfe, 0xfe, 0xfe,
  13.     0x46, 0xfe, 0xfe, 0xfe, 0xfe, 0x45, 0xfe, 0xfe, 0xfe, 0xfe,
  14.     0x74, 0xba, 0xf0, 0xff, 0x74, 0xa2, 0xf1, 0xff, 0xcf, 0x26,
  15.     0x76, 0xba, 0xf0, 0xff, 0xbf, 0x7d, 0x7, 0xf7, 0x8b, 0x12, 0x8a,
  16.     0xfe, 0x46, 0xfe, 0xfe, 0xfe, 0xfe, 0x3d
  17. };
  18.  
  19. char decryptionKey[24] = {
  20.     0xd3, 0xd6, 0xd3, 0xce, 0xd7, 0xd0, 0xd9, 0xc8, 0xd1, 0xdd, 0xd7,
  21.     0xd9, 0xce, 0xcd, 0xcf, 0xc6, 0xd0, 0xc7, 0xc7, 0xc9, 0xca, 0xc4,
  22.     0xc9, 0xd3
  23. };
  24.  
  25. void decryptKey() {
  26.     for (int i = 0; i < 24; i++) {
  27.         decryptionKey[i] ^= 0xBE;
  28.     }
  29. }
  30.  
  31. void decryptCode() {
  32.     for (int i = 0; i < CODE_SIZE; i++) {
  33.         decryptionCode[i] ^= 0xFE;
  34.     }
  35. }
  36.  
  37. bool IsPasswordRight(char* password) {
  38.    
  39.     if (strlen(password) != 24) {
  40.         return false;
  41.     }
  42.  
  43.  
  44.     decryptKey();
  45.     decryptCode();
  46.    
  47.     void* allocatedCode = VirtualAlloc(0, CODE_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
  48.     CopyMemory(allocatedCode, decryptionCode, CODE_SIZE);
  49.  
  50.     char *tmpPassword = (char*)VirtualAlloc(0, 9, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
  51.     ZeroMemory(tmpPassword, 9);
  52.     CopyMemory(tmpPassword, password, 9);
  53.  
  54.     CodeFunc_t func = (CodeFunc_t)(allocatedCode);
  55.     func(tmpPassword, (char*)decryptionKey);
  56.  
  57.     int res = strcmp(PASSWORD, tmpPassword);
  58.  
  59.     VirtualFree(tmpPassword, 9, MEM_RELEASE);
  60.     VirtualFree(allocatedCode, CODE_SIZE, MEM_RELEASE);
  61.  
  62.  
  63.     return (res == 0);
  64. }
  65.  
  66. bool IsDebugged() {
  67.     bool detected = false;
  68.  
  69.     __asm {
  70.         mov eax, fs:[0x30]
  71.         mov al, [eax + 0x2]
  72.         mov detected, al
  73.     };
  74.  
  75.     return detected;
  76. }
  77.  
  78. int main() {
  79.  
  80.     char *string = (char*)malloc(120);
  81.     ZeroMemory(string, 120);
  82.  
  83.     printf("Enter password: ");
  84.     scanf_s("%s", string);
  85.  
  86.     if (IsPasswordRight(string) && !IsDebugged()) {
  87.         printf("Good!\n");
  88.         system("pause");
  89.         return 0;
  90.     }
  91.  
  92.     printf("Wrong password!\n");
  93.     system("pause");
  94.  
  95.     return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement