Mind Palace III [PPC]

Mind Palace III

100% of brain CPU

URL: nc 212.47.229.1 33003

Recon

The servers gives a question with two numbers and an operand AND, OR or XOR. It expects a correct answer. The flag is given after a certain amount of questions.

Code

import string
import pwn

def get_answer(n1, n2, op):
    if (op == 'AND'):
        return n1 & n2
    if (op == 'XOR'):
        return n1 ^ n2
    if (op == 'OR'):
        return n1 | n2

conn = pwn.remote('212.47.229.1', 33003)

res = True
while res:
    m = conn.recvuntil('[>] ')
    if b'FLAG' in m:
        print(m.decode().split('\n')[0])
        break
    res = conn.recv().decode().split('\n')[0].split(' ')
    answer = get_answer(int(res[0]), int(res[2]), res[1])
    conn.send((str(answer) + '\n').encode())
conn.close()

Flag

FLAG{0HH_Y0UR3_4_V3RY_5M3RT_M4TH3M4T1C}