A Puzzle in Seven Parts
3 minutos de lectura
Se nos proporciona esta cadena de texto:
AbCDeFGAbCDEFGAbCDEFGABCdEFGaBCdeFGAbCDEFGAbCDEFGaBCdefgAbCDeFGABCdeFGAbCDeFGABCdefgaBCdeFGAbCDeFGABCdefgABCDEFGAbCDeFGAbCDeFGAbCDeFGABCDEFGAbCDEFGaBCdeFGaBCdeFGAbcDEFGAbCDeFGAbCDEFGAbCDeFGABCdefgAbCDeFGABcDEfGABCdefgaBCdefgAbCDeFGAbCDeFGABCDefGABCDEFgAbCDeFGABCdEFGAbCDEFGaBCdefgAbCDEFGABCDefGAbCDEFGAbcDEFgAbCDeFGAbCDeFGABCdefgABCdefgAbCDEFGaBCdefgaBCdeFGAbCDeFGaBCdeFGAbcDEFGAbCDEFGABCdEFGAbCDeFGABcDEfGAbCDEFGAbcDEFgaBCdeFGABCdEFGAbCDeFGAbCDEFGAbCDeFGAbCDeFGAbCDeFGABCdefgABCDefGAbCDeFGAbCDEFGabCDEFGAbCDeFGaBCdeFGABCDefGaBCdefgAbCDeFGABCdEFGABCdefgAbCDeFGAbCDeFGaBCdefgAbCDEFGAbcDEFgAbCDEFGABCDEFGAbCDeFGABCdefgaBCdeFGaBCDEfGAbCDeFGAbCDEFGaBCdeFGABCdEFGAbCDeFGABCDEFGAbCDeFGABCdeFGAbCDeFGaBCdeFGaBCdeFGAbCDEFGaBCdeFGABCdEFGAbCDEFGaBCdeFGABCDefGABcDEfGaBCdeFGABCdEFGaBCdeFGAbCDeFGAbCDeFGABCdefgAbCDEFGAbcDEFgAbCDEFGaBCdeFGAbCDeFGABCDefGaBCdeFGaBCDEfGABCDefGABCDEFgaBCdeFGABCdEFGaBCdeFGAbCDeFGAbCDeFGAbCDEFGAbCDEFGABCdEFGaBCdeFGAbCDEFGAbCDeFGAbCDEFGAbCDEFGAbCDeFGaBCdeFGABCdefgaBCdeFGAbcDEFGAbCDeFGABCDEFGAbCDeFGABCDefGAbCDEFGabCDEFGAbCDEFGAbcDEFg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bCDEFGaBCdeFGAbCDeFGaBCdeFGAbCDeFGABcDEfGAbCDeFGaBCdeFGaBCdeFGAbCDEFGAbCDeFGABCdEFGAbCDeFGAbCDEFGaBCdeFGABCdefgABCDefGaBCdefgAbCDEFGAbcdEFGAbCDeFGAbCDeFGABCDefGABCDEFgABCDefGaBCdefgaBCdeFGABCdeFGAbCDeFGaBCdefgAbCDEFGabCDEFGABCdefgaBCdeFGAbCDeFGABCdefgAbCDeFGABcDEfGAbCDEFGAbcDEFgAbCDeFGABCdEFGAbCDeFGABCDefGAbCDeFGABCdEFGaBCdeFGaBCdeFGaBCdeFGAbCDEFGaBCdeFGABCDefGAbCDeFGAbCDeFGAbCDEFGAbcDEFgaBCdeFGABcDEfGAbCDeFGAbCDeFGaBCdeFGaBCDEfGaBCdeFGaBCdeFGABCDefGABCDEFgABCDefGaBCDEfG
Display de siete segmentos
Como sugiere el reto, el texto anterior debe estar relacionado con un display de siete segmentos:
Por ejemplo, las primeras 7 letras son AbCDeFG
, que forman un 5
(las letras mayúsculas están encendidas y las letras minúsculas están apagadas). Usemos Python para dividir toda la cadena en trozos de 7 letras y eliminar las letras minúsculas:
$ python3 -q
>>> import re
>>> m = 'AbCDeFGAbCDEFGAbCDEFGABCdEFGaBCdeFGAbCDEFGAbCDEFGaBCdefgAbCDeFGABCdeFGAbCDeFGABCdefgaBCdeFGAbCDeFGABCdefgABCDEFGAbCDeFGAbCDeFGAbCDeFGABCDEFGAbCDEFGaBCdeFGaBCdeFGAbcDEFGAbCDeFGAbCDEFGAbCDeFGABCdefgAbCDeFGABcDEfGABCdefgaBCdefgAbCDeFGAbCDeFGABCDefGABCDEFgAbCDeFGABCdEFGAbCDEFGaBCdefgAbCDEFGABCDefGAbCDEFGAbcDEFgAbCDeFGAbCDeFGABCdefgABCdefgAbCDEFGaBCdefgaBCdeFGAbCDeFGaBCdeFGAbcDEFGAbCDEFGABCdEFGAbCDeFGABcDEfGAbCDEFGAbcDEFgaBCdeFGABCdEFGAbCDe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m[i : i + 7] for i in range(0, len(m), 7)]
>>> ms = [re.sub('[a-g]', '', mss) for mss in ms]
>>> ' '.join(ms)
'ACDFG ACDEFG ACDEFG ABCEFG BCFG ACDEFG ACDEFG BC ACDFG ABCFG ACDFG ABC BCFG ACDFG ABC ABCDEFG ACDFG ACDFG ACDFG ABCDEFG ACDEFG BCFG BCFG ADEFG ACDFG ACDEFG ACDFG ABC ACDFG ABDEG ABC BC ACDFG ACDFG ABCDG ABCDEF ACDFG ABCEFG ACDEFG BC ACDEFG ABCDG ACDEFG ADEF ACDFG ACDFG ABC ABC ACDEFG BC BCFG ACDFG BCFG ADEFG ACDEFG ABCEFG ACDFG ABDEG ACDEFG ADEF BCFG ABCEFG ACDFG ACDEFG ACDFG ACDFG ACDFG ABC ABCDG ACDFG ACDEFG CDEFG ACDFG BCFG ABCDG BC ACDFG ABCEFG ABC ACDFG ACDFG BC ACDEFG ADEF ACDEFG ABCDEFG ACDFG ABC BCFG BCDEG ACDFG ACDEFG BCFG ABCEFG ACDFG ABCDEFG ACDFG ABCFG ACDFG BCFG BCFG ACDEFG BCFG ABCEFG ACDEFG BCFG ABCDG ABDEG BCFG ABCEFG BCFG ACDFG ACDFG ABC ACDEFG ADEF ACDEFG BCFG ACDFG ABCDG BCFG BCDEG ABCDG ABCDEF BCFG ABCEFG BCFG ACDFG ACDFG ACDEFG ACDEFG ABCEFG BCFG ACDEFG ACDFG ACDEFG ACDEFG ACDFG BCFG ABC BCFG ADEFG ACDFG ABCDEFG ACDFG ABCDG ACDEFG CDEFG ACDEFG ADEF ACDFG ACDEFG ACDEFG ABDEG BCFG ABC ACDEFG ABCDEFG ACDFG BCFG ACDFG ACDFG ACDEFG ADEF ACDFG ABDEG ACDFG ABC ACDFG ACDEFG ACDFG ACDEFG ACDEFG BCFG ACDFG ABCDEFG ACDEFG ABCDG BCFG ACDFG ACDEFG BCFG ACDEFG CDEFG BCFG BCDEG ACDFG ACDEFG ACDEFG ADEF ABCDG ABCDG ACDFG BCFG ABCDG BC ACDFG ABCEFG ABC ABCDG ACDFG ABCFG ACDFG ACDEFG BCFG ABCEFG ABC ACDFG ACDFG BC ACDEFG ADEF ACDEFG ADEF ACDFG ACDEFG ACDEFG ABDEG BCFG ABC BCFG BCDEG ABCDG BC ACDFG BCFG ACDFG BCFG BCFG ACDEFG ACDEFG CDEFG ACDFG ABC ACDFG ABC BCFG ADEFG BCFG ACDEFG ACDFG ABC ACDEFG CDEFG ABCDG ABCFG ACDFG ABC BCFG BCDEG BCFG ACDEFG ABC ABCDEF BCFG ABCEFG ACDFG ACDEFG ACDEFG CDEFG ACDEFG ABCDG ABCDG BC ACDFG ACDFG ABCDG BC ACDFG ABCFG ABC ABCFG ACDFG ABCDG ACDEFG ADEF ACDEFG BCFG ACDEFG ABCEFG ACDFG ABCDG BCFG ACDFG ABC ABCDEF ACDFG ABC ACDFG BCFG ACDFG ACDFG ACDFG ABCEFG ACDEFG BC BCFG BCDEG ABCDG BC ABC ABCDEF BCFG ACDFG ACDFG ABDEG ACDEFG ADEFG ACDEFG BCFG ACDFG BCFG ACDFG ABDEG ACDFG BCFG BCFG ACDEFG ACDFG ABCEFG ACDFG ACDEFG BCFG ABC ABCDG BC ACDEFG AEFG ACDFG ACDFG ABCDG ABCDEF ABCDG BC BCFG ABCFG ACDFG BC ACDEFG CDEFG ABC BCFG ACDFG ABC ACDFG ABDEG ACDEFG ADEF ACDFG ABCEFG ACDFG ABCDG ACDFG ABCEFG BCFG BCFG BCFG ACDEFG BCFG ABCDG ACDFG ACDFG ACDEFG ADEF BCFG ABDEG ACDFG ACDFG BCFG BCDEG BCFG BCFG ABCDG ABCDEF ABCDG BCDEG'
Ahora podemos usar dcode.fr para decodificar los dígitos anteriores:
Más decodificación
Ahora tenemos una cadena de texto en hexadecimal (obsérvese que q
es 9
):
>>> enc = '566A46615q5745785558644E5657527155305A61636C557761454E6A526C4A565557356b54315A75516C68574d564A585q54464A64324A45576C64534d304A45566A465665474E58536b6C5662476854556C5257565664586345646b4d566C3354315A735q564A75516C6C5662474d315454466b57574E46576b3q574d46704A566b633155315q7q536C646A5345705754555A614d317045526E64545254465A5647316F5530314q516b7457526C5A535A444643556C42554d44303d'
>>> enc = enc.replace('q', '9')
>>> bytes.fromhex(enc)
b'VjFaYWExUXdNVWRqU0ZaclUwaENjRlJVUW5kT1ZuQlhWMVJXYTFJd2JEWldSM0JEVjFVeGNXSklVbGhTUlRWVVdXcEdkMVl3T1ZsYVJuQllVbGM1TTFkWWNFWk9WMFpJVkc1U1YySldjSEpWTUZaM1pERndTRTFZVG1oU01IQktWRlZSZDFCUlBUMD0='
Y luego tenemos Base64… varias veces:
>>> b64decode(bytes.fromhex(enc))
b'V1Zaa1QwMUdjSFZrU0hCcFRUQndOVnBXV1RWa1IwbDZWR3BDV1UxcWJIUlhSRTVUWWpGd1YwOVlaRnBYUlc5M1dYcEZOV0ZIVG5SV2JWcHJVMFZ3ZDFwSE1YTmhSMHBKVFVRd1BRPT0='
Flag
Después de todo el proceso de decodificación, obtenemos la flag:
>>> b64decode(b64decode(bytes.fromhex(enc)))
b'WVZkT01GcHVkSHBpTTBwNVpWWTVkR0l6VGpCWU1qbHRXRE5TYjFwV09YZFpXRW93WXpFNWFHTnRWbVprU0Vwd1pHMXNhR0pJTUQwPQ=='
>>> b64decode(b64decode(b64decode(bytes.fromhex(enc))))
b'YVdOMFpudHpiM0p5ZVY5dGIzTjBYMjltWDNSb1pWOXdZWEowYzE5aGNtVmZkSEpwZG1saGJIMD0='
>>> b64decode(b64decode(b64decode(b64decode(bytes.fromhex(enc)))))
b'aWN0Zntzb3JyeV9tb3N0X29mX3RoZV9wYXJ0c19hcmVfdHJpdmlhbH0='
>>> b64decode(b64decode(b64decode(b64decode(b64decode(bytes.fromhex(enc))))))
b'ictf{sorry_most_of_the_parts_are_trivial}'