Kategori
Programmering
Beskrivning
Harald och den engelske kungen har inlett ett sammarbete och Harald har fått en leverans av ett nytt autentiseringssystem. Han har dock missat att stänga systemet för nya användare och det är fritt fram för motståndsrörelsen att lägga till egna. Det enda som de behöver göra är att skapa ett lösenord till användaren. Hur svårt kan det vara? Det är ju bara att följa reglerna.
Lösning
Ansluter man till utmaningen så får man ett antal regler för att skapa ett lösenord. Skapar man ett lösenord som följer reglerna så får man tillbaks ännu fler regler.

Följande regler gäller:
- Thy password shall consist of more than eight runes. Let no man sayeth otherwise!
- Thou shalt not make thy password greater than 64 runes in length, lest ye anger the gods.
- Let thy password contain both upper and lower case letters.
- Thou shalt not use a common password. Be creative, or suffer the consequences!
- Let thy password be made up of more than 10 digits, lest thou wish to be challenged by the guardians of this realm.
- Thy password shall have at least three lower case letters and five upper case letters, that thy strength may be known to all.
- Let thy password contain a hexadecimal number (0x..), greater than one, lest ye wish to face the wrath of the vikings.
- Thy password shall also contain an octal number (0o..), greater than one, that all may know thy worth.
- Let the sum of all digit runes in thy password be equal to 191, lest thou wish to face the challenges of the realm.
- Thy password must have the octal number (0o2) multiplied with the hexadecimal number (0xa6db898) equal to thy traveler number, that all may know thee as a true warrior of this land.
- Verify thy password within three seconds, lest thou wish to be cast out into the wilderness! Haste, my friend, for time is of the essence in this realm.
Följande Python-kod kan användas för att skapa ett lösenord som följer reglerna:
#!/usr/bin/env python3
from pwn import *
import re
r = remote("0.cloud.chals.io", 16992)
data = r.recvuntil(b"password: ")
data = data.decode()
traveller_number = int(re.findall(r"#(\d+)!", data)[0])
print("Traveller number:", traveller_number)
print("Traveller number in hex:", hex(traveller_number))
divisor = 0
if traveller_number % 2 == 0:
divisor = 2
else:
print("Traveller number is not divisible by 2")
exit()
traveller_number = traveller_number // divisor
password = f"KOKO{hex(traveller_number)}sn0o{divisor}ootEN0000000".encode()
print("Password:", password)
r.sendline(password)
tn = re.findall(r"\d", hex(traveller_number))
tn = [int(i) for i in tn]
digit_sum = sum(tn) + divisor
data = r.recvuntil(b"password: ")
data = data.decode()
digit_sum = int(re.findall(r"\d+", data)[-1]) - digit_sum
nines = digit_sum // 9
remainder = digit_sum % 9
password = password + str(remainder).encode() + b"9" * nines
print("New password:", password)
r.sendline(password)
data = r.recvall()
flag = re.findall(r"undut{.*}", data.decode())[0]
print("Flag:", flag)
Flagga: undut{super_complicated_rules_does_not_improve_security}