Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <stdio.h>
- #define EM(a) __asm __emit (a)
- #define X64_Start_with_CS(_cs) \
- { \
- EM(0x6A) EM(_cs) /* push _cs */ \
- EM(0xE8) EM(0) EM(0) EM(0) EM(0) /* call $+5 */ \
- EM(0x83) EM(4) EM(0x24) EM(5) /* add dword [esp], 5 */ \
- EM(0xCB) /* retf */ \
- }
- #define X64_End_with_CS(_cs) \
- { \
- EM(0xE8) EM(0) EM(0) EM(0) EM(0) /* call $+5 */ \
- EM(0xC7) EM(0x44) EM(0x24) EM(4) /* */ \
- EM(_cs) EM(0) EM(0) EM(0) /* mov dword [rsp + 4], _cs */ \
- EM(0x83) EM(4) EM(0x24) EM(0xD) /* add dword [rsp], 0xD */ \
- EM(0xCB) /* retf */ \
- }
- #define X64_Start() X64_Start_with_CS(0x33)
- #define X64_End() X64_End_with_CS(0x23)
- #define EMIT(a) __asm __emit (a)
- #define X64_Push(r) EM(0x48 | ((r) >> 3)) EM(0x50 | ((r) & 7))
- #define X64_Pop(r) EMIT(0x48 | ((r) >> 3)) EMIT(0x58 | ((r) & 7))
- #define REX_W EMIT(0x48) __asm
- bool __fastcall CheckPassword2(DWORD password) {
- __asm {
- mov ebx, 0
- }
- X64_Start();
- 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)
- X64_End();
- bool result = false;
- __asm {
- mov dword ptr[result], ebx
- }
- return result;
- }
- bool __fastcall CheckPassword(DWORD password) {
- __asm {
- mov ebx, 0
- }
- X64_Start();
- 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)
- X64_End();
- bool result = false;
- __asm {
- mov dword ptr [result], ebx
- }
- return result;
- }
- int main() {
- printf("Enter password: ");
- char password[255];
- scanf_s("%s", password);
- DWORD tmp, tmp2;
- RtlCopyMemory(&tmp, password, 4);
- RtlCopyMemory(&tmp2, password+4, 4);
- if (CheckPassword(tmp) && CheckPassword2(tmp2)) {
- printf("Good job!\n");
- system("pause");
- return 0;
- }
- printf("Nope\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement