Cybercamp 2017 Online – 04. Transfer with terrible consequences [400]

Y vamos a por el cuarto, si, ya no se me ocurren mejores introducciones jajaja Vamos con el enunciado:

We are in a complicated situation. The control of a critical infrastructure was impossible due to the loss of the access password. During the transfer of a worker’s position, a mishap occurred and some of the information has disappeared.

The worker, who wants to remain anonymous, kept each character of a hash in some sheets arranged in a filing cabinet. One character per sheet. During the transfer of his workplace, the sheets have been disordered and some information has disappeared.

Not everything, but some information characters from the hash could be retrieved: ‘50afXXXXXX6351475e54bf6eb2c96f2b’. Characters identified by “X” are hexadecimal values that have been lost.

The password was not complicated but we have minimum information. The worker barely remembers that the password was composed of eight alphanumeric characters. “In q, it ends in q!“ – He excitedly exclaimed. Finally, he remembered that of the eight characters, the first was a “q” and the last two were “oq”. He was asked about the type of used hash, but he shook his head. After holding his breath for a few seconds, he recognised that he was unable to remember the type of hash.

We need help in order to obtain the password and get control of the infrastructure. The solution must have the following format: password-hash

Esta vez no tenemos archivo ya que el enunciado nos da toda la información que necesitamos, en este caso debemos encontrar un hash, del cual no sabemos que tipo es y del cual conocemos parte; de una palabra de 8 caracteres de longitud que comienza por oq y termina por q.

Primero probamos rellenando los caracteres que faltan en el hash con ceros y se lo pasamos a hashid para ver que nos dice:

50af0000006351475e54bf6eb2c96f2b
Analyzing '50af0000006351475e54bf6eb2c96f2b'
[+] MD2 
[+] MD5 
[+] MD4 
[+] Double MD5 
[+] LM 
[+] RIPEMD-128 
[+] Haval-128 
[+] Tiger-128 
[+] Skein-256(128) 
[+] Skein-512(128) 
[+] Lotus Notes/Domino 5 
[+] Skype 
[+] Snefru-128 
[+] NTLM 
[+] Domain Cached Credentials 
[+] Domain Cached Credentials 2 
[+] DNSSEC(NSEC3) 
[+] RAdmin v2.x 

Parece que no hemos tenido mucha suerte con esto, tendremos que ir probando distintos hashes, en lugar de escribir un script que permutara por todos debido al gran número de posibilidades me decante por utilizar john, pero primero necesitamos una lista de todos los posibles hashes y las posibles palabras, para ello utilizamos el siguiente script:

import itertools
import string

def gen_hash_dict():
    alphabet='0123456789abcdef'
    d=[]
    for x in itertools.product(alphabet, repeat=6):
        h='50af'+''.join(x)+'6351475e54bf6eb2c96f2b'
        d.append(h+'\n')
    with open('hash_dict.txt', 'w') as f:
        f.writelines(d)

def gen_passwd_dict():
    alphabet=string.ascii_lowercase + string.digits
    d=[]
    for x in itertools.product(alphabet, repeat=5):
        p='q'+''.join(x)+'oq'
        d.append(p+'\n')
    with open('passwd_dict.txt', 'w') as f:
        f.writelines(d)

print('generating hash dict...')
gen_hash_dict()
print('generating passwd dict...')
gen_passwd_dict()
print('done!')

Como veis en la primera función limitamos los carácteres a los utilizados en hexadecimal ya que en el enunciado nos indican que estos son los utilizados en el hash; para las contraseñas utilizamos todos los caracteres alfanuméricos.

Una vez tenemos los dos archivos, vamos probando cada uno de los hashes que hashid nos ha dado, finalmente en la tercera tenemos suerte:

Este es el comando de john que finalmente nos dio la solución:

john --fork=4 --format=raw-md4 --wordlist=passwd_dict.txt hash_dict.txt

Ahora que ya tenemos la palabra veamos cual es su hash correspondiente utilizando una de las multiples tools online y obtenemos 50affc9dcf6351475e54bf6eb2c96f2b.

La flag finalmente es:

q5ib44oq-50affc9dcf6351475e54bf6eb2c96f2b

Espero os haya gustado, un saludo y gracias por la visita!

 

Esta entrada fue publicada en cripto, ctf, cybercamp, writeups. Guarda el enlace permanente.

Deja un comentario

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.