2024 Cyber Apocalypse: Makeshift

Challenge Information

AttributeDetails
Event2024 Cyber Apocalypse
CategoryCrypto
ChallengeMakeshift
DifficultyEasy

Summary

Makeshift implements a simple string transformation that reverses the flag and then rearranges characters in groups of three using the pattern ABC → BCA. The challenge is trivial to reverse by applying the inverse transformations.


Analysis

The encryption process:

  1. Reverse the flag: FLAG[::-1]
  2. Rearrange in triplets: Every sequence of characters ABC is changed to BCA
    • Position 0 → Position 2
    • Position 1 → Position 0
    • Position 2 → Position 1

Encrypted output: !?}De!e3d_5n_nipaOw_3eTR3bt4{_THB


Solution

Decryption Algorithm

To reverse the process:

enc_flag = r'!?}De!e3d_5n_nipaOw_3eTR3bt4{_THB'
# Step 1: Reverse the triplet rearrangement
# BCA pattern means: position 0←1, position 1←2, position 2←0
# To reverse: position 0→2, position 1→0, position 2→1
new_flag = ''
for i in range(0, len(enc_flag), 3):
# BCA → ABC means: take second, take third, take first
new_flag += enc_flag[i+2] # Position 2 of BCA → Position 0 of ABC
new_flag += enc_flag[i] # Position 0 of BCA → Position 1 of ABC
new_flag += enc_flag[i+1] # Position 1 of BCA → Position 2 of ABC
# Step 2: Reverse the string
flag = new_flag[::-1]
print(flag)
# HTB{4_w0nd3rfully_d33p_3ncrypt10n_for_d3tection!}

Walkthrough

  1. Encrypted: !?}De!e3d_5n_nipaOw_3eTR3bt4{_THB
  2. After reversing triplets: Groups rearranged from BCA back to ABC
  3. After reversing string: Full flag revealed

Key Takeaways

  • Simple string manipulations are easily reversible
  • Multiple transformations (reverse + rearrange) still provide no cryptographic security
  • The transformation is deterministic and lacks any key material
  • Security through obfuscation fails when the algorithm is known