复现一下,还是太菜了😩
LinearCasino
题目:
alarm(120)
n, d1, d2 = 100, 60, 50
FLAG = "aliyunctf{REDACTED}"
print("😊 LinearCasino is the Game 4 Super Guesser.")
for _ in range(100):
D1 = random_matrix(GF(2), d1, n)
D2 = random_matrix(GF(2), d2, n)
A = random_matrix(GF(2), d1+d2, d1+d2)
B = [random_matrix(GF(2), d1+d2, 2*n), block_matrix([[D1, D1],[0, D2]])]
C = Permutations(2*n).random_element().to_matrix()
ct = [A*B[0]*C, A*B[1]*C]
decision = randint(0,1)
a = int(''.join(map(str, ct[decision].list())),2)
print("🎩", int(''.join(map(str, ct[decision].list())),2))
assert input("🎲 ") == str(decision)
print(f"🚩 Real Super Guesser! {FLAG}")
题目描述:
分别计算两个矩阵和:
靶机发来一段密文,判断这个密文是还是
参考2025-阿里云CTF-wp-crypto|糖醋小鸡块的blog
这道题主要从矩阵的秩入手
C是一个置换矩阵(每一行有一个随机位置为1,其余位置都是0,并且一列不会同时出现两个1)
举例:
那么就有:
并且对于有:
计算:
下,那么就有
复习一下矩阵的秩的重要性质:
通过性质1可以推出左半矩阵的秩不大于,右半矩阵的秩也不大于
再通过性质5,得到 的秩不大于
最后通过性质7,得到结论:一定小于
exp:
from tqdm import *
from pwn import *
sh = remote('121.41.238.106','16938')
sh.recvuntil(b"LinearCasino is the Game 4 Super Guesser.")
n, d1, d2 = 100, 60, 50
for _ in trange(100):
sh.recvuntil(b"\xf0\x9f\x8e\xa9 ")
enc = Matrix(GF(2), d1+d2, 2*n, list(map(int, bin(int(sh.recvline().strip().decode()))[2:].zfill((d1+d2)*(2*n)))))
if((enc*enc.T).rank() <= 100):
sh.sendline(b"1")
else:
sh.sendline(b"0")
print(sh.recvline())