Convert ‘Em All!
nc -nv 109.233.56.90 11573
Solution
Бинаря нет — сразу проверю, что там:
cu63:Converter/ $ nc -nv 109.233.56.90 11573
Convert 972201650 to
___ _ _
/ _ \ ___ | |_ __ _ | |
| | | | / __|| __| / _` || |
| |_| || (__ | |_ | (_| || |
\___/ \___| \__| \__,_||_|
Программа выдаёт число и просит перевести его в один из форматов: Octal, Hex, LittleEndian64, BigEndian64.
Создам шаблон:
pwn template --host 109.233.56.90 --port 11573 > exploit.py
Exploit
Читаю число, определяю формат по первой строке ASCII-арта, отправляю ответ. Повторяю в цикле:
io = start()
while True:
num = io.recvuntil(b'to').decode().split(' ')[1]
io.recvline()
s = io.recvline()
num = int(num)
match s:
case b' _ _ _ _ _ _____ _ _ __ _ _ \r\n': # LittleEndian64
io.sendline(p64(num))
case b' ___ _ _ \r\n': # Octal
io.sendline(oct(num)[2:].encode())
case b' ____ _ _____ _ _ __ _ _ \r\n': # BigEndian64
io.sendline(p64(num, endian='big'))
case b' _ _ \r\n': # Hex
io.sendline(hex(num)[2:].encode())
case _:
print(s)
break
io.recvuntil(b'\r\n200 OK\n')
io.interactive()
cu63:Converter/ $ python exploit.py DEBUG
...
[DEBUG] Received 0x3b bytes:
b'200 OK\n'
b'You are win! FLAG: spbctf{You_ARE_CONveRTEr_MSW600}\n'
spbctf{You_ARE_CONveRTEr_MSW600}