· Manuel López Pérez · writeups  · 2 min read

Resolviendo retos de CTF – Parte 2

Segunda entrega de la serie en la que resolvemos retos de HackCon 2019. Cubrimos desafíos de criptografía (OTP, Vigenère, lenguajes esotéricos) y reversing (análisis de binarios ELF). Incluye explicaciones detalladas y código actualizado.

Segunda entrega de la serie en la que resolvemos retos de HackCon 2019. Cubrimos desafíos de criptografía (OTP, Vigenère, lenguajes esotéricos) y reversing (análisis de binarios ELF). Incluye explicaciones detalladas y código actualizado.

Resolviendo retos de CTF – Parte 2Vamos a seguir con la resolución de algunos retos de CTF. Os dejo también la primera parte en la que resolvimos algunos retos: parte 1. En este caso, vamos a estar resolviendo retos del CTF Hackcon 2019 en el cual aun podéis registraros y hacer los retos. Si preferís, podeis seguir el tutorial en formato Notebook y trabajar el código fácilmente: Notebook - HackCon19

Criptografía

OTP (HackCon 2019)

Enunciado

hackerman is so dank that he decided to play around with OTPs. he did the following: message1 ^ key = cipher1 message2 ^ key = cipher2

He gives you cipher1 and cipher2 and challenges you to find the concatenation of messages 1 and 2. Are you dank enough to find this? Oh and also, ‘meme’ is so popular that hackerman used the word in both his messages. cipher1 is ‘\x05F\x17\x12\x14\x18\x01\x0c\x0b4’ cipher2 is ’>\x1f\x00\x14\n\x08\x07Q\n\x0e’ Both without quotes

Resolución Se sabe que el formato del flag es d4rk{FLAG}c0de así que podemos obtener los 5 primeros y últimos caracteres de la key:

‘d4rk{’ ^ ‘\x05F\x17\x12\x14’ = key1 ‘}c0de’ ^ ‘\x08\x07Q\n\x0e’ = key2

[python] import itertools def xor(s1, s2): if len(s1) < len(s2): s1 = itertools.cycle(s1) elif len(s1) > len(s2): s2 = itertools.cycle(s2) return ”.join(chr(ord(a) ^ ord(b)) for a, b in zip(s1, s2))

c1 = ‘\x05F\x17\x12\x14\x18\x01\x0c\x0b4’ c2 = ’>\x1f\x00\x14\n\x08\x07Q\n\x0e’ c = c1 + c2 k1 = xor(c

Back to Blog

Related Posts

View All Posts »