Created
March 31, 2019 06:27
-
-
Save tsalvia/29e61e40608dcf07468381f89ca9e5b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define XOR_PASSWORD "]pyyzJR}|qgt4" // Hello_Ghidra! xor 0x15 | |
#define XOR_KEY 0x15 | |
#define PASSWORD_LEN 13 | |
int check_password(char *password) | |
{ | |
char buf[PASSWORD_LEN]; | |
int i; | |
if (strlen(password) != PASSWORD_LEN) | |
return -1; | |
for (i = 0; i < PASSWORD_LEN; i++) | |
buf[i] = password[i] ^ XOR_KEY; | |
if (strncmp(buf, XOR_PASSWORD, PASSWORD_LEN) != 0) | |
return -1; | |
return 0; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if (argc < 2) { | |
printf("Usage: %s <password>\n", argv[0]); | |
return -1; | |
} | |
if (check_password(argv[1]) < 0) { | |
printf("Incorrect password.\n"); | |
return -1; | |
} | |
printf("Congratulations! flag{%s}\n", argv[1]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment