← Back to Writeups
CUSTOMEasyReversing

crackme3

XESXOR9/10/20261 min read
#reversing#custom#easy#source_code_analysis#xor_decode_with_key

crackme3

Platform: rev-kids20.forkbomb.ru | Category: Reversing | Type: Challenge | Difficulty: Easy | OS: NA | Author: XESXOR | Date: 2026-03-09 | Status: Solved Techniques: source_code_analysis, xor_decode_with_key

Summary

Language: C. Source code of encoder provided + encoded flag file. Encoding uses XOR with random bytes.

crackme3 — Reverse Kids 2.0

Description

Language: C. Source code of encoder provided + encoded flag file. Encoding uses XOR with random bytes.

Analysis

Encoding algorithm:

c
srand(time(NULL));
for (i = 0; i < strlen(text); i++) {
    number = rand() & 0xff;
    fputc(text[i] ^ number, fd);  // encrypted byte
    fputc(number, fd);            // XOR key stored right next to it!
}

Key observation: each key byte (number) is written immediately after the encrypted byte. Knowledge of rand() is not needed. ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

Bytes come in pairs: (text[i] ^ key, key). Decoding is trivial:

python
with open('encoded_flag3', 'rb') as f:
    data = f.read()
result = ""
for i in range(0, len(data), 2):
    result += chr(data[i] ^ data[i+1])
# FLAG{REDACTED}

‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍