Looks like PALINDROME implemented their own authentication protocol and cryptosystem to provide a secure handshake between any 2 services or devices. It does not look secure to us, can you take a look at what we have got?
Try to fool their authentication service: nc chal00bq3ouweqtzva9xcobep6spl5m75fucey.ctf.sg 56765
Solution
This was a pretty straightforward crypto challenge where a weak authentication scheme allowed the leaking of the secret key through a challenge-response sequence. This relied on the following matrix multiplication in GF(2).
Since we control the challenge bits c, we could leak the result of each column by challenging the server. For example, setting c1=1,c2...n=0 gives us
r1r2⋮rn=c1s11c1s21⋮c1sn1
and since we can do the same for all c1...n, we could reconstruct the response to any challenge by adding up the relevant column results.
The solution to this challenge is to simply probe the server with 00000001, 00000010, ... 10000000, and when challenged, take the 1-bits and add up their corresponding probed values.
Since this happens in GF(2), addition is the same as XOR (hence the use of XOR in the script).
from pwn import*import reconn =remote("chal00bq3ouweqtzva9xcobep6spl5m75fucey.ctf.sg", 56765)defsolve(): rows = []for i inrange(8): conn.recvuntil(b"<-- ") binstr ="0"* (8- i -1) +"1"+"0"* (i) conn.send(binstr.encode() +b"\n") resp = conn.recvline().decode() match = re.search(r"--> (.*)\n", resp) rows.append(int(match.group(1), 2))for i inrange(8): resp = conn.recvuntil(b"<-- ").decode() match = re.search(r"--> (.*)\n", resp) challenge = match.group(1) result =0for j inrange(8):if challenge[j]=="1": result ^= rows[7- j] conn.send(bin(result)[2:].zfill(8).encode() +b"\n") conn.interactive()solve()
This gives us the flag.
========================
All challenges passed :)
========================
=================================================================
Here is your flag: TISC{d0N7_R0lL_Ur_0wN_cRyp70_7a25ee4d777cc6e9}
=================================================================