0%

2022wmctf

WMCTF2022

解题情况

image-20220822211055392

Crypto

nanoDiamond

题目

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from Crypto.Util.number import *
import string
import secrets
from hashlib import sha256
from random import randint, shuffle, choice

def proof_of_work():
s = ''.join([secrets.choice(string.digits + string.ascii_letters)
for _ in range(20)])
print(f'sha256(XXXX+{s[4:]}) == {sha256(s.encode()).hexdigest()}')
if input('Give me XXXX: ') != s[:4]:
exit(1)

ROUND_NUM = 50
PREROUND_NUM = 14
CHEST_NUM = 6

flag = b'flag{test}'

white_list = ['==','(',')','0','1','and','or','B0','B1','B2','B3','B4','B5']

def calc(ans, chests, expr):
B0, B1, B2, B3, B4, B5 = chests
return ans(eval(expr))

def round():
chests = [choice((True, False)) for _ in range(CHEST_NUM)]
print("Six chests lie here, with mimics or treasure hidden inside.")
print("But don't worry. Skeleton Merchant knows what to do.")
print("Be careful, Skeleton Merchant can lie twice!")

truth = lambda r: not not r
lie = lambda r: not r
lie_num = randint(0, 2)
lie_status = [truth] * (PREROUND_NUM - lie_num) + [lie] * lie_num
shuffle(lie_status)

for i in range(PREROUND_NUM):
try:
question = input('Question: ').strip()
for word in question.split(' '):
print(word)
assert word in white_list, f"({word}) No treasure for dirty hacker!"
result = calc(lie_status[i], chests, question)
print(f'Answer: {result}!')
except Exception as e:
print("Skeleton Merchant fails to understand your words.")
print(e)
print('Now open the chests:')
return chests == list(map(int, input().strip().split(' ')))


if __name__ == '__main__':

proof_of_work()

print('Terraria is a land of adventure! A land of mystery!')
print('Can you get all the treasure without losing your head?')

for i in range(ROUND_NUM):
if not round():
print('A chest suddenly comes alive and BITE YOUR HEAD OFF.')
exit(0)
else:
print('You take all the treasure safe and sound. Head to the next vault!')

print(f"You've found all the treasure! {flag}")

题解

starctf2022同类型题,信息论中利用生成多项式与循环码纠正错误

找到wp,原题是(15,7),这里是(14,6),因此生成多项式不用改动,改参数即可

part1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# from pwn import *

# context.log_level = 'debug'

R.<x>= PolynomialRing(GF(2))
g = x ^ 8 + x ^ 7 + x ^ 6 + x ^ 4 + 1


def n2p(a):
a = bin(a)[2:]
p = 0
for i in range(len(a)):
if a[len(a) - i - 1] == '1':
p += x ^ i
return p


def enc(i):
m = n2p(i)
c = (x ^ 8) * m + (((x ^ 8) * m) % g)
return "".join([str(int(i in c.exponents())) for i in range(14)])[::-1]


dic = []
for i in range(2 ** 6):
dic.append(enc(i))

part = "( B0 == {} and B1 == {} and B2 == {} and B3 == {} and B4 == {} and B5 == {}) "
questions = []
for i in range(14):
question = ""
nums = [j[:6] for j in dic if j[i] == '1']
assert (len(nums) == 32)
for j in range(32):
n = nums[j]
question += part.format(n[0], n[1], n[2], n[3], n[4], n[5]) + "or "
questions.append(question[:-4]) # ?


def dif(a, b):
cnt = 0
for i in range(len(a)):
if a[i] != b[i]:
cnt += 1
return cnt

print(questions)
print(dic)

part2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from pwn import *
import hashlib
from string import ascii_letters, digits
from itertools import product


def dif(a, b):
cnt = 0
for i in range(len(a)):
if a[i] != b[i]:
cnt += 1
return cnt


table = ascii_letters + digits

context.log_level = 'debug'
questions = [
'( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)',
'( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)']
questions = [i.replace(')', ' )') for i in questions]
dic = ['00000000000000', '00000111010001', '00001001110011', '00001110100010', '00010011100110', '00010100110111',
'00011010010101', '00011101000100', '00100000011101', '00100111001100', '00101001101110', '00101110111111',
'00110011111011', '00110100101010', '00111010001000', '00111101011001', '01000000111010', '01000111101011',
'01001001001001', '01001110011000', '01010011011100', '01010100001101', '01011010101111', '01011101111110',
'01100000100111', '01100111110110', '01101001010100', '01101110000101', '01110011000001', '01110100010000',
'01111010110010', '01111101100011', '10000001110100', '10000110100101', '10001000000111', '10001111010110',
'10010010010010', '10010101000011', '10011011100001', '10011100110000', '10100001101001', '10100110111000',
'10101000011010', '10101111001011', '10110010001111', '10110101011110', '10111011111100', '10111100101101',
'11000001001110', '11000110011111', '11001000111101', '11001111101100', '11010010101000', '11010101111001',
'11011011011011', '11011100001010', '11100001010011', '11100110000010', '11101000100000', '11101111110001',
'11110010110101', '11110101100100', '11111011000110', '11111100010111']
# 1.13.154.182:30310
r = remote('1.13.154.182', 30310)

# proof of work
proof = r.recvuntil(b'Give me XXXX: ')
print(proof)
tail = proof[12:28].decode()
_hash = proof[33:97].decode()
print(tail)
print(_hash)
print('开始爆破!')
for i in product(table, repeat=4):
head = ''.join(i)
t = hashlib.sha256((head + tail).encode()).hexdigest()
if t == _hash:
r.sendline(head.encode())
print('爆破成功!结果是:', end='')
print(head)
break

for i in range(50):
msg = ''
for j in range(14):
# r.recvuntil("Question: ")
# r.send(questions[j])
r.sendlineafter("Question: ", questions[j])
r.recvuntil("Answer: ")
if b'True' in r.recvuntil("!"):
msg += '1'
else:
msg += '0'
for j in range(64): # 32*2 = 64
if (dif(msg, dic[j]) <= 2):
break
ans = ""
for k in dic[j][:6]:
ans += k + " "
r.sendlineafter("chests:", ans)
r.interactive()
# You take all the treasure safe and sound. Head to the next vault!
# You've found all the treasure! WMCTF{TERR4R1a_IS_4_LAND_0F_@DVENturE}

WMCTF{TERR4R1a_IS_4_LAND_0F_@DVENturE}

nanoDiamond - rev

题目

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# from Crypto.Util.number import *
import string
import secrets
from hashlib import sha256
from random import randint, shuffle, choice

def proof_of_work():
s = ''.join([secrets.choice(string.digits + string.ascii_letters)
for _ in range(20)])
print(f'sha256(XXXX+{s[4:]}) == {sha256(s.encode()).hexdigest()}')
if input('Give me XXXX: ') != s[:4]:
exit(1)

ROUND_NUM = 50
PREROUND_NUM = 13
CHEST_NUM = 6

with open('flag', 'r') as f:
flag = f.read()

white_list = ['==','(',')','0','1','and','or','B0','B1','B2','B3','B4','B5']

def calc(ans, chests, expr):
B0, B1, B2, B3, B4, B5 = chests
return ans(eval(expr))

def round():
chests = [choice((True, False)) for _ in range(CHEST_NUM)]
print("Six chests lie here, with mimics or treasure hidden inside.")
print("But don't worry. Skeleton Merchant knows what to do.")
print("Be careful, Skeleton Merchant can lie twice!")

truth = lambda r: not not r
lie = lambda r: not r
lie_num = randint(0, 2)
lie_status = [truth] * (PREROUND_NUM - lie_num) + [lie] * lie_num
shuffle(lie_status)

for i in range(PREROUND_NUM):
try:
question = input('Question: ').strip()
for word in question.split(' '):
assert word in white_list, f"({word}) No treasure for dirty hacker!"
result = calc(lie_status[i], chests, question)
print(f'Answer: {result}!')
except Exception as e:
print("Skeleton Merchant fails to understand your words.")
print(e)
print('Now open the chests:')
return chests == list(map(int, input().strip().split(' ')))


if __name__ == '__main__':

proof_of_work()

print('Terraria is a land of adventure! A land of mystery!')
print('Can you get all the treasure without losing your head?')

for i in range(ROUND_NUM):
if not round():
print('A chest suddenly comes alive and BITE YOUR HEAD OFF.')
exit(0)
else:
print('You take all the treasure safe and sound. Head to the next vault!')

print(f"You've found all the treasure! {flag}")

题解

简单入门循环码生成多项式等概念与性质

题中n=13,k=6,而$x ^{13} - 1$或$x ^ { 13 } + 1$因式分解组合不出7(13-6)次多项式

随便找了个(15, 8)的生成多项式,无脑爆破

运气好,出了

part1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# from pwn import *

# context.log_level = 'debug'

R.<x>= PolynomialRing(GF(2))
g = x^7+x^6+x^4+1


def n2p(a):
a = bin(a)[2:]
p = 0
for i in range(len(a)):
if a[len(a) - i - 1] == '1':
p += x ^ i
return p


def enc(i):
m = n2p(i)
c = (x ^ 7) * m + (((x ^ 7) * m) % g)
return "".join([str(int(i in c.exponents())) for i in range(13)])[::-1]


dic = []
for i in range(2 ** 6):
dic.append(enc(i))

part = "( B0 == {} and B1 == {} and B2 == {} and B3 == {} and B4 == {} and B5 == {}) "
questions = []
for i in range(13):
question = ""
nums = [j[:6] for j in dic if j[i] == '1']
print(len(nums))
assert (len(nums) == 32)
for j in range(32):
n = nums[j]
question += part.format(n[0], n[1], n[2], n[3], n[4], n[5]) + "or "
questions.append(question[:-4]) # ?


def dif(a, b):
cnt = 0
for i in range(len(a)):
if a[i] != b[i]:
cnt += 1
return cnt

print(questions)
print(dic)

part2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from pwn import *
import hashlib
from string import ascii_letters, digits
from itertools import product


def dif(a, b):
cnt = 0
for i in range(len(a)):
if a[i] != b[i]:
cnt += 1
return cnt



table = ascii_letters + digits

context.log_level = 'debug'
questions = ['( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0)', '( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1)', '( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 0 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 0 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 0 and B3 == 1 and B4 == 1 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 0 and B5 == 0) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 0 and B4 == 1 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 0 and B5 == 1) or ( B0 == 1 and B1 == 1 and B2 == 1 and B3 == 1 and B4 == 1 and B5 == 0)']
questions = [i.replace(')', ' )') for i in questions]
dic = ['0000000000000', '0000011010001', '0000101110011', '0000110100010', '0001000110111', '0001011100110', '0001101000100', '0001110010101', '0010001101110', '0010010111111', '0010100011101', '0010111001100', '0011001011001', '0011010001000', '0011100101010', '0011111111011', '0100000001101', '0100011011100', '0100101111110', '0100110101111', '0101000111010', '0101011101011', '0101101001001', '0101110011000', '0110001100011', '0110010110010', '0110100010000', '0110111000001', '0111001010100', '0111010000101', '0111100100111', '0111111110110', '1000000011010', '1000011001011', '1000101101001', '1000110111000', '1001000101101', '1001011111100', '1001101011110', '1001110001111', '1010001110100', '1010010100101', '1010100000111', '1010111010110', '1011001000011', '1011010010010', '1011100110000', '1011111100001', '1100000010111', '1100011000110', '1100101100100', '1100110110101', '1101000100000', '1101011110001', '1101101010011', '1101110000010', '1110001111001', '1110010101000', '1110100001010', '1110111011011', '1111001001110', '1111010011111', '1111100111101', '1111111101100']
# 1.13.154.182:31888
while True:
try:
r = remote('1.13.154.182', 31888)

# proof of work
proof = r.recvuntil(b'Give me XXXX: ')
print(proof)
tail = proof[12:28].decode()
_hash = proof[33:97].decode()
print(tail)
print(_hash)
print('开始爆破!')
for i in product(table, repeat=4):
head = ''.join(i)
t = hashlib.sha256((head + tail).encode()).hexdigest()
if t == _hash:
r.sendline(head.encode())
print('爆破成功!结果是:', end='')
print(head)
break

for i in range(50):
msg = ''
for j in range(13):
# r.recvuntil("Question: ")
# r.send(questions[j])
r.sendlineafter("Question: ", questions[j])
r.recvuntil("Answer: ")
if b'True' in r.recvuntil("!"):
msg += '1'
else:
msg += '0'
for j in range(64): # 32*2 = 64
if (dif(msg, dic[j]) <= 2):
break
ans = ""
for k in dic[j][:6]:
ans += k + " "
r.sendlineafter("chests:", ans)
r.interactive()
except:
continue
break
# WMCTF{7ErrAr14_Is_a_lAND_0F_AdVeNTURe!!!!!}

WMCTF{7ErrAr14_Is_a_lAND_0F_AdVeNTURe!!!!!}

ecc

题目

1
2
3
4
5
6
flag bits: 606
e = 0x10001
n = 61262574892917665379101848600282751252633178779864648655116434051615964747592676204833262666589440081296571836666022795166255640192795587508845265816642144669301520989571990670507103278098950563219296310830719975959589061794360407053224254135937766317251283933110936269282950512402428088733821277056712795259
c = 16002162436420434728223131316901476099110904029045408221515087977802746863468505266500673611412375885221860212238712311981079623398373906773247773552766200431323537510699147642358473715224124662007742017000810447999989426207919068340364725395075614636875116086496704959130761547095168937180751237132642548997
G = (3364552845709696244757995625685399274809023621531082895612949981433844727622567352338990765970534554565693355095508508160162961299445890209860508127449468 : 4874111773041360858453223185020051270111929505293131058858547656851279111764112235653823943997681930204977283843433850957234770591933663960666437259499093 : 1)
3G = (8240596254289477251157504980772167439041663401504657696787046343848644902166655624353107697436635678388969190302189718026343959470011854412337179727187240 : 4413479999185843948404442728411950785256136111461847698098967018173326770728464491960875264034301169184074110521039566669441716138955932362724194843596479 : 1)

hint:wmctf{a+b+c}

题解

factordb分解出n,根据提示将a、b、m二进制补位并拼接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import libnum,gmpy2
# flag bits: 606
e = 0x10001
n = 61262574892917665379101848600282751252633178779864648655116434051615964747592676204833262666589440081296571836666022795166255640192795587508845265816642144669301520989571990670507103278098950563219296310830719975959589061794360407053224254135937766317251283933110936269282950512402428088733821277056712795259
c = 16002162436420434728223131316901476099110904029045408221515087977802746863468505266500673611412375885221860212238712311981079623398373906773247773552766200431323537510699147642358473715224124662007742017000810447999989426207919068340364725395075614636875116086496704959130761547095168937180751237132642548997
x1, y1 = (3364552845709696244757995625685399274809023621531082895612949981433844727622567352338990765970534554565693355095508508160162961299445890209860508127449468 , 4874111773041360858453223185020051270111929505293131058858547656851279111764112235653823943997681930204977283843433850957234770591933663960666437259499093)
x3, y3 = (8240596254289477251157504980772167439041663401504657696787046343848644902166655624353107697436635678388969190302189718026343959470011854412337179727187240 , 4413479999185843948404442728411950785256136111461847698098967018173326770728464491960875264034301169184074110521039566669441716138955932362724194843596479)
tmp1 = x1^3-y1^2
tmp2 = x3^3-y3^2
tmp = (tmp2-tmp1)
p = 8308060309959524788634404677678479024666400240233812713350984932475838872076486898595574202532027412806488106365658717017155800093596205985127436125626827

# tmp = x3^3-x1^3-y3^2+y1^2 # tmp = a(x1-x3)+kp
# R.<a> = PolynomialRing(Zmod(p))
# f = a*(x1-x3)-tmp
# print(f.roots())

a = 3629864911627283784723617758993690217446918991113173559686999
print((tmp-a*(x1-x3))%p) # 验证a
b = (y3^2-x3^3-a*x3)%p
q = n//p
d = int(gmpy2.invert(e, (p-1)*(q-1)))
flag = int(pow(c,d,n))
print(libnum.n2s(int(pow(c,d,n))))

####
print('a', int(a).bit_length())
print('b', int(b).bit_length())
print('flag',int(flag).bit_length())
print('p =',p)
print('a =', a)
print('b =', b)
tmp = str(a)+str(b)+str(flag)
# tmp = a+b+flag
def pad(num):
print(len('0'*(202-len(str(bin(num)[2:])))+str(bin(num)[2:])))
return('0'*(202-len(str(bin(num)[2:])))+str(bin(num)[2:]))
flag = int(pad(a)+pad(b)+pad(flag),2)
print(libnum.n2s(flag))
# b'$$U_c0u1d_s01v3_e11iptiCurv3_s0_34sily$$0f19d82199a0db0dee31fa12330307ea90aa'

wmctf{$$U_c0u1d_s01v3_e11iptiCurv3_s0_34sily$$0f19d82199a0db0dee31fa12330307ea90aa}

homo

题目

  • gentry.py

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    from Crypto.Util.number import *
    from secret import flag
    from random import *

    assert flag.startswith(b'wmctf{') and flag.endswith(b'}')
    flaglen = len(flag) - 7
    flag = bytes_to_long(flag[6:-1])
    pbit = 114
    qbit = 514
    rbit = 191
    keylen = 981
    nouse = 0


    def keygen():
    pk = []
    sk = getPrime(qbit)
    for i in range(keylen):
    print(i)
    p = getPrime(pbit)
    r = getPrime(rbit)
    pk.append(p * sk + 2 * r)
    return pk, sk


    def enc(m, pk):
    c = []
    m = [int(i) for i in bin(m)[2:]] # 转二进制
    print(m)
    for i in m:
    tempc = i
    for j in range(keylen):
    if randint(0, 1):
    tempc += pk[j]
    c.append(tempc)
    return c


    pk, sk = keygen()
    print(sk)
    c = enc(flag, pk)

    f = open('./pubkey.txt', 'w')
    f.write(str(pk))
    f.close()

    f = open('./cipher.txt', 'w')
    f.write(str(c))
    f.close()
    print([(i % sk) % 2 for i in c])
    print(sk)
  • pubkey.txt

  • cipher.txt

题解

搜索思路

相关参考

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
f = open('/Users/0HB/Desktop/复现/wm/homo/pubkey.txt', 'r')
pk_ = f.read()
x = []
eval('x.extend({})'.format(pk_))
f.close()

f = open('/Users/0HB/Desktop/复现/wm/homo/cipher.txt', 'r')
c_ = f.read()
ct = []
eval('ct.extend({})'.format(c_))
f.close()

def SDA(x, t, gamma, rho, eta):
M = Matrix(ZZ, t, t)
M[0, 0] = 2^(rho+1)
for i in range(1, t):
M[0, i] = x[i]
M[i, i] = -x[0]

print('Matirx done')
ML = M.LLL()
print('LLL done!')
# f = open('/Users/0HB/Desktop/复现/wm/homo/LLL.txt', 'w')
# f.write(str(ML))
# f.close()
# print('Save LLL')

d = ML.determinant()
# assert d == 2^(rho + 1) * x[0]^(t - 1)
# assert sqrt(t)*2^(gamma - eta + rho + 1) < sqrt(t/(2*pi*e))*d^(1/t)

v = ML[0]
min = abs(norm(ML[0]) - sqrt(t)*2^(gamma - eta + rho + 1))
for i in ML:
if min > abs(norm(i) - sqrt(t)*2^(gamma - eta + rho + 1)):
min = abs(norm(i) - sqrt(t)*2^(gamma - eta + rho + 1))
v = i

# v[0] = 2^(rho + 1) * q_0
q0 = v[0] // 2^(rho + 1)
r0 = x[0] % q0
print(q0)
print('p =', q0)
print('r =', r0)
p = (x[0] - r0) // q0
print("sk:{}".format(p))

return p


def decryption(ct, p):
ct = '0b' + ''.join(str(i%p%2) for i in ct)
m = int(ct, 2).to_bytes((len(ct) - 1) // 8, byteorder='big').decode()
return m

if __name__ == "__main__":
t = 981
gamma = 628 # 514+114
eta = 514
rho = 191
p = SDA(x, t, gamma, rho, eta)
print(decryption(ct, p))

output

1
2
3
4
5
6
Matirx done
LLL done!
17195743943555229331660961462727499
p = 17195743943555229331660961462727499
r = 2615830010834467677351383140406463
sk:41565572874253689464437825525802665878958533473562648432875965578230785556539072257838190060392315994424904212374664222250474284551897781086850148587327684

r>p,所以上面求得的r、sk是不准的,可以利用整除p平方(p平方大于2r)的思想消除r影响,求得真正的私钥sk

get flag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sys

import libnum, gmpy2
from Crypto.Util.number import *
from random import *

f = open('/Users/0HB/Desktop/复现/wm/homo/pubkey.txt', 'r')
pk_ = f.read()
pks = []
eval('pks.extend({})'.format(pk_))
f.close()

f = open('/Users/0HB/Desktop/复现/wm/homo/cipher.txt', 'r')
c_ = f.read()
cs = []
eval('cs.extend({})'.format(c_))
f.close()

"""
# c = p*sk+2*r
c = 714750948012851406500586517157106717606895617539492838332982483584450804764237803294239970247209996859617533175677756145984683775979560835419919499626250456011382074927666818288229451188779
p = 17195743943555229331660961462727499

# 不准
r = 2615830010834467677351383140406463 # 2*r % p
sk:41565572874253689464437825525802665878958533473562648432875965578230785556539072257838190060392315994424904212374664222250474284551897781086850148587327684
"""

def decryption(ct, p):
ct = '0b' + ''.join(str(i % p % 2) for i in ct)
m = int(ct, 2).to_bytes((len(ct) - 1) // 8, byteorder='big')
return m


# x = p*sk+2*r
x = pks[0]
p = 17195743943555229331660961462727499
r = 2615830010834467677351383140406463
sk0 = 41565572874253689464437825525802665878958533473562648432875965578230785556539072257838190060392315994424904212374664222250474284551897781086850148587327684
print(decryption(cs, sk0))
sk = ((x//(p**2))*(p**2))//p
print(decryption(cs, sk))
# b'sodayo>A<!!$%!$_Easy_G@CDp_ATtaCk'

wmctf{sodayo>A<!!$%!$_Easy_G@CDp_ATtaCk}

INTERCEPT

人菜+时间不够了

OCOCOCB

2021年

简单看了下往年wp,没思路就没看了