1 min read

[CTF GEMA] Being_A_Reverser

CTF GEMA Groupe 2025

Niveau de Difficulté : Easy

Catégorie du Challenge : Crypto

Description :

Au cours du processus de transfert de données, un problème inattendu s'est produit dans la programmation du protocole, entraînant un transfert de données dans l'ordre inverse. Pouvez-vous m'aider à comprendre cette anomalie ?

Challenge Concept:

Le défi consiste à décoder un texte chiffré sous forme de tableaux binaires, où chaque ligne comporte un seul « 1 » indiquant la position ASCII d'un caractère. Au cours du transfert de données, les lignes ont été inversées, et la tâche consiste à décoder et à restaurer le texte original.


Steps to Solve :

  • Lire le fichier : analyser les tableaux binaires du fichier dans une liste Python.
  • Trouver les positions : Identifier la position du « 1 » dans chaque tableau pour obtenir les valeurs ASCII.
  • Décoder les caractères : Convertir les positions en caractères à l'aide de chr().
  • Inverser l'ordre : Inverser le texte décodé pour corriger l'anomalie de transfert.
  • Résultats de sortie : Afficher le texte décodé et les positions pour vérification.

Solve Code:

import ast
pts=""
pt = ""

def read_arrays_from_file(filename):
with open(filename, 'r') as file:
    content = file.read().strip()
    try:

        arrays = ast.literal_eval(content)
        return arrays
    except (SyntaxError, ValueError) as e:
        print(f"Error reading arrays from file: {e}")
        return []


def find_position_of_one(char_list):
try:
    position = char_list.index(1)
    return position
except ValueError:
    return -1  


arrays_of_arrays = read_arrays_from_file('enc.txt')


if arrays_of_arrays:

positions = [find_position_of_one(sub_array) for sub_array in arrays_of_arrays]
for i in positions:
    pts+=chr(i)
    pt = ""


for char in reversed(pts):
    pt += char
print(pt)

print(positions)
else:
print("No arrays to process.")

Output :

$ python solve.py
FLAG{We_can_meet_tomorrow_at_7_AM_to_discuss_possible_solutions._I_believe_being_a_reverser_should_not_be_too_difficult}
[125, 116, 108, 117, 99, 105, 102, 102, 105, 100, 95, 111, 111, 116, 95, 101, 98, 95, 116, 111, 110, 95, 100, 108, 117, 111, 104, 115, 95, 114, 101, 115, 114, 101, 118, 101, 114, 95, 97, 95, 103, 110, 105, 101, 98, 95, 101, 118, 101, 105, 108, 101, 98, 95, 73, 95, 46, 115, 110, 111, 105, 116, 117, 108, 111, 115, 95, 101, 108, 98, 105, 115, 115, 111, 112, 95, 115, 115, 117, 99, 115, 105, 100, 95, 111, 116, 95, 77, 65, 95, 55, 95, 116, 97, 95, 119, 111, 114, 114, 111, 109, 111, 116, 95, 116, 101, 101, 109, 95, 110, 97, 99, 95, 101, 87, 123, 71, 65, 76, 70]

Flag:

FLAG{We_can_meet_tomorrow_at_7_AM_to_discuss_possible_solutions._I_believe_being_a_reverser_should_not_be_too_difficult}