uoftctf2025 WP

clev1L Lv3

Highly Optimized

取余

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
ops = [0x0000000000000000, 0x00CFFB289AF4B1D1, 0x0000000000000000, 0x0000000000000083, 0x0000000000000002,
0x0000000000000001, 0x0000000000000000, 0x0000000000000083, 0x0000000000000003, 0x0000000000000004,
0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x00955F7E7A2ABC09, 0x0000000000000000,
0x0000000000000082, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x0000000000000082,
0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000,
0x0171D0EEF6E34564, 0x0000000000000000, 0x0000000000000092, 0x0000000000000002, 0x0000000000000001,
0x0000000000000000, 0x0000000000000092, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009,
0x0000000000000005, 0x0000000000000000, 0x01C8C0106F982D2C, 0x0000000000000000, 0x0000000000000078,
0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x0000000000000078, 0x0000000000000003,
0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x01A3DF010DB43D50,
0x0000000000000000, 0x0000000000000079, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000,
0x0000000000000079, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005,
0x0000000000000000, 0x0070D52B655429D4, 0x0000000000000000, 0x00000000000000A0, 0x0000000000000002,
0x0000000000000001, 0x0000000000000000, 0x00000000000000A0, 0x0000000000000003, 0x0000000000000004,
0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x0086BA083DB4A00E, 0x0000000000000000,
0x000000000000008F, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x000000000000008F,
0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000,
0x01EE6D244821E17E, 0x0000000000000000, 0x0000000000000093, 0x0000000000000002, 0x0000000000000001,
0x0000000000000000, 0x0000000000000093, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009,
0x0000000000000005, 0x0000000000000000, 0x021F3E25788406B2, 0x0000000000000000, 0x000000000000008A,
0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x000000000000008A, 0x0000000000000003,
0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x013C0021E70D77B4,
0x0000000000000000, 0x00000000000000A3, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000,
0x00000000000000A3, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005,
0x0000000000000000, 0x027EDD2385F658C6, 0x0000000000000000, 0x00000000000000AA, 0x0000000000000002,
0x0000000000000001, 0x0000000000000000, 0x00000000000000AA, 0x0000000000000003, 0x0000000000000004,
0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x00A07DA21EF9E1B4, 0x0000000000000000,
0x0000000000000034, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x0000000000000034,
0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000,
0x00D00E8519E9CC06, 0x0000000000000000, 0x0000000000000041, 0x0000000000000002, 0x0000000000000001,
0x0000000000000000, 0x0000000000000041, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009,
0x0000000000000005, 0x0000000000000000, 0x00D6DFC3F1E11375, 0x0000000000000000, 0x0000000000000078,
0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x0000000000000078, 0x0000000000000003,
0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x00EFAA53300DA663,
0x0000000000000000, 0x000000000000008D, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000,
0x000000000000008D, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005,
0x0000000000000000, 0x007568123DB27DB8, 0x0000000000000000, 0x0000000000000089, 0x0000000000000002,
0x0000000000000001, 0x0000000000000000, 0x0000000000000089, 0x0000000000000003, 0x0000000000000004,
0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x00F174602422164A, 0x0000000000000000,
0x0000000000000087, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x0000000000000087,
0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000,
0x009B991D46E343EE, 0x0000000000000000, 0x0000000000000075, 0x0000000000000002, 0x0000000000000001,
0x0000000000000000, 0x0000000000000075, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009,
0x0000000000000005, 0x0000000000000000, 0x0016C43FB0F9B780, 0x0000000000000000, 0x0000000000000044,
0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x0000000000000044, 0x0000000000000003,
0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x010C7B1796D09C04,
0x0000000000000000, 0x0000000000000044, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000,
0x0000000000000044, 0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005,
0x0000000000000000, 0x005F5CFCF58C8717, 0x0000000000000000, 0x000000000000007A, 0x0000000000000002,
0x0000000000000001, 0x0000000000000000, 0x000000000000007A, 0x0000000000000003, 0x0000000000000004,
0x0000000000000009, 0x0000000000000005, 0x0000000000000000, 0x00D715FDA1220CE0, 0x0000000000000000,
0x0000000000000093, 0x0000000000000002, 0x0000000000000001, 0x0000000000000000, 0x0000000000000093,
0x0000000000000003, 0x0000000000000004, 0x0000000000000009, 0x0000000000000005, 0x0000000000000006]
for i in range(len(ops)):
if ops[i]>0xff:
print(chr(ops[i]%ops[i+2]),end="")

Py_FlagChecker

断在python310.dll的marshal.loads函数就能dump出pyc

pycdas看到flag

Encrypted Flag

爆破时间戳,这时间戳在2034年,我从2025年爆到了1970年,蒙蔽了

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
#include<stdio.h>
#include<stdlib.h>
int main(){
int v4 = 64;
int v6,v9,i;
unsigned int v7;
char v10;
int v5;
int tar[4]={0xa8, 0xf9, 0xdd, 0x73};
int idx[4];
for(int v5=0;v5<0xffffffff;v5+=1){
srand(v5);
if(v5%0x100000==0){
printf("0x%x\n",v5);
}
v6 = 0;
v7 = rand();
char buf[256]={0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF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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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
from z3 import *
from tqdm import tqdm
key1 = [0x57, 0x2D, 0xAF, 0x32, 0x00, 0x00, 0x00, 0x00, 0x4A, 0x0A,
0x27, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x23, 0x58, 0xDA, 0x47,
0x23, 0x58, 0xDA, 0x47, 0x69, 0x52, 0xFD, 0x39, 0x69, 0x52,
0xFD, 0x39, 0xAE, 0xE4, 0xDE, 0x3A, 0x8D, 0xBC, 0x04, 0x7D,
0xE4, 0xEE, 0xF9, 0x44, 0x8D, 0xBC, 0x04, 0x7D, 0x70, 0x19,
0x59, 0xFA, 0xFD, 0xA5, 0x5D, 0x87, 0x19, 0x4B, 0xA4, 0xC3,
0x94, 0xF7, 0xA0, 0xBE, 0x81, 0x97, 0xF1, 0xE7, 0x7C, 0x32,
0xAC, 0x60, 0x65, 0x79, 0x08, 0xA3, 0xF1, 0x8E, 0xA8, 0x1D,
0xC7, 0x97, 0x6E, 0x31, 0xBB, 0xA5, 0xC2, 0x51, 0xDE, 0xDC,
0xCA, 0xF2, 0x2F, 0x52, 0x62, 0xEF, 0x68, 0x2C, 0x7E, 0x4B,
0xD3, 0x89, 0xBC, 0x1A, 0x0D, 0x55, 0x76, 0xE8, 0x22, 0x07,
0x14, 0x07, 0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0xED, 0xE3, 0xE1, 0xE7, 0xE5]
for i in range(len(test)):
test[i] ^= key1[i]

get1 = [0xE8, 0x2A, 0x34, 0xBE, 0x63, 0x3B, 0x87, 0xA3, 0xD1, 0x01,
0xDA, 0x6B, 0x74, 0x8C, 0xA2, 0x11]
get2 = [0xE8, 0x3B, 0xDA, 0x11, 0x63, 0x01, 0xA2, 0xBE, 0xD1, 0x8C,
0x34, 0xA3, 0x74, 0x2A, 0x87, 0x6B]
for k in range(1, 10):
ntest = [0] * 16
for i in range(len(test)):
ntest[get2.index(get1[i])] = buf[test[i]]
test = ntest
ntest = [0] * 16
for i in range(0, len(test), 4):
temp = test[i:i + 4]
ntest[i] = byte1[temp[1]] ^ byte2[temp[0]] ^ temp[3] ^ temp[2]
ntest[i + 1] = byte1[temp[2]] ^ byte2[temp[1]] ^ temp[3] ^ temp[0]
ntest[i + 2] = byte1[temp[3]] ^ byte2[temp[2]] ^ temp[1] ^ temp[0]
ntest[i + 3] = byte1[temp[0]] ^ byte2[temp[3]] ^ temp[2] ^ temp[1]
test = ntest


for i in range(len(test)):
test[i] ^= key1[16 * k + i]

ntest = [0] * 16
for i in range(len(test)):
ntest[get2.index(get1[i])] = buf[test[i]]
test = ntest

for i in range(len(test)):
test[i] ^= key1[16 * 10 + i]


'''解密'''
def sol(tar):
temp = [BitVec('%d' % i, 8) for i in range(4)]
x = Solver()
byte1Arr = Array('byte1', BitVecSort(8), BitVecSort(8))
byte2Arr = Array('byte2', BitVecSort(8), BitVecSort(8))

# 设置 byte1 和 byte2 数组的值
for i in range(256):
x.add(byte1Arr[i] == BitVecVal(byte1[i], 8)) # 用你的值替换 byte1_values
x.add(byte2Arr[i] == BitVecVal(byte2[i], 8)) # 用你的值替换 byte2_values

# 定义目标数组

# 计算 ntest 的每一项,使用条件表达式
ntest = [0] * 4

ntest[0] = Select(byte1Arr, temp[1]) ^ Select(byte2Arr, temp[0]) ^ temp[3] ^ temp[2]
ntest[1] = Select(byte1Arr, temp[2]) ^ Select(byte2Arr, temp[1]) ^ temp[3] ^ temp[0]
ntest[2] = Select(byte1Arr, temp[3]) ^ Select(byte2Arr, temp[2]) ^ temp[1] ^ temp[0]
ntest[3] = Select(byte1Arr, temp[0]) ^ Select(byte2Arr, temp[3]) ^ temp[2] ^ temp[1]

for i in range(4):
x.add(ntest[i] == tar[i])
ans = []
if x.check() == sat:
model = x.model()
for i in range(4):
ans.append(model[temp[i]].as_long().real)
return ans


tests=list(bytes.fromhex('''96 14 91 D5 1A B3 31 F3 89 A5 A1 55 3D 74 4E C9 E6 05 86 7F 71 3F 44 10 E6 50 DE 1A 49 20 35 AA'''))
for _ in range(0,len(tests),16):
test=tests[_:_+16]
for i in range(len(test)):
test[i] ^= key1[16 * 10 + i]
ntest = [0] * 16
for i in range(len(test)):
ntest[i] = test[get2.index(get1[i])]
ntest[i] = buf.index(ntest[i])
test = ntest

for k in range(9, 0, -1):
for i in range(len(test)):
test[i] ^= key1[16 * k + i]
for i in range(0,16,4):
ans=sol(test[i:i+4])
test[i:i+4]=ans

ntest = [0] * 16
for i in range(len(test)):
ntest[i] = test[get2.index(get1[i])]
ntest[i] = buf.index(ntest[i])
test = ntest

for i in range(len(test)):
test[i] ^= key1[i]

print("".join(map(chr,test)),end="")
  • Title: uoftctf2025 WP
  • Author: clev1L
  • Created at : 2025-01-14 15:48:04
  • Updated at : 2025-02-23 12:29:57
  • Link: https://github.com/clev1l/2025/01/14/uoftctf2025-WP/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
uoftctf2025 WP