Keyquest
Keyquest
Keyquest
Le système d'authentification utilise plusieurs fonctions pour valider l'accès des utilisateurs.
Les principales fonctions identifiées sont :
def whippin5(inpt):
import hashlib
sh = hashlib.md5()
sh.update(inpt.encode())
return sh.hexdigest()
def whippin3(n):
import string
lc = string.ascii_lowercase
uc = string.ascii_uppercase
dc = string.digits
trans = str.maketrans(
CTF : HackerLab 2024
lc + uc + dc,
lc[n:] + lc[:n] + uc[n:] + uc[:n] + dc[n:] + dc[:n]
)
return lambda s: s.translate(trans)
def whippin4(a, b):
b_etx = b * (len(a) // len(b) + 1)
return ''.join(chr(ord(c) ^ ord(d)) for c, d in zip(a, b_etx))
# Fonction `check` pour valider la clé de l'utilisateur
def check(username, y_key):
if username == 'BJIZ-HACKERLAB':
print(f'Congratz, you can use this flag to validate : HLB2024{{{y_key}}}')
else:
print("Good, but the key of BJIZ-HACKERLAB' is the flag")
II -> Décryptage de `crypted_password`
import string
def whippin3(n):
lc = string.ascii_lowercase
uc = string.ascii_uppercase
dc = string.digits
trans = str.maketrans(
lc + uc + dc,
lc[n:] + lc[:n] + uc[n:] + uc[:n] + dc[n:] + dc[:n]
)
return lambda s: s.translate(trans)
# Clé initiale de substitution
initial_key = -9
decryption_key = -initial_key
crypted_password = 'dpjLgviGRJJN1IUUFeKu1ls8'
decrypted_password = whippin3(decryption_key)(crypted_password)
print(f"Decrypted password: {decrypted_password}")
En utilisant le `real_password` déchiffré, nous pouvons générer la clé correcte `y_key` pour
l'utilisateur BJIZ-HACKERLAB.
import hashlib
import string
def whippin5(inpt):
sh = hashlib.md5()
sh.update(inpt.encode())
return sh.hexdigest()
def whippin3(n):
lc = string.ascii_lowercase
uc = string.ascii_uppercase
dc = string.digits
trans = str.maketrans(
CTF : HackerLab 2024
lc + uc + dc,
lc[n:] + lc[:n] + uc[n:] + uc[:n] + dc[n:] + dc[:n]
)
username = 'BJIZ-HACKERLAB'
y_key = whippin5(whippin4(username, real_password))
def check(username, y_key):
if username == 'BJIZ-HACKERLAB':
print(f'Congratz, you can use this flag to validate : HLB2024{{{y_key}}}')
else:
print("Good, but the key of BJIZ-HACKERLAB' is the flag")
check(username, y_key)
Conclusion
En analysant les fonctions opcode fournies et en comprenant leur fonctionnement, nous avons pu
déterminer qu'il est possible de retrouver la clé de l'utilisateur BJIZ-HACKERLAB. En inversant la
fonction de substitution et en appliquant les opérations cryptographiques dans l'ordre inverse, nous
avons obtenu le `real_password` et généré la clé `y_key` correcte.
Cette analyse démontre les faiblesses potentielles du système d'authentification et la nécessité de
renforcer les mécanismes de sécurité pour éviter de telles vulnérabilités.
CTF : HackerLab 2024
Participant : shadowcipher