攻防世界:https://adworld.xctf.org.cn/
题目:Simple-Math (NO.GFSJ1113)
题解:Python代码
import numpy as np
import galois # 伽罗瓦域
import hashlib
GF = galois.GF(2) # Ax = b mod 2
A = GF([[1, 1, 0, 1, 1, 0, 1, 1, 1, 1],
[0, 0, 1, 1, 0, 0, 0, 1, 1, 0],
[1, 0, 1, 1, 0, 0, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 1, 1, 0, 1, 1, 1],
[1, 1, 1, 1, 1, 0, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 1, 0, 1, 1, 1],
[0, 0, 0, 1, 0, 1, 0, 0, 0, 1],
[0, 1, 1, 0, 0, 0, 1, 1, 1, 0],
[0, 0, 0, 1, 0, 0, 1, 1, 0, 1]])
A_inv = np.linalg.inv(A)
b = GF([1,0,1,1,0,0,0,1,0,1])
x = A_inv@b
print(x)
x_to_str = ''.join(map(str,x))
print(x_to_str)
flag='XSCTF{'+hashlib.sha1(x_to_str.encode('utf-8')).hexdigest()+'}'
print(flag)
输出:
[0 0 1 1 0 1 1 0 0 1]
0011011001
XSCTF{103c8041593b4b8e38971db283a7a773b0ffc2ee}