← Back to Writeups
CUSTOMEasyReversing

Keygen Me

XESXOR9/10/20261 min read
#reversing#custom#easy#affine_cipher_implementation#keygen_generation

Keygen Me

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

Summary

Language: C. Source code provided. Generate serial for email spbctf2017@forkbomb.ru.

Keygen Me — Reverse Kids 2.0

Description

Language: C. Source code provided. Generate serial for email spbctf2017@forkbomb.ru.

Analysis

The check_serial function applies an affine cipher to each letter of the email:

c
val_em = ((uint8_t)*em | 0x20) - 'a';  // lowercase, 0-25
val_em = ((A * val_em) % MODULE) + 'a'; // A=7, MODULE=26

Only alphabetic characters are processed (digits, @, . are skipped).

Solution

python
email = "spbctf2017@forkbomb.ru"
serial = ""
for c in email:
    if c.isalpha():
        val = ((7 * (ord(c.lower()) - ord('a'))) % 26) + ord('a')
        serial += chr(val)
# REDACTED

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

Letters from email: s,p,b,c,t,f,f,o,r,k,b,o,m,b,r,u → REDACTED ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍