← Back to Writeups
CUSTOMEasyReversing

crackme1

XESXOR9/2/20261 min read
#reversing#custom#easy#source_code_analysis#xor_chain_decode

crackme1

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_chain_decode

Summary

Language: C. Source code of encoder provided + encoded flag file. Need to reverse the encoding.

crackme1 — Reverse Kids 2.0

Description

Language: C. Source code of encoder provided + encoded flag file. Need to reverse the encoding.

Analysis

Encoding algorithm (XOR chain):

c
int c = 0x7f;  // initial value
for (i = 0; i < strlen(text); i++) {
    fputc(c ^ text[i], fd);  // write XOR of current c and plaintext
    c ^= text[i];            // update c
}

Key observation: after c ^= text[i], the new value of c equals c_old ^ text[i], which matches the written byte. So c_new = byte[i]. ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

Decoding: text[i] = byte[i] ^ c_old, where c_old for the first iteration = 0x7f, and then c_old = byte[i-1].

python
with open('encoded_flag', 'rb') as f:
    data = f.read()
c = 0x7f
result = ""
for b in data:
    result += chr(b ^ c)
    c = b
# FLAG{REDACTED}

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