#include #include #include #include #include #define NUM_OPTIONS 5 #define MAX_INPUT_LENGTH 100 int display_menu() { int current_option = 0; char input[MAX_INPUT_LENGTH]; const char *options[NUM_OPTIONS] = { "[1]--|Level 1", "[2]--|Level 2", "[3]--|Level 3", "[4]--|Level 4", "[5]--|EXIT ME" }; while (1) { // Clear the screen printf("\033[H\033[J"); // ANSI escape codes to clear the screen // Draw the menu printf("Left4Code's Levels Keygen & crackme!\n[Hints For Each Level Are Included In The Zip!]\nAny and all feedback for the crackme is appreciated, I hope you learn something.\n\n"); // Display the options for (int i = 0; i < NUM_OPTIONS; i++) { if (i == current_option) { printf("{ %s }\n", options[i]); // Highlight the current option } else { printf(" %s\n", options[i]); } } // Get user input printf("\nPress a number (1-5) and press ENTER to select a level\nPress ENTER to load the selected level: "); fgets(input, sizeof(input), stdin); // Check for number input if (input[0] >= '1' && input[0] <= '5' && input[1] == '\n') { current_option = input[0] - '1'; // Convert char to int (1-6 to 0-5) } else if (input[0] == '\n') { // Enter key return current_option; // Return the selected option } } } void level_1() { #define PASS_LENGTH 20 char pass_being_modded[PASS_LENGTH + 1]; char user_pass_guess[PASS_LENGTH + 1]; printf("\033[H\033[J"); // ANSI escape codes to clear the screen printf("Level 1 - (simple analysis)\n\n\nENTER A STRING: "); fgets(pass_being_modded, PASS_LENGTH + 1, stdin); pass_being_modded[strcspn(pass_being_modded, "\n")] = 0; // remove newline character for (int i = 0; i < strlen(pass_being_modded); i++) { pass_being_modded[i] ^= 4; } printf("\n*Your entered string has been modified in some way*\n*analyze the program and enter the modified string*\n\n"); printf("What is the modified string? "); fgets(user_pass_guess, PASS_LENGTH + 1, stdin); user_pass_guess[strcspn(user_pass_guess, "\n")] = 0; if (strcmp(user_pass_guess, pass_being_modded) == 0) { printf("\n\n*LEVEL 1 COMPLETE*\n\n {Press Any Key to Return to the Menu}\n"); getchar(); } else { printf("\n\n*LEVEL 1 FAILED TRY AGAIN*\n"); sleep(1); level_1(); } } void level_2(char** argv) { #define MAX_PASSWORD_LENGTH 20 #define ENCRYPTION_KEY 0x12 printf("\033[H\033[J"); // ANSI escape codes to clear the screen char cs[] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x61,0x62,0x63,0x64,0x65,0x66}; // randomize the orderofthis char encrypted_password[] = {cs[1], cs[13], cs[8], cs[6], cs[12], cs[14], '\0'}; char password[MAX_PASSWORD_LENGTH + 1]; char arg_val = {0x65}; printf("Level 2 - (Little more complex)\n\n\nENTER THE PASSWORD: "); fgets(password, MAX_PASSWORD_LENGTH + 1, stdin); password[strcspn(password, "\n")] = 0; // Remove newline character // Encrypt the user input for (int i = 0; i < strlen(password); i++) { password[i] ^= ENCRYPTION_KEY; password[i] = password[i] + i; } // Compare the encrypted user input with the encrypted password if (argv[1] != NULL && strlen(argv[1]) > 0 && arg_val == argv[1][0] && strcmp(password, encrypted_password) == 0) { printf("\n\n*LEVEL 2 COMPLETE*\n\n {Press Any Key to Return to the Menu}\n"); getchar(); } else { printf("*LEVEL 2 FAILED TRY AGAIN*\n"); sleep(1); level_2(argv); } } void level_3(char **argv, int argc){ #define MAX_PASSWORD_LENGTH 20 #define ENCRYPTION_KEY 0x12 // char outputString[4]; // 3 characters + 1 for null terminator int rand_num = 23; int rand_num2 = 45; int check_var = 1; int rand_num3 = 040; int rand_num4 = 0050052; char FAKEPASS1[] = "R4d1x"; char password[MAX_PASSWORD_LENGTH + 1] = ""; char FAKEPASS_HEX1[] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x61,0x62,0x63,0x64,0x65,0x66}; char FAKEPASS2[] = "Z3n1th"; char FAKEPASS_EMPTY2 = FAKEPASS_EMPTY2; char FAKEPASS_HEX2[] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x61,0x62,0x63,0x64,0x65,0x66}; char FAKEPASS3[] = "L0x31yy"; char FAKEPASS_EMPTY3 = FAKEPASS_EMPTY3; char REALPASS_CHUNK[] = {0x30,0x31}; char REALPASS_CHUNK1[] = {0x32, 0x33}; char REALPASS_CHUNK2[] = {0x34, 0x35, 0x36, 0x37, '\0'}; char REALPASS_SINGLE; char REALPASS_SINGLE2 = REALPASS_SINGLE2; char REALPASS_SINGLE3; char REALPASS_SINGLE4; char REALPASS_SINGLE5; char REALPASS_SINGLE6; char REALPASS_SINGLE7; char REALPASS_SINGLE8; char REALPASS_SINGLE9; char FAKEPASS4[] = "D00m3r"; char FAKEPASS_EMPTY4 = FAKEPASS_EMPTY4; char FAKEPASS_HEX4[] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x61,0x62,0x63,0x64,0x65,0x66}; printf("\033[H\033[J"); // ANSI escape codes to clear the screen // printf("Level 3 - (Disgusted Decompiler) \n**Discover the key! There's only one? I think?**\n", rand_num, "KN0bH0cker", "Buff4l0", "M4gn1feye", "Of", FAKEPASS3, FAKEPASS2, "Ch4ddyd4ddy", "I", "B0BB1N", rand_num, rand_num2, rand_num4, rand_num3, rand_num, rand_num, rand_num, FAKEPASS1); printf("\n\n\nENTER THE PASSWORD: "); fgets(password, MAX_PASSWORD_LENGTH + 1, stdin); password[strcspn(password, "\n")] = 0; // Remove newline character // Encrypt the user input /*for (int i = 0; i < strlen(password); i++) { password[i] ^= ENCRYPTION_KEY; password[i] = password[i] + i; } */ // Compare the encrypted user input with the encrypted password password[strcspn(password, "\n")] = '\0'; int fakepass1 = 12345; int fakepass2 = 67890; int fakepass3 = 11111; int fakepass4 = 22222; int fakepass5 = 33333; int realpass = 0x1337beef; char HOLYCRAP[] = "You found my programming warcrime! Does your analysis tool still love you?"; for (int i = 0; i < 3; i++) { fakepass1 = (fakepass1 & 0x0000FFFF) | ((realpass & 0xFFFF0000) >> 16); fakepass2 = (fakepass2 & 0x00FF00FF) | ((fakepass2 & 0x0000FF00) << 16); fakepass3 = ~fakepass3 + 1; fakepass4 = fakepass4 << 2; fakepass5 = fakepass5 >> 2; FAKEPASS_HEX1[1] = 0x34; FAKEPASS_HEX2[3] = 0x13; FAKEPASS4[4] = 'B'; FAKEPASS_HEX4[5] = 0x96; REALPASS_SINGLE = REALPASS_CHUNK[0]; REALPASS_SINGLE2 = REALPASS_CHUNK[1]; REALPASS_SINGLE3 = REALPASS_CHUNK1[0]; REALPASS_SINGLE4 = REALPASS_CHUNK1[1]; REALPASS_SINGLE5 = REALPASS_CHUNK2[0]; REALPASS_SINGLE6 = REALPASS_CHUNK2[1]; REALPASS_SINGLE7 = REALPASS_CHUNK2[2]; REALPASS_SINGLE8 = REALPASS_CHUNK2[3]; REALPASS_SINGLE9 = REALPASS_CHUNK2[4]; REALPASS_SINGLE5 = REALPASS_SINGLE5 ^ 0x3; // Do nothing } FAKEPASS1[3] = 'd'; outputString[0] = '\0'; // Check if the input string is long enough if (strlen(FAKEPASS3) >= 4) { // Copy characters from position 1 to 3 (inclusive) strncat(outputString, &FAKEPASS3[1], 3); REALPASS_SINGLE4 = REALPASS_SINGLE4 ^ 0x5; } else { // If the string is too short, handle accordingly } while((rand_num ^ 23) == (rand_num2 ^ 45)){ for(int i = 0; i < 2; i = 0){ if(argc > 1 && argc != 0 && argc > (1 + 3 + 5 - 5 - 3) && argc != (1-1)){ if (strcmp(HOLYCRAP, "You found my programming warcrime! Does your analysis tool still love you?") == 0 && password[0] == REALPASS_SINGLE && password[1] == REALPASS_SINGLE2 && password[2] == REALPASS_SINGLE3 && password[3] == REALPASS_SINGLE4 && password[4] == REALPASS_SINGLE5 && password[5] == REALPASS_SINGLE6 && password[6] == REALPASS_SINGLE7 && password[7] == REALPASS_SINGLE8 && password[8] == REALPASS_SINGLE9 && fakepass1 == fakepass1 && fakepass2 == ((fakepass1 - fakepass1) + fakepass2) && FAKEPASS4[4] == 'B' && argv[1] != NULL && strlen(argv[1]) > 0 && strcmp(outputString, argv[1]) == 0){ check_var = 0; goto success; }else{ goto success; } } else { goto success; } } } success: if (check_var == 0){ printf("\n\n*LEVEL 3 COMPLETE*\n\n {Press Any Key to Return to the Menu}\n"); getchar(); } else { printf("*LEVEL 3 FAILURE TRY AGAIN*\n\n"); sleep(1); level_3(argv, argc); } } int pass_check(char *required_password,char password[100]){ if(required_password[0] == password[0] && required_password[1] == password[1] && required_password[2] == password[2] && required_password[3] == password[3] && required_password[4] == password[4] && required_password[5] == password[5]){ return 1; } else { return 2; } } void level_4(); void eye_chk(const char *success_message, const char *failure_message, int randomizer_eyes, const char random_eyes[randomizer_eyes], char cs[18], char *required_password, char password[100] , int cv_1, int cv_2, int cv_3, int cv_4){ if(random_eyes[randomizer_eyes] == random_eyes[0] || random_eyes[randomizer_eyes] == random_eyes[1]){ required_password[1] = cs[cv_1]; required_password[3] = cs[cv_2]; required_password[6] = '\0'; // Null-terminate the string int screwltrace = pass_check(required_password, password); if(screwltrace == 1){ printf("%s\n", success_message); getchar(); } else { printf("%s\n", failure_message); sleep(1); level_4(); } } else if (random_eyes[randomizer_eyes] == random_eyes[2] || random_eyes[randomizer_eyes] == random_eyes[3]){ required_password[1] = cs[cv_3]; required_password[3] = cs[cv_4]; required_password[6] = '\0'; // Null-terminate the string int screwltrace = pass_check(required_password, password); if(screwltrace == 1){ printf("%s\n", success_message); getchar(); } else { printf("%s\n", failure_message); sleep(1); level_4(); } } } void rambl_chk(const char *success_message, const char *failure_message, int randomizer_eyes, const char random_eyes[randomizer_eyes], char cs[18], char *required_password, char password[100], int randomizer_rambling_1, const char random_rambling_1[randomizer_rambling_1] ){ if(random_rambling_1[randomizer_rambling_1] == random_rambling_1[0] || random_rambling_1[randomizer_rambling_1] == random_rambling_1[1] || random_rambling_1[randomizer_rambling_1] == random_rambling_1[2]){ required_password[2] = cs[8]; eye_chk(success_message, failure_message, randomizer_eyes, &random_eyes[randomizer_eyes], cs, required_password, password, 2, 7, 4, 8); }else if (random_rambling_1[randomizer_rambling_1] == random_rambling_1[3] || random_rambling_1[randomizer_rambling_1] == random_rambling_1[4]){ required_password[2] = cs[2]; eye_chk(success_message, failure_message, randomizer_eyes, &random_eyes[randomizer_eyes], cs, required_password, password, 2, 4, 9, 9); } } void hat_chk(const char *success_message, const char *failure_message, int randomizer_eyes, const char random_eyes[randomizer_eyes], char cs[18], char *required_password, char password[100], int randomizer_rambling_1, const char *random_rambling_1[randomizer_rambling_1], int randomizer_hat, const char random_hat[randomizer_hat]){ if(random_hat[randomizer_hat] == random_hat[0]){ required_password[5] = cs[4]; rambl_chk(success_message, failure_message, randomizer_eyes, &random_eyes[randomizer_eyes], cs, required_password, password, randomizer_rambling_1, random_rambling_1[randomizer_rambling_1]); } else if(random_hat[randomizer_hat] == random_hat[1]){ required_password[5] = cs[1]; rambl_chk(success_message, failure_message, randomizer_eyes, &random_eyes[randomizer_eyes], cs, required_password, password, randomizer_rambling_1, random_rambling_1[randomizer_rambling_1]); } else if (random_hat[randomizer_hat] == random_hat[2]){ required_password[5] = cs[0]; rambl_chk(success_message, failure_message, randomizer_eyes, &random_eyes[randomizer_eyes], cs, required_password, password, randomizer_rambling_1, random_rambling_1[randomizer_rambling_1]); } } void level_4(){ printf("\033[H\033[J"); // ANSI escape codes to clear the screen /* (\. \ ,/) \( |\ )/ //\ | \ /\\ -- "Hunga" (/ /\_#oo#_/\ \) <-- small o-shaped or big 0 shaped or Wonky o0 shaped. \/\ #### /\/ `##' */ char wi[10] = {'(', '\\', ',', '/', ')', '|', '\'', '#', 'o', '_'}; char cs[18] = {'@', '$', '+', 'Z', 'Q', 'B', '*', 'J', '&', '%', '|', '{', ':', '?', '<', '>', '!', 'X'}; char *wi_prophecy_fill[6]; char required_password[100]; int wi_prophecy_if[6]; char *wi_prophecy[40] = {"THIS","HATE","I","REVERSING", "IS", "COOL", "STUPID", "DECOMPILER", "XOR", "AND", "KEYGEN", "SYSCALL", "CRACKME", "DISASSEMBLER", "DEBUGGER", "OBFUSCATED", "UNPACKED", "PACKED", "INJECTED", "DAUNTING", "AWESOME", "ELEPHANT", "RAINBOW", "KEYBOARD", "PORCUPINE", "DAZZLING", "UNIVERSE", "GUITAR", "PANCAKE", "PARACHUTE", "COMPUTER", "MOUSE", "CAT", "SOUP", "DIVINE", "INTELLECT", "THE", "GETS", "ME", "YOU"}; srand(time(0)); int average = 0; int randomizer_eyes = rand()%4; int randomizer_hat = rand()%3; int randomizer_rambling_1 = rand()%5; const char *success_message = "\n\n*LEVEL 4 [! COMPLETE !] (How did you not rip your hair out?)*\n\n {Press Any Key to Return to the Menu}\n"; const char *failure_message = "\n\n*LEVEL 4 [X FAILED X] (Give it another try, reverser :-])"; const char *random_eyes[] = {"@", "$", "*", "+"}; const char *random_hat[] = {"@", "\\", "&"}; const char *random_rambling_1[] = {"Hunga", "Bunga", "Funga", "Lunga", "Skrunga"}; char password[100]; for(int p = 0; p < 6; p++){ int randomizer_prophecy = rand()%40; wi_prophecy_fill[p] = wi_prophecy[randomizer_prophecy]; wi_prophecy_if[p] = randomizer_prophecy; } // modify the array to include random attributes for the wizard here: printf("Level 4 - (SorceREr of Disarray) *Last one!\n"); printf ("[IN THIS LEVEL, ANYTHING GOES EXCEPT PATCHING JUMPS OR ADDING NOPS! {KEYGEN RECOMMENDED}]\n\n%c%c%c %s %c%c%c\n %c%c %c%c %c%c \n %c%c%c %c %c %c%c%c -- \"%s Shlunga\"\n%c%c %c%c%c%c%s%s%c%c%c%c %c%c \n %c%c%c %c%c%c%c %c%c%c \n %c%c%c%c \n", wi[0], wi[1], wi[2], random_hat[randomizer_hat], wi[2], wi[3], wi[4], wi[1], wi[0], wi[5], wi[1], wi[4], wi[4], wi[3], wi[3], wi[1], wi[5], wi[1], wi[3], wi[1], wi[1], random_rambling_1[randomizer_rambling_1], wi[0], wi[3], wi[3], wi[1], wi[9], wi[7], random_eyes[randomizer_eyes], random_eyes[randomizer_eyes], wi[7], wi[9], wi[3], wi[1], wi[1], wi[4], wi[1], wi[3], wi[1], wi[7], wi[7], wi[7], wi[7], wi[3], wi[1], wi[3], wi[6], wi[7], wi[7], wi[6] ); printf("\n\n[*THE ARRAY LOVING WIZARD ANNOUNCES HIS PROPHECY*]\n"); printf("\"%s, %s, %s, %s, %s, %s\" - Wizard, Retainer of Divine Intellect", wi_prophecy_fill[0], wi_prophecy_fill[1], wi_prophecy_fill[2], wi_prophecy_fill[3], wi_prophecy_fill[4], wi_prophecy_fill[5]); printf("\n\nDid he just cast a curse on you or something?\nHopefully not.. Anyways. What's his password?: "); fgets(password, sizeof(password), stdin); password[strcspn(password, "\n")] = 0; // Remove newline character for(int i = 0; i < 6; i++){ if(wi_prophecy_if[i] <= 20){ average++; } else { average--; } } // REWRITE THIS AND STUFF IT INTO A FUNCTION FOR GOD'S SAKE!!!! if(average >= 0){ required_password[4] = cs[6]; required_password[0] = cs[2]; hat_chk(success_message, failure_message, randomizer_eyes, random_eyes[randomizer_eyes], cs, required_password, password, randomizer_rambling_1, &random_rambling_1[randomizer_rambling_1], randomizer_hat, random_hat[randomizer_hat]); } else { required_password[4] = cs[1]; required_password[0] = cs[3]; hat_chk(success_message, failure_message, randomizer_eyes, random_eyes[randomizer_eyes], cs, required_password, password, randomizer_rambling_1, &random_rambling_1[randomizer_rambling_1], randomizer_hat, random_hat[randomizer_hat]); } // look out for the } if there's a potential problem here. } void ending_messages(){ printf("\033[H\033[J"); // ANSI escape codes to clear the screen srand(time(0)); int random_quote = rand()%10; char quotes[10][230] = { {"\"Reverse engineering is like trying to figure out how a watch works by studying the smell of its strap.\" - DiscordKitten"}, {"\"Reverse engineering: the art of turning a binary into\na non-working mess of nop instructions and wondering how it ever worked in the first place.\n - God"}, {"\"Reverse engineering is like trying to understand a foreign language, but\nthe language is binary and the speakers are all drunk.\" - BinaryButterfly"}, {"\"I can find a needle in a haystack, as long as the needle is a function\ncall and the haystack is a binary, but I can't promise I won't get lost along the way.\" - GlitchGopher"}, {"\"I can reverse engineer a program so well, I can make it sing the national anthem.\" - Tru3P4tr10t"}, {"\"Making this took only 20\% of my sanity, surprisingly..\" - Mac841"}, {"\"Reverse engineering. Where you spend hours trying to figure out what the original\nprogrammer was smoking when they wrote this.\" - D00BM4ST3R"}, {"\"What the F*#@ am I even looking at\" - Maybe you"}, {"\"Reverse engineering. The ultimate way to learn that you don't know S#!& about S#!&\" - SaltedMacaroni841"}, {"\"Reverse engineering. The only profession where you would consider\nsacrificing your co-workers in a satanic ritual to Dennis Ritchie to understand what\nthis Adderal-microdosing programmer decided to ruin your day with\" - SKru&."} }; printf("[PROGRAM EXITING ENJOY A QUOTE!]\n\n%s\n\n*Any and all feedback for the crackme is appreciated, hope you got some value out of this!*\n\nUntil next time. Reverser.. - Left4Code\n\n", quotes[random_quote]); } int main(int argc, char** argv) { while (1) { int result = display_menu(); switch (result) { case 0: level_1(); break; case 1: level_2(argv); break; case 2: level_3(argv, argc); break; case 3: level_4(); break; case 4: ending_messages(); return 0; } } }