← Back to Writeups
CUSTOMEasyReversing

crackme4

XESXOR9/2/20261 min read
#reversing#custom#easy#keygen_implementation#xor_swap_analysis

crackme4

Platform: CUSTOM | Category: Reversing | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: keygen_implementation, xor_swap_analysis

Summary

Walkthrough of the CUSTOM Reversing crackme4. Language: Python. Source code provided. Generate serial for name 'SPb_CTF_2017'.

Description

Language: Python. Source code provided. Generate serial for name 'SPb_CTF_2017'.

Analysis

python
def check(name, serial):
    name = bytes(name, 'utf-8')
    valid = [
        int.from_bytes(name[:4], 'big'),
        int.from_bytes(name[4:8], 'big'),
        int.from_bytes(name[8:], 'big')
    ]
    valid[0] ^= valid[2]  # XOR swap
    valid[2] ^= valid[0]
    valid[0] ^= valid[2]
    return serial == '{:08x}-{:08x}-{:08x}'.format(*valid)

The name is split into 3 blocks of 4 bytes each, then the first and third blocks are swapped using XOR swap. ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

python
name = 'SPb_CTF_2017'
name_bytes = bytes(name, 'utf-8')
valid = [
    int.from_bytes(name_bytes[:4], 'big'),   # SPb_ = 0x5350625f
    int.from_bytes(name_bytes[4:8], 'big'),  # CTF_ = 0x4354465f
    int.from_bytes(name_bytes[8:], 'big')    # 2017 = 0x32303137
]
# XOR swap: valid[0] and valid[2] are swapped
valid[0], valid[2] = valid[2], valid[0]
serial = '{:08x}-{:08x}-{:08x}'.format(*valid)
# REDACTED

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

Key Takeaways / Lessons

  • Mastering keygen_implementation, xor_swap_analysis was key to this challenge.
  • Always check for common misconfigurations and verify assumptions.

Crafted by XESXOR Research • 2026-03-09 • CUSTOM • crackme4 • Difficulty: Easy