← Back to Writeups
CUSTOMMediumReversing

The Reshuffler

XESXOR9/2/20261 min read
#reversing#custom#medium#shuffle_algorithm_reversal#swap_operation_analysis

The Reshuffler

Platform: CUSTOM | Category: Reversing | Type: Challenge | Difficulty: Medium | OS: N/A | **Author: XESXOR Techniques: shuffle_algorithm_reversal, swap_operation_analysis

Summary

Walkthrough of the CUSTOM Reversing The Reshuffler. Detailed walkthrough.

Description

"You have the binary that encodes a string given as command line argument. Find original string from this encoded data:" bpoctifh_t{tmkh_smowsllsfoe_smia_amsart_h'i?ti_in}

Analysis

The binary applies a series of swap operations with decreasing step sizes (10→2) to the input string. Each step swaps pairs of characters at a certain distance.

Solution

The reverse operation — apply the same swaps with increasing step sizes (2→10):

python
encoded = "bpoctifh_t{tmkh_smowsllsfoe_smia_amsart_h'i?ti_in}"
s = list(encoded)
for step in range(2, 11):  # reverse: from 2 to 10
    for i in range(0, len(s) - step, step):
        s[i], s[i + step] = s[i + step], s[i]
result = ''.join(s)

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

Note: The flag starts with "sbpctf" (not "spbctf") — this is intentional, part of the challenge. ‍​‌‌​​​​‌​‌‌​​‌‌​​‌‌​​‌‌​​‌‌​​‌​​​​‌‌​​​​​‌‌​​‌‌​​‌‌​​‌​‌​‌‌​​‌​‌‍

Key Takeaways / Lessons

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

Crafted by XESXOR Research • 2026-03-09 • CUSTOM • The Reshuffler • Difficulty: Medium