Advertisement
Guest User

Untitled

a guest
Jul 30th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Windows.h>
  2. #include <stdio.h>
  3.  
  4. #define EM(a) __asm __emit (a)
  5.  
  6. #define X64_Start_with_CS(_cs) \
  7. { \
  8.     EM(0x6A) EM(_cs)                     /*  push   _cs                   */ \
  9.     EM(0xE8) EM(0) EM(0) EM(0) EM(0)     /*  call   $+5                   */ \
  10.     EM(0x83) EM(4) EM(0x24) EM(5)        /*  add    dword [esp], 5        */ \
  11.     EM(0xCB)                             /*  retf                         */ \
  12. }
  13.  
  14. #define X64_End_with_CS(_cs) \
  15. { \
  16.     EM(0xE8) EM(0) EM(0) EM(0) EM(0)     /*  call   $+5                   */ \
  17.     EM(0xC7) EM(0x44) EM(0x24) EM(4)     /*                               */ \
  18.     EM(_cs) EM(0) EM(0) EM(0)            /*  mov    dword [rsp + 4], _cs  */ \
  19.     EM(0x83) EM(4) EM(0x24) EM(0xD)      /*  add    dword [rsp], 0xD      */ \
  20.     EM(0xCB)                             /*  retf                         */ \
  21. }
  22.  
  23. #define X64_Start() X64_Start_with_CS(0x33)
  24. #define X64_End() X64_End_with_CS(0x23)
  25.  
  26. #define EMIT(a) __asm __emit (a)
  27. #define X64_Push(r) EM(0x48 | ((r) >> 3)) EM(0x50 | ((r) & 7))
  28. #define X64_Pop(r) EMIT(0x48 | ((r) >> 3)) EMIT(0x58 | ((r) & 7))
  29. #define REX_W EMIT(0x48) __asm
  30.  
  31. bool __fastcall CheckPassword2(DWORD password) {
  32.  
  33.     __asm {
  34.         mov ebx, 0
  35.     }
  36.  
  37.     X64_Start();
  38.  
  39.     EM(0x48) EM(0x89) EM(0xC8) EM(0x48) EM(0xC7) EM(0xC6) EM(0x68) EM(0x46) EM(0x34) EM(0x7A) EM(0x48) EM(0x39) EM(0xF0) EM(0x48) EM(0xC7) EM(0xC2) EM(0x01) EM(0x00) EM(0x00) EM(0x00) EM(0x48) EM(0x0F) EM(0x44) EM(0xDA)
  40.  
  41.     X64_End();
  42.  
  43.     bool result = false;
  44.  
  45.     __asm {
  46.         mov dword ptr[result], ebx
  47.     }
  48.  
  49.     return result;
  50. }
  51.  
  52.  
  53. bool __fastcall CheckPassword(DWORD password) {
  54.  
  55.     __asm {
  56.         mov ebx, 0
  57.     }
  58.  
  59.     X64_Start();
  60.    
  61.     EM(0x48) EM(0x89) EM(0xC8) EM(0x48) EM(0xC7) EM(0xC6) EM(0x58) EM(0x44) EM(0x70) EM(0x34) EM(0x48) EM(0x39) EM(0xF0) EM(0x48) EM(0xC7) EM(0xC2) EM(0x01) EM(0x00) EM(0x00) EM(0x00) EM(0x48) EM(0x0F) EM(0x44) EM(0xDA)
  62.  
  63.     X64_End();
  64.  
  65.     bool result = false;
  66.  
  67.     __asm {
  68.         mov dword ptr [result], ebx
  69.     }
  70.  
  71.     return result;
  72. }
  73.  
  74. int main() {
  75.  
  76.     printf("Enter password: ");
  77.  
  78.     char password[255];
  79.     scanf_s("%s", password);
  80.  
  81.     DWORD tmp, tmp2;
  82.     RtlCopyMemory(&tmp, password, 4);
  83.     RtlCopyMemory(&tmp2, password+4, 4);
  84.    
  85.  
  86.     if (CheckPassword(tmp) && CheckPassword2(tmp2)) {
  87.         printf("Good job!\n");
  88.         system("pause");
  89.         return 0;
  90.     }
  91.  
  92.     printf("Nope\n");
  93.     system("pause");
  94.     return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement