Reverse Engineering a Simple XOR Encryption in CTF Challenge

Binary Analyssi

First, examine the binary with IDA Pro. The main function performs the following operations:

int main() {
    char input[24];
    char encrypted_flag[] = "rxusoCqxw{yqK`{KZqag{r`i";
    
    printf("please input flag");
    scanf("%24s", input);
    
    if(strlen(input) != 24) {
        printf("error");
        return 0;
    }
    
    for(int i = 0; i < 24; i++) {
        input[i] ^= 0x14;
    }
    
    if(memcmp(input, encrypted_flag, 24) == 0) {
        printf("good job");
    } else {
        printf("error");
    }
    
    return 0;
}

Key Observations

  1. The program expects a 24-character input
  2. Each character is XORed with 0x14
  3. The result is compared against a hardcoded encrypted string

Solution Script

To reverse the encryption and retrieve the flag:

encrypted = 'rxusoCqxw{yqK`{KZqag{r`i'
flag = ''.join([chr(ord(c) ^ 0x14) for c in encrypted])
print(flag)

This Python script performs the inverse XOR operation on each character of the encrypted string.

Tags: reverse-engineering CTF XOR binary-analysis

Posted on Tue, 01 Sep 2026 16:53:45 +0000 by Jocke