← Back to Writeups
CUSTOMMediumReversing

Haskell

XESXOR9/10/20261 min read
#reversing#custom#medium#functional_code_analysis#paired_arithmetic_reverse

Haskell

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

Summary

Language: Haskell. Source code provided. Functional flag checker using recursive list transformation.

Haskell — Reverse Kids 2.0

Description

Language: Haskell. Source code provided. Functional flag checker using recursive list transformation.

Analysis

The calculate1 function processes the list in pairs:

haskell
calculate1 (x:[]) = [x*4]
calculate1 (x:y:[]) = [(x+y)*5] ++ (calculate1 [y])  -- = [(x+y)*5, y*4]
calculate1 (x:y:xs) = (calculate1 [x,y]) ++ (calculate1 xs)

For each pair (x, y) of ASCII codes from the input, two values are generated: (x+y)*5 and y*4.

Target array: [730,304,680,284,860,196,505,204,1020,408,1000,396,995,408,995,392,975,392,1130,500] ‍​‌‌​​‌​​​‌‌​​‌​​​​‌‌​‌​​​​‌‌‌​​‌​​‌‌​​​‌​​‌‌‌​​​​​‌‌​‌‌​​​‌‌​​​​‍

Solution

For each pair (a, b) in the target array:

  • y = b / 4
  • x = a / 5 - y
python
target = [730,304,680,284,860,196,505,204,1020,408,1000,396,995,408,995,392,975,392,1130,500]
flag = ""
for i in range(0, len(target), 2):
    y = target[i+1] // 4
    x = target[i] // 5 - y
    flag += chr(x) + chr(y)
# FLAG{REDACTED}

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