Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <stdio.h>
- #include <string.h>
- #define PASSWORD ".RACKME$4c"
- typedef void(__fastcall* CodeFunc_t)(char* password, char* key);
- #define CODE_SIZE 48
- char decryptionCode[CODE_SIZE] = {
- 0x77, 0x30, 0x77, 0x29, 0x47, 0xfe, 0xfe, 0xfe, 0xfe,
- 0x46, 0xfe, 0xfe, 0xfe, 0xfe, 0x45, 0xfe, 0xfe, 0xfe, 0xfe,
- 0x74, 0xba, 0xf0, 0xff, 0x74, 0xa2, 0xf1, 0xff, 0xcf, 0x26,
- 0x76, 0xba, 0xf0, 0xff, 0xbf, 0x7d, 0x7, 0xf7, 0x8b, 0x12, 0x8a,
- 0xfe, 0x46, 0xfe, 0xfe, 0xfe, 0xfe, 0x3d
- };
- char decryptionKey[24] = {
- 0xd3, 0xd6, 0xd3, 0xce, 0xd7, 0xd0, 0xd9, 0xc8, 0xd1, 0xdd, 0xd7,
- 0xd9, 0xce, 0xcd, 0xcf, 0xc6, 0xd0, 0xc7, 0xc7, 0xc9, 0xca, 0xc4,
- 0xc9, 0xd3
- };
- void decryptKey() {
- for (int i = 0; i < 24; i++) {
- decryptionKey[i] ^= 0xBE;
- }
- }
- void decryptCode() {
- for (int i = 0; i < CODE_SIZE; i++) {
- decryptionCode[i] ^= 0xFE;
- }
- }
- bool IsPasswordRight(char* password) {
- if (strlen(password) != 24) {
- return false;
- }
- decryptKey();
- decryptCode();
- void* allocatedCode = VirtualAlloc(0, CODE_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
- CopyMemory(allocatedCode, decryptionCode, CODE_SIZE);
- char *tmpPassword = (char*)VirtualAlloc(0, 9, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
- ZeroMemory(tmpPassword, 9);
- CopyMemory(tmpPassword, password, 9);
- CodeFunc_t func = (CodeFunc_t)(allocatedCode);
- func(tmpPassword, (char*)decryptionKey);
- int res = strcmp(PASSWORD, tmpPassword);
- VirtualFree(tmpPassword, 9, MEM_RELEASE);
- VirtualFree(allocatedCode, CODE_SIZE, MEM_RELEASE);
- return (res == 0);
- }
- bool IsDebugged() {
- bool detected = false;
- __asm {
- mov eax, fs:[0x30]
- mov al, [eax + 0x2]
- mov detected, al
- };
- return detected;
- }
- int main() {
- char *string = (char*)malloc(120);
- ZeroMemory(string, 120);
- printf("Enter password: ");
- scanf_s("%s", string);
- if (IsPasswordRight(string) && !IsDebugged()) {
- printf("Good!\n");
- system("pause");
- return 0;
- }
- printf("Wrong password!\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement