DASCTF2022_11月赛

babytea

这个题目用到了比较简单的TEA加密,但是使用异常处理来打乱了控制流。

分析

首先是main函数:

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
.text:00A21200                               ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:00A21200 _main proc near ; CODE XREF: __scrt_common_main_seh(void)+F5↓p
.text:00A21200
.text:00A21200 var_2C= dword ptr -2Ch
.text:00A21200 var_28= dword ptr -28h
.text:00A21200 Buf1= byte ptr -24h
.text:00A21200 var_4= dword ptr -4
.text:00A21200 argc= dword ptr 8
.text:00A21200 argv= dword ptr 0Ch
.text:00A21200 envp= dword ptr 10h
.text:00A21200
.text:00A21200 55 push ebp
.text:00A21201 8B EC mov ebp, esp
.text:00A21203 83 EC 2C sub esp, 2Ch
.text:00A21206 A1 44 F0 A3 00 mov eax, ___security_cookie
.text:00A2120B 33 C5 xor eax, ebp
.text:00A2120D 89 45 FC mov [ebp+var_4], eax
.text:00A21210 6A 20 push 20h ; ' ' ; Size
.text:00A21212 6A 00 push 0 ; Val
.text:00A21214 8D 45 DC lea eax, [ebp+Buf1]
.text:00A21217 50 push eax ; void *
.text:00A21218 E8 E3 1B 00 00 call _memset
.text:00A21218
.text:00A2121D 83 C4 0C add esp, 0Ch
.text:00A21220 68 60 81 A3 00 push offset aPleaseInput ; "please input: \n"
.text:00A21225 E8 26 01 00 00 call sub_A21350
.text:00A21225
.text:00A2122A 83 C4 04 add esp, 4
.text:00A2122D 8D 4D DC lea ecx, [ebp+Buf1]
.text:00A21230 51 push ecx
.text:00A21231 68 70 81 A3 00 push offset a32s ; "%32s"
.text:00A21236 E8 55 01 00 00 call sub_A21390
.text:00A21236
.text:00A2123B 83 C4 08 add esp, 8
.text:00A2123E C7 45 D4 08 00 00 00 mov [ebp+var_2C], 8
.text:00A21245 C7 45 D8 00 00 00 00 mov [ebp+var_28], 0
.text:00A2124C EB 09 jmp short loc_A21257
.text:00A2124C
.text:00A2124E ; ---------------------------------------------------------------------------
.text:00A2124E
.text:00A2124E loc_A2124E: ; CODE XREF: _main+7E↓j
.text:00A2124E 8B 55 D8 mov edx, [ebp+var_28]
.text:00A21251 83 C2 01 add edx, 1
.text:00A21254 89 55 D8 mov [ebp+var_28], edx
.text:00A21254
.text:00A21257
.text:00A21257 loc_A21257: ; CODE XREF: _main+4C↑j
.text:00A21257 8B 45 D4 mov eax, [ebp+var_2C]
.text:00A2125A D1 E8 shr eax, 1
.text:00A2125C 39 45 D8 cmp [ebp+var_28], eax
.text:00A2125F 73 1F jnb short loc_A21280
.text:00A2125F
.text:00A21261 68 04 F0 A3 00 push offset keys ; keys
.text:00A21266 8B 4D D8 mov ecx, [ebp+var_28]
.text:00A21269 D1 E1 shl ecx, 1
.text:00A2126B 8D 54 8D DC lea edx, [ebp+ecx*4+Buf1]
.text:00A2126F 52 push edx ; flag
.text:00A21270 A1 14 F0 A3 00 mov eax, a1
.text:00A21275 50 push eax ; a1
.text:00A21276 E8 85 FD FF FF call tea
.text:00A21276
.text:00A2127B 83 C4 0C add esp, 0Ch
.text:00A2127E EB CE jmp short loc_A2124E
.text:00A2127E
.text:00A21280 ; ---------------------------------------------------------------------------
.text:00A21280
.text:00A21280 loc_A21280: ; CODE XREF: _main+5F↑j
.text:00A21280 6A 20 push 20h ; ' ' ; Size
.text:00A21282 68 18 F0 A3 00 push offset dword_A3F018 ; Buf2
.text:00A21287 8D 4D DC lea ecx, [ebp+Buf1]
.text:00A2128A 51 push ecx ; Buf1
.text:00A2128B E8 62 0C 00 00 call _memcmp
.text:00A2128B
.text:00A21290 83 C4 0C add esp, 0Ch
.text:00A21293 85 C0 test eax, eax
.text:00A21295 75 0F jnz short loc_A212A6
.text:00A21295
.text:00A21297 68 78 81 A3 00 push offset aGreatYourInput ; "Great\nYour input is right!!!\n"
.text:00A2129C E8 AF 00 00 00 call sub_A21350
.text:00A2129C
.text:00A212A1 83 C4 04 add esp, 4
.text:00A212A4 EB 0D jmp short loc_A212B3
.text:00A212A4
.text:00A212A6 ; ---------------------------------------------------------------------------
.text:00A212A6
.text:00A212A6 loc_A212A6: ; CODE XREF: _main+95↑j
.text:00A212A6 68 98 81 A3 00 push offset aSorryYourInput ; "Sorry\nYour input is wrong...\n"
.text:00A212AB E8 A0 00 00 00 call sub_A21350
.text:00A212AB
.text:00A212B0 83 C4 04 add esp, 4
.text:00A212B0
.text:00A212B3
.text:00A212B3 loc_A212B3: ; CODE XREF: _main+A4↑j
.text:00A212B3 33 C0 xor eax, eax
.text:00A212B5 8B 4D FC mov ecx, [ebp+var_4]
.text:00A212B8 33 CD xor ecx, ebp ; StackCookie
.text:00A212BA E8 0B 01 00 00 call @__security_check_cookie@4 ; __security_check_cookie(x)
.text:00A212BA
.text:00A212BF 8B E5 mov esp, ebp
.text:00A212C1 5D pop ebp
.text:00A212C2 C3 retn
.text:00A212C2
.text:00A212C2 _main endp

并没有什么需要关注的点,就是调用了tea函数进行加密,接着进行比较并输出结果。

下面是tea函数:

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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
.text:00A21000                               ; int __cdecl tea(unsigned int a1, unsigned int *flag, _DWORD *keys)
.text:00A21000 tea proc near ; CODE XREF: _main+76↓p
.text:00A21000
.text:00A21000 key_3= dword ptr -38h
.text:00A21000 key_2= dword ptr -34h
.text:00A21000 key_1= dword ptr -30h
.text:00A21000 key_0= dword ptr -2Ch
.text:00A21000 var_28= dword ptr -28h
.text:00A21000 sum= dword ptr -24h
.text:00A21000 v1= dword ptr -20h
.text:00A21000 v0= dword ptr -1Ch
.text:00A21000 ms_exc= CPPEH_RECORD ptr -18h
.text:00A21000 a1= dword ptr 8
.text:00A21000 flag= dword ptr 0Ch
.text:00A21000 keys= dword ptr 10h
.text:00A21000
.text:00A21000 ; __unwind { // __except_handler4
.text:00A21000 55 push ebp
.text:00A21001 8B EC mov ebp, esp
.text:00A21003 6A FE push 0FFFFFFFEh
.text:00A21005 68 C0 E0 A3 00 push offset stru_A3E0C0
.text:00A2100A 68 A0 2F A2 00 push offset __except_handler4
.text:00A2100F 64 A1 00 00 00 00 mov eax, large fs:0
.text:00A21015 50 push eax
.text:00A21016 83 C4 D8 add esp, 0FFFFFFD8h
.text:00A21019 53 push ebx
.text:00A2101A 56 push esi
.text:00A2101B 57 push edi
.text:00A2101C A1 44 F0 A3 00 mov eax, ___security_cookie
.text:00A21021 31 45 F8 xor [ebp+ms_exc.registration.ScopeTable], eax
.text:00A21024 33 C5 xor eax, ebp
.text:00A21026 50 push eax
.text:00A21027 8D 45 F0 lea eax, [ebp+ms_exc.registration]
.text:00A2102A 64 A3 00 00 00 00 mov large fs:0, eax
.text:00A21030 89 65 E8 mov [ebp+ms_exc.old_esp], esp
.text:00A21033 B8 04 00 00 00 mov eax, 4
.text:00A21038 6B C8 00 imul ecx, eax, 0
.text:00A2103B 8B 55 0C mov edx, [ebp+flag]
.text:00A2103E 8B 04 0A mov eax, [edx+ecx]
.text:00A21041 89 45 E4 mov [ebp+v0], eax
.text:00A21044 B9 04 00 00 00 mov ecx, 4
.text:00A21049 C1 E1 00 shl ecx, 0
.text:00A2104C 8B 55 0C mov edx, [ebp+flag]
.text:00A2104F 8B 04 0A mov eax, [edx+ecx]
.text:00A21052 89 45 E0 mov [ebp+v1], eax
.text:00A21055 C7 45 DC 00 00 00 00 mov [ebp+sum], 0
.text:00A2105C B9 04 00 00 00 mov ecx, 4
.text:00A21061 6B D1 00 imul edx, ecx, 0
.text:00A21064 8B 45 10 mov eax, [ebp+keys]
.text:00A21067 8B 0C 10 mov ecx, [eax+edx]
.text:00A2106A 89 4D D4 mov [ebp+key_0], ecx
.text:00A2106D BA 04 00 00 00 mov edx, 4
.text:00A21072 C1 E2 00 shl edx, 0
.text:00A21075 8B 45 10 mov eax, [ebp+keys]
.text:00A21078 8B 0C 10 mov ecx, [eax+edx]
.text:00A2107B 89 4D D0 mov [ebp+key_1], ecx
.text:00A2107E BA 04 00 00 00 mov edx, 4
.text:00A21083 D1 E2 shl edx, 1
.text:00A21085 8B 45 10 mov eax, [ebp+keys]
.text:00A21088 8B 0C 10 mov ecx, [eax+edx]
.text:00A2108B 89 4D CC mov [ebp+key_2], ecx
.text:00A2108E BA 04 00 00 00 mov edx, 4
.text:00A21093 6B C2 03 imul eax, edx, 3
.text:00A21096 8B 4D 10 mov ecx, [ebp+keys]
.text:00A21099 8B 14 01 mov edx, [ecx+eax]
.text:00A2109C 89 55 C8 mov [ebp+key_3], edx
.text:00A2109C
.text:00A2109F ; __try { // __except at loc_A210BE
.text:00A2109F C7 45 FC 00 00 00 00 mov [ebp+ms_exc.registration.TryLevel], 0
.text:00A210A6 33 D2 xor edx, edx
.text:00A210A8 33 C0 xor eax, eax
.text:00A210AA 40 inc eax
.text:00A210AB 33 C9 xor ecx, ecx
.text:00A210AD F7 F9 idiv ecx
.text:00A210AD ; } // starts at A2109F
.text:00A210AF C7 45 FC FE FF FF FF mov [ebp+ms_exc.registration.TryLevel], 0FFFFFFFEh
.text:00A210B6 EB 28 jmp short loc_A210E0
.text:00A210B6
.text:00A210B8 ; ---------------------------------------------------------------------------
.text:00A210B8
.text:00A210B8 loc_A210B8: ; DATA XREF: .rdata:stru_A3E0C0↓o
.text:00A210B8 ; __except filter // owned by A2109F
.text:00A210B8 B8 01 00 00 00 mov eax, 1
.text:00A210BD C3 retn
.text:00A210BD
.text:00A210BE ; ---------------------------------------------------------------------------
.text:00A210BE
.text:00A210BE loc_A210BE: ; DATA XREF: .rdata:stru_A3E0C0↓o
.text:00A210BE ; __except(loc_A210B8) // owned by A2109F
.text:00A210BE 8B 65 E8 mov esp, [ebp+ms_exc.old_esp]
.text:00A210C1 8B 45 E4 mov eax, [ebp+v0]
.text:00A210C4 33 05 38 F0 A3 00 xor eax, dword_A3F038
.text:00A210CA 89 45 E4 mov [ebp+v0], eax
.text:00A210CD 8B 4D E0 mov ecx, [ebp+v1]
.text:00A210D0 33 0D 3C F0 A3 00 xor ecx, dword_A3F03C
.text:00A210D6 89 4D E0 mov [ebp+v1], ecx
.text:00A210D9 C7 45 FC FE FF FF FF mov [ebp+ms_exc.registration.TryLevel], 0FFFFFFFEh
.text:00A210D9
.text:00A210E0
.text:00A210E0 loc_A210E0: ; CODE XREF: tea+B6↑j
.text:00A210E0 C7 45 D8 00 00 00 00 mov [ebp+var_28], 0
.text:00A210E7 EB 09 jmp short loc_A210F2
.text:00A210E7
.text:00A210E9 ; ---------------------------------------------------------------------------
.text:00A210E9
.text:00A210E9 loc_A210E9: ; CODE XREF: tea+187↓j
.text:00A210E9 8B 55 D8 mov edx, [ebp+var_28]
.text:00A210EC 83 C2 01 add edx, 1
.text:00A210EF 89 55 D8 mov [ebp+var_28], edx
.text:00A210EF
.text:00A210F2
.text:00A210F2 loc_A210F2: ; CODE XREF: tea+E7↑j
.text:00A210F2 8B 45 D8 mov eax, [ebp+var_28]
.text:00A210F5 3B 45 08 cmp eax, [ebp+a1]
.text:00A210F8 0F 83 8E 00 00 00 jnb loc_A2118C
.text:00A210F8
.text:00A210FE 8B 4D DC mov ecx, [ebp+sum]
.text:00A21101 03 0D 00 F0 A3 00 add ecx, dword_A3F000
.text:00A21107 89 4D DC mov [ebp+sum], ecx
.text:00A21107
.text:00A2110A ; __try { // __except at loc_A2112D
.text:00A2110A C7 45 FC 01 00 00 00 mov [ebp+ms_exc.registration.TryLevel], 1
.text:00A21111 8B 4D DC mov ecx, [ebp+sum]
.text:00A21114 C1 E9 1F shr ecx, 1Fh
.text:00A21117 33 D2 xor edx, edx
.text:00A21119 33 C0 xor eax, eax
.text:00A2111B 40 inc eax
.text:00A2111C F7 F9 idiv ecx
.text:00A2111C ; } // starts at A2110A
.text:00A2111E C7 45 FC FE FF FF FF mov [ebp+ms_exc.registration.TryLevel], 0FFFFFFFEh
.text:00A21125 EB 1C jmp short loc_A21143
.text:00A21125
.text:00A21127 ; ---------------------------------------------------------------------------
.text:00A21127
.text:00A21127 loc_A21127: ; DATA XREF: .rdata:stru_A3E0C0↓o
.text:00A21127 ; __except filter // owned by A2110A
.text:00A21127 B8 01 00 00 00 mov eax, 1
.text:00A2112C C3 retn
.text:00A2112C
.text:00A2112D ; ---------------------------------------------------------------------------
.text:00A2112D
.text:00A2112D loc_A2112D: ; DATA XREF: .rdata:stru_A3E0C0↓o
.text:00A2112D ; __except(loc_A21127) // owned by A2110A
.text:00A2112D 8B 65 E8 mov esp, [ebp+ms_exc.old_esp]
.text:00A21130 8B 55 DC mov edx, [ebp+sum]
.text:00A21133 81 F2 67 45 23 01 xor edx, 1234567h
.text:00A21139 89 55 DC mov [ebp+sum], edx
.text:00A2113C C7 45 FC FE FF FF FF mov [ebp+ms_exc.registration.TryLevel], 0FFFFFFFEh
.text:00A2113C
.text:00A21143
.text:00A21143 loc_A21143: ; CODE XREF: tea+125↑j
.text:00A21143 8B 45 E0 mov eax, [ebp+v1]
.text:00A21146 C1 E0 04 shl eax, 4
.text:00A21149 03 45 D4 add eax, [ebp+key_0]
.text:00A2114C 8B 4D E0 mov ecx, [ebp+v1]
.text:00A2114F 03 4D DC add ecx, [ebp+sum]
.text:00A21152 33 C1 xor eax, ecx
.text:00A21154 8B 55 E0 mov edx, [ebp+v1]
.text:00A21157 C1 EA 05 shr edx, 5
.text:00A2115A 03 55 D0 add edx, [ebp+key_1]
.text:00A2115D 33 C2 xor eax, edx
.text:00A2115F 03 45 E4 add eax, [ebp+v0]
.text:00A21162 89 45 E4 mov [ebp+v0], eax
.text:00A21165 8B 45 E4 mov eax, [ebp+v0]
.text:00A21168 C1 E0 04 shl eax, 4
.text:00A2116B 03 45 CC add eax, [ebp+key_2]
.text:00A2116E 8B 4D E4 mov ecx, [ebp+v0]
.text:00A21171 03 4D DC add ecx, [ebp+sum]
.text:00A21174 33 C1 xor eax, ecx
.text:00A21176 8B 55 E4 mov edx, [ebp+v0]
.text:00A21179 C1 EA 05 shr edx, 5
.text:00A2117C 03 55 C8 add edx, [ebp+key_3]
.text:00A2117F 33 C2 xor eax, edx
.text:00A21181 03 45 E0 add eax, [ebp+v1]
.text:00A21184 89 45 E0 mov [ebp+v1], eax
.text:00A21187 E9 5D FF FF FF jmp loc_A210E9
.text:00A21187
.text:00A2118C ; ---------------------------------------------------------------------------
.text:00A2118C
.text:00A2118C loc_A2118C: ; CODE XREF: tea+F8↑j
.text:00A2118C ; __try { // __except at loc_A211AB
.text:00A2118C C7 45 FC 02 00 00 00 mov [ebp+ms_exc.registration.TryLevel], 2
.text:00A21193 33 D2 xor edx, edx
.text:00A21195 33 C0 xor eax, eax
.text:00A21197 40 inc eax
.text:00A21198 33 C9 xor ecx, ecx
.text:00A2119A F7 F9 idiv ecx
.text:00A2119A ; } // starts at A2118C
.text:00A2119C C7 45 FC FE FF FF FF mov [ebp+ms_exc.registration.TryLevel], 0FFFFFFFEh
.text:00A211A3 EB 21 jmp short loc_A211C6
.text:00A211A3
.text:00A211A5 ; ---------------------------------------------------------------------------
.text:00A211A5
.text:00A211A5 loc_A211A5: ; DATA XREF: .rdata:stru_A3E0C0↓o
.text:00A211A5 ; __except filter // owned by A2118C
.text:00A211A5 B8 01 00 00 00 mov eax, 1
.text:00A211AA C3 retn
.text:00A211AA
.text:00A211AB ; ---------------------------------------------------------------------------
.text:00A211AB
.text:00A211AB loc_A211AB: ; DATA XREF: .rdata:stru_A3E0C0↓o
.text:00A211AB ; __except(loc_A211A5) // owned by A2118C
.text:00A211AB 8B 65 E8 mov esp, [ebp+ms_exc.old_esp]
.text:00A211AE 8B 45 E4 mov eax, [ebp+v0]
.text:00A211B1 A3 38 F0 A3 00 mov dword_A3F038, eax
.text:00A211B6 8B 4D E0 mov ecx, [ebp+v1]
.text:00A211B9 89 0D 3C F0 A3 00 mov dword_A3F03C, ecx
.text:00A211BF C7 45 FC FE FF FF FF mov [ebp+ms_exc.registration.TryLevel], 0FFFFFFFEh
.text:00A211BF
.text:00A211C6
.text:00A211C6 loc_A211C6: ; CODE XREF: tea+1A3↑j
.text:00A211C6 BA 04 00 00 00 mov edx, 4
.text:00A211CB 6B C2 00 imul eax, edx, 0
.text:00A211CE 8B 4D 0C mov ecx, [ebp+flag]
.text:00A211D1 8B 55 E4 mov edx, [ebp+v0]
.text:00A211D4 89 14 01 mov [ecx+eax], edx
.text:00A211D7 B8 04 00 00 00 mov eax, 4
.text:00A211DC C1 E0 00 shl eax, 0
.text:00A211DF 8B 4D 0C mov ecx, [ebp+flag]
.text:00A211E2 8B 55 E0 mov edx, [ebp+v1]
.text:00A211E5 89 14 01 mov [ecx+eax], edx
.text:00A211E8 8B 4D F0 mov ecx, [ebp+ms_exc.registration.Next]
.text:00A211EB 64 89 0D 00 00 00 00 mov large fs:0, ecx
.text:00A211F2 59 pop ecx
.text:00A211F3 5F pop edi
.text:00A211F4 5E pop esi
.text:00A211F5 5B pop ebx
.text:00A211F6 8B E5 mov esp, ebp
.text:00A211F8 5D pop ebp
.text:00A211F9 C3 retn
.text:00A211F9 ; } // starts at A21000
.text:00A211F9
.text:00A211F9 tea endp

我们可以发现函数最开始有mov eax, large fs:0指令(见上图),说明函数用到了异常处理,这时直接F5就大概率没有用了,虽然有patch的方法,但是因为题目比较简单我就直接汇编分析了。

接下来的部分是将参数分别放入v0、v1、keys,并初始化sum,并且会触发第一次异常:

这次异常触发后程序会执行loc_A210BE部分的代码,将v0、v1分别与dword_A3F038dword_A3F03C进行xor。

接下来就是加密部分,我们都知道TEA加密每轮会对sum进行修改,经过分析发现,程序每次修改完sum后会判断sum >> 31的结果是否为0,如果为0就会触发异常,而在异常处理中会将sum与1234567h进行xor(见上图)。

对sum进行修改之后就是正常的加密流程,使用sum、keys、移位操作对v0、v1进行加法操作。

在32轮加密结束之后会触发最后一次异常,将v0、v1的结果存入dword_A3F038dword_A3F03C为了下一次加密使用。

解密

因为sum每次不一定只是加了delta,也可能是还进行了异或,所以我们不能直接让解密程序的sum等于delta * 32,这里我们先模拟一边加密过程,将sum在每轮的值保存到list,供解密使用。

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
import ctypes

g0 = ctypes.c_uint32(0x01234567)
g1 = ctypes.c_uint32(0x89ABCDEF)


def encrypt():
sums = []
sum = ctypes.c_uint32(0)
delta = 0x9E3779B1
for i in range(32):
sum.value += delta
if ((sum.value) >> 31) == 0:
sum.value ^= 0x1234567
sums.append(sum.value)

return sums


def decrypt(v: list, k: list):
sums = encrypt()
global g0, g1
v0 = ctypes.c_uint32(v[0])
v1 = ctypes.c_uint32(v[1])
k = [ctypes.c_uint32(kk) for kk in k]
for i in range(32):
sum = ctypes.c_uint32(sums[len(sums) - 1 - i])
v1.value -= (((v0.value << 4)) +
k[2].value) ^ (v0.value + sum.value) ^ (((v0.value >> 5)) + k[3].value)
v0.value -= (((v1.value << 4)) +
k[0].value) ^ (v1.value + sum.value) ^ (((v1.value >> 5)) + k[1].value)

v0.value ^= g0.value
v1.value ^= g1.value
g0 = ctypes.c_uint32(v[0])
g1 = ctypes.c_uint32(v[1])
v[0] = v0.value
v[1] = v1.value
return v[0], v[1]


s = [0x5E27B530, 0x0BDBEF7F3, 0x0E3516A8F, 0x5D836CFE,
0x0D83DFA09, 0x8EFC737A, 0x55A853A3, 0x7A564EC5]
k = [0x67452301, 0x0EFCDAB89, 0x98BADCFE, 0x10325476]

t = []
flag = b''
tmp = [s[0], s[1]]
tmp[0], tmp[1] = decrypt(tmp, k)
flag += int.to_bytes(tmp[0], 4, 'little')
flag += int.to_bytes(tmp[1], 4, 'little')
tmp = [s[2], s[3]]
tmp[0], tmp[1] = decrypt(tmp, k)
flag += int.to_bytes(tmp[0], 4, 'little')
flag += int.to_bytes(tmp[1], 4, 'little')
tmp = [s[4], s[5]]
tmp[0], tmp[1] = decrypt(tmp, k)
flag += int.to_bytes(tmp[0], 4, 'little')
flag += int.to_bytes(tmp[1], 4, 'little')
tmp = [s[6], s[7]]
tmp[0], tmp[1] = decrypt(tmp, k)
flag += int.to_bytes(tmp[0], 4, 'little')
flag += int.to_bytes(tmp[1], 4, 'little')
print(flag)

babysmc

顾名思义,题目用到了SMC,还不了解的同学可以自行Google。

分析

程序随便输入一个字符串之后会卡死一段时间,最后也没有输出对错,猜测应该是输入的字符会在SMC中用到,如果输入的不对那么SMC就无法还原正确的汇编指令,程序自然无法正常执行。

main函数如下,我们会发现里面调用了sub_351850sub_3518C0,但是这两个函数的汇编看起来不太对,说明这两个函数应该是需要被SMC解密的。

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
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
.text:003546C0             ; int __cdecl main(int argc, const char **argv, const char **envp)
.text:003546C0 _main proc near ; CODE XREF: __scrt_common_main_seh(void)+F5↓p
.text:003546C0
.text:003546C0 var_28= byte ptr -28h
.text:003546C0 var_4= dword ptr -4
.text:003546C0
.text:003546C0 55 push ebp
.text:003546C1 8B EC mov ebp, esp
.text:003546C3 83 EC 28 sub esp, 28h
.text:003546C6 A1 FC 3E 37+mov eax, ___security_cookie
.text:003546C6 00
.text:003546CB 33 C5 xor eax, ebp
.text:003546CD 89 45 FC mov [ebp+var_4], eax
.text:003546D0 6A 22 push 22h ; '"' ; Size
.text:003546D2 6A 00 push 0 ; Val
.text:003546D4 8D 45 D8 lea eax, [ebp+var_28]
.text:003546D7 50 push eax ; void *
.text:003546D8 E8 03 0D 00+call _memset
.text:003546D8 00
.text:003546D8
.text:003546DD 83 C4 0C add esp, 0Ch
.text:003546E0 68 70 B1 36+push offset aPleaseInput ; "please input: \n"
.text:003546E0 00
.text:003546E5 E8 46 01 00+call printf
.text:003546E5 00
.text:003546E5
.text:003546EA 83 C4 04 add esp, 4
.text:003546ED 8D 4D D8 lea ecx, [ebp+var_28]
.text:003546F0 51 push ecx
.text:003546F1 68 80 B1 36+push offset a34s ; "%34s"
.text:003546F1 00
.text:003546F6 E8 75 01 00+call scanf
.text:003546F6 00
.text:003546F6
.text:003546FB 83 C4 08 add esp, 8
.text:003546FE BA 01 00 00+mov edx, 1
.text:003546FE 00
.text:00354703 6B C2 21 imul eax, edx, 21h ; '!'
.text:00354706 0F B6 4C 05+movzx ecx, [ebp+eax+var_28]
.text:00354706 D8
.text:0035470B 51 push ecx
.text:0035470C BA 01 00 00+mov edx, 1
.text:0035470C 00
.text:00354711 6B C2 00 imul eax, edx, 0
.text:00354714 0F B6 4C 05+movzx ecx, [ebp+eax+var_28]
.text:00354714 D8
.text:00354719 51 push ecx
.text:0035471A E8 11 FF FF+call smc
.text:0035471A FF
.text:0035471A
.text:0035471F 83 C4 08 add esp, 8
.text:00354722 EB 15 jmp short loc_354739
.text:00354722
.text:00354724 ; ---------------------------------------------------------------------------
.text:00354724 BA 01 00 00+mov edx, 1
.text:00354724 00
.text:00354729 C1 E2 00 shl edx, 0
.text:0035472C 8D 44 15 D8 lea eax, [ebp+edx+var_28]
.text:00354730 50 push eax
.text:00354731 E8 1A D1 FF+call sub_351850
.text:00354731 FF
.text:00354731
.text:00354736 83 C4 08 add esp, 8
.text:00354736
.text:00354739
.text:00354739 loc_354739: ; CODE XREF: _main+62↑j
.text:00354739 6A 10 push 10h
.text:0035473B B9 01 00 00+mov ecx, 1
.text:0035473B 00
.text:00354740 C1 E1 00 shl ecx, 0
.text:00354743 8D 54 0D D8 lea edx, [ebp+ecx+var_28]
.text:00354747 52 push edx
.text:00354748 E8 73 D1 FF+call sub_3518C0
.text:00354748 FF
.text:00354748
.text:0035474D 83 C4 08 add esp, 8
.text:00354750 0F B6 C0 movzx eax, al
.text:00354753 85 C0 test eax, eax
.text:00354755 74 2D jz short loc_354784
.text:00354755
.text:00354757 6A 10 push 10h
.text:00354759 B9 01 00 00+mov ecx, 1
.text:00354759 00
.text:0035475E 6B D1 11 imul edx, ecx, 11h
.text:00354761 8D 44 15 D8 lea eax, [ebp+edx+var_28]
.text:00354765 50 push eax
.text:00354766 E8 C5 E7 FF+call sub_352F30
.text:00354766 FF
.text:00354766
.text:0035476B 83 C4 08 add esp, 8
.text:0035476E 0F B6 C8 movzx ecx, al
.text:00354771 85 C9 test ecx, ecx
.text:00354773 74 0F jz short loc_354784
.text:00354773
.text:00354775 68 88 B1 36+push offset aGreatYourInput ; "Great\nYour input is right!!!\n"
.text:00354775 00
.text:0035477A E8 B1 00 00+call printf
.text:0035477A 00
.text:0035477A
.text:0035477F 83 C4 04 add esp, 4
.text:00354782 EB 0D jmp short loc_354791
.text:00354782
.text:00354784 ; ---------------------------------------------------------------------------
.text:00354784
.text:00354784 loc_354784: ; CODE XREF: _main+95↑j
.text:00354784 ; _main+B3↑j
.text:00354784 68 A8 B1 36+push offset aSorryYourInput ; "Sorry\nYour input is wrong...\n"
.text:00354784 00
.text:00354789 E8 A2 00 00+call printf
.text:00354789 00
.text:00354789
.text:0035478E 83 C4 04 add esp, 4
.text:0035478E
.text:00354791
.text:00354791 loc_354791: ; CODE XREF: _main+C2↑j
.text:00354791 33 C0 xor eax, eax
.text:00354793 8B 4D FC mov ecx, [ebp+var_4]
.text:00354796 33 CD xor ecx, ebp ; StackCookie
.text:00354798 E8 0D 01 00+call @__security_check_cookie@4 ; __security_check_cookie(x)
.text:00354798 00
.text:00354798
.text:0035479D 8B E5 mov esp, ebp
.text:0035479F 5D pop ebp
.text:003547A0 C3 retn
.text:003547A0
.text:003547A0 _main endp

这里smc是用来SMC解密的,它的参数是inpStr[0]inpStr[33],而这两个参数用来与内存中的数据分别进行xor操作,这里我们就能够明确SMC是与我们的输入有联系的,再仔细看smc函数的内部,首先smc函数将0x351850开始的0x100个字节与inpStr[0]进行xor,然后是将0x003517C0开始的0x100个字节与inpStr[33]进行xor。

这里就需要我们对汇编语言的机器码有一些了解了,首先我们不难发现程序中的函数一般都是以push ebp开头的,也就是调整栈指针相关的指令,那么按理来说sub_351850sub_3517C0也不例外,而push ebp的机器码是0x55,也就是说函数都是以0x55为第一个字节开头的。

在SMC解密前,sub_351850sub_3517C0的第一个字节是0x570x74,所以我们可以根据0x74 ^ ord('!') == 0x55(0x57 ^ ord('!')) ^ ord('#') == 0x55来得知inpStr[0]就是#inpStr[33]就是!。(这里要注意sub_351850是被xor了两次,自己仔细分析一下就能得知)

sub_351850如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
int __cdecl sub_351850(int a1, int a2)
{
int result; // eax
unsigned int i; // [esp+0h] [ebp-14h]
int v4; // [esp+0h] [ebp-14h]
char v5[12]; // [esp+4h] [ebp-10h] BYREF

memset(v5, 0, 0xAu);
result = Address(v5);
for ( i = 0; i < 0xA; i = v4 + 1 )
result = funcs_8418AB[(unsigned __int8)v5[a2]](a1, a2);
return result;
}

SMC还原得到的sub_3518C0如下:

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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
bool __cdecl sub_3518C0(unsigned __int8 *a1)
{
return dword_372000[12] == 199 * a1[9]
+ 98 * a1[7]
+ 192 * a1[8]
+ 23 * a1[12]
+ 79 * a1[14]
+ 77 * a1[10]
+ 185 * a1[13]
+ 135 * a1[15]
+ 119 * a1[4]
+ 54 * *a1
+ 41 * a1[1]
+ 124 * a1[6]
+ 18 * a1[2]
+ 181 * a1[11]
+ 191 * a1[5]
+ 7 * a1[3]
&& dword_372000[3] == 210 * a1[11]
+ 26 * a1[15]
+ 169 * *a1
+ 177 * a1[13]
+ a1[6]
+ 205 * a1[8]
+ 223 * a1[10]
+ 32 * a1[5]
+ 225 * a1[3]
+ 61 * a1[14]
+ 72 * a1[1]
+ 186 * a1[9]
+ 253 * a1[12]
+ 205 * a1[2]
+ 49 * a1[4]
+ 232 * a1[7]
&& dword_372000[13] == 192 * a1[3]
+ 22 * a1[10]
+ 175 * a1[1]
+ 184 * a1[7]
+ 116 * a1[15]
+ 70 * a1[13]
+ 153 * a1[14]
+ 119 * *a1
+ 217 * a1[6]
+ 123 * a1[5]
+ 17 * a1[2]
+ 244 * a1[12]
+ 116 * a1[8]
+ 46 * a1[4]
+ 19 * a1[9]
+ 130 * a1[11]
&& dword_372000[7] == 41 * a1[12]
+ 71 * a1[7]
+ 185 * a1[1]
+ 69 * a1[11]
+ 142 * a1[8]
+ 221 * a1[5]
+ 24 * a1[3]
+ 208 * a1[6]
+ 41 * a1[9]
+ 159 * a1[2]
+ 231 * a1[14]
+ 235 * a1[13]
+ 225 * *a1
+ (a1[4] << 6)
+ 162 * a1[10]
+ 134 * a1[15]
&& dword_372000[11] == 36 * a1[12]
+ 220 * a1[4]
+ 110 * a1[13]
+ 45 * a1[7]
+ 123 * a1[9]
+ 133 * a1[1]
+ 101 * a1[5]
+ 137 * a1[10]
+ 102 * *a1
+ 227 * a1[14]
+ 94 * a1[15]
+ 18 * a1[2]
+ 22 * a1[6]
+ 189 * a1[11]
+ 218 * a1[8]
&& dword_372000[15] == 86 * a1[11]
+ 31 * a1[9]
+ 229 * a1[6]
+ 27 * a1[3]
+ 6 * a1[12]
+ 13 * a1[10]
+ 158 * a1[1]
+ 89 * a1[7]
+ 35 * a1[15]
+ 126 * a1[8]
+ 165 * a1[13]
+ 220 * *a1
+ 138 * a1[5]
+ 100 * a1[4]
+ 84 * a1[14]
+ 175 * a1[2]
&& dword_372000[8] == 7 * a1[1]
+ 28 * a1[8]
+ 131 * a1[10]
+ 6 * a1[6]
+ 254 * *a1
+ 130 * a1[13]
+ 124 * a1[3]
+ 55 * a1[12]
+ 157 * a1[14]
+ 175 * a1[5]
+ 140 * a1[4]
+ 241 * a1[9]
+ 11 * a1[11]
+ 211 * a1[2]
+ 121 * a1[7]
+ 200 * a1[15]
&& dword_372000[6] == 195 * a1[14]
+ 197 * a1[13]
+ 218 * a1[7]
+ 83 * a1[1]
+ 98 * a1[2]
+ 70 * a1[10]
+ 229 * a1[15]
+ 148 * a1[11]
+ 195 * *a1
+ 94 * a1[6]
+ 211 * a1[12]
+ 220 * a1[9]
+ 81 * a1[5]
+ 253 * a1[8]
+ 78 * a1[4]
+ 4 * a1[3]
&& dword_372000[14] == 3 * a1[4]
+ 136 * a1[7]
+ 156 * a1[3]
+ 189 * a1[1]
+ 244 * a1[12]
+ 157 * a1[15]
+ 83 * a1[9]
+ 6 * *a1
+ 113 * a1[6]
+ 63 * a1[14]
+ 35 * a1[2]
+ 22 * a1[8]
+ 26 * a1[10]
+ 62 * a1[11]
+ 98 * a1[5]
+ 110 * a1[13]
&& dword_372000[4] == 96 * a1[4]
+ 248 * a1[8]
+ 191 * a1[9]
+ 194 * a1[2]
+ 154 * a1[1]
+ 31 * a1[6]
+ 157 * a1[7]
+ 248 * a1[13]
+ 81 * a1[15]
+ 56 * a1[10]
+ 52 * *a1
+ 94 * a1[12]
+ 212 * a1[5]
+ 83 * a1[3]
+ 83 * a1[14]
+ 158 * a1[11]
&& dword_372000[1] == 67 * a1[4]
+ 220 * a1[2]
+ 123 * a1[11]
+ 168 * a1[5]
+ 23 * a1[12]
+ 148 * a1[7]
+ 127 * a1[10]
+ 194 * a1[1]
+ 132 * a1[8]
+ 44 * *a1
+ 60 * a1[13]
+ 98 * a1[15]
+ 38 * a1[14]
+ 245 * a1[9]
+ 159 * a1[6]
+ 146 * a1[3]
&& dword_372000[5] == 132 * a1[3]
+ 10 * a1[7]
+ 95 * *a1
+ 83 * a1[10]
+ 99 * a1[1]
+ 77 * a1[12]
+ 195 * a1[2]
+ 47 * a1[6]
+ 38 * a1[13]
+ 178 * a1[8]
+ 74 * a1[4]
+ 86 * a1[11]
+ 208 * a1[9]
+ 240 * a1[14]
+ 120 * a1[5]
+ 43 * a1[15]
&& dword_372000[9] == 172 * a1[1]
+ 110 * a1[2]
+ 92 * a1[7]
+ 126 * a1[15]
+ 91 * *a1
+ 77 * a1[6]
+ 207 * a1[5]
+ 249 * a1[11]
+ 240 * a1[12]
+ 129 * a1[10]
+ 6 * a1[13]
+ 100 * a1[3]
+ a1[14]
+ 76 * a1[9]
+ 127 * a1[4]
+ 4 * a1[8]
&& dword_372000[10] == 46 * a1[15]
+ 37 * *a1
+ 3 * a1[3]
+ 72 * a1[6]
+ 116 * a1[7]
+ 186 * a1[1]
+ 221 * a1[14]
+ 236 * a1[4]
+ 79 * a1[2]
+ 175 * a1[10]
+ 184 * a1[9]
+ 160 * a1[11]
+ 227 * a1[12]
+ 99 * a1[8]
+ 71 * a1[13]
+ 4 * a1[5]
&& dword_372000[0] == 203 * a1[3]
+ 31 * *a1
+ 11 * a1[14]
+ 149 * a1[7]
+ 215 * a1[5]
+ 206 * a1[1]
+ 245 * a1[6]
+ 9 * a1[11]
+ 16 * a1[10]
+ 241 * a1[13]
+ 110 * a1[8]
+ 175 * a1[2]
+ 38 * a1[4]
+ 227 * a1[9]
+ 208 * a1[12]
+ 8 * a1[15]
&& dword_372000[2] == 132 * a1[3]
+ 119 * a1[14]
+ 26 * a1[8]
+ 24 * a1[6]
+ 121 * a1[11]
+ 235 * a1[2]
+ 228 * a1[12]
+ 34 * a1[5]
+ 37 * a1[15]
+ 24 * a1[9]
+ 145 * a1[13]
+ 199 * a1[4]
+ 173 * a1[10]
+ 58 * *a1
+ 246 * a1[7]
+ 199 * a1[1];
}
1
2, 3, 5, 7, 11, 13, 17, 19, 23, 29
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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
bool __cdecl sub_8418C0(unsigned __int8 *a1)
{
return dword_862000[12] == 199 * a1[9]
+ 98 * a1[7]
+ 192 * a1[8]
+ 23 * a1[12]
+ 79 * a1[14]
+ 77 * a1[10]
+ 185 * a1[13]
+ 135 * a1[15]
+ 119 * a1[4]
+ 54 * *a1
+ 41 * a1[1]
+ 124 * a1[6]
+ 18 * a1[2]
+ 181 * a1[11]
+ 191 * a1[5]
+ 7 * a1[3]
&& dword_862000[3] == 210 * a1[11]
+ 26 * a1[15]
+ 169 * *a1
+ 177 * a1[13]
+ a1[6]
+ 205 * a1[8]
+ 223 * a1[10]
+ 32 * a1[5]
+ 225 * a1[3]
+ 61 * a1[14]
+ 72 * a1[1]
+ 186 * a1[9]
+ 253 * a1[12]
+ 205 * a1[2]
+ 49 * a1[4]
+ 232 * a1[7]
&& dword_862000[13] == 192 * a1[3]
+ 22 * a1[10]
+ 175 * a1[1]
+ 184 * a1[7]
+ 116 * a1[15]
+ 70 * a1[13]
+ 153 * a1[14]
+ 119 * *a1
+ 217 * a1[6]
+ 123 * a1[5]
+ 17 * a1[2]
+ 244 * a1[12]
+ 116 * a1[8]
+ 46 * a1[4]
+ 19 * a1[9]
+ 130 * a1[11]
&& dword_862000[7] == 41 * a1[12]
+ 71 * a1[7]
+ 185 * a1[1]
+ 69 * a1[11]
+ 142 * a1[8]
+ 221 * a1[5]
+ 24 * a1[3]
+ 208 * a1[6]
+ 41 * a1[9]
+ 159 * a1[2]
+ 231 * a1[14]
+ 235 * a1[13]
+ 225 * *a1
+ (a1[4] << 6)
+ 162 * a1[10]
+ 134 * a1[15]
&& dword_862000[11] == 36 * a1[12]
+ 220 * a1[4]
+ 110 * a1[13]
+ 45 * a1[7]
+ 123 * a1[9]
+ 133 * a1[1]
+ 101 * a1[5]
+ 137 * a1[10]
+ 102 * *a1
+ 227 * a1[14]
+ 94 * a1[15]
+ 18 * a1[2]
+ 22 * a1[6]
+ 189 * a1[11]
+ 218 * a1[8]
&& dword_862000[15] == 86 * a1[11]
+ 31 * a1[9]
+ 229 * a1[6]
+ 27 * a1[3]
+ 6 * a1[12]
+ 13 * a1[10]
+ 158 * a1[1]
+ 89 * a1[7]
+ 35 * a1[15]
+ 126 * a1[8]
+ 165 * a1[13]
+ 220 * *a1
+ 138 * a1[5]
+ 100 * a1[4]
+ 84 * a1[14]
+ 175 * a1[2]
&& dword_862000[8] == 7 * a1[1]
+ 28 * a1[8]
+ 131 * a1[10]
+ 6 * a1[6]
+ 254 * *a1
+ 130 * a1[13]
+ 124 * a1[3]
+ 55 * a1[12]
+ 157 * a1[14]
+ 175 * a1[5]
+ 140 * a1[4]
+ 241 * a1[9]
+ 11 * a1[11]
+ 211 * a1[2]
+ 121 * a1[7]
+ 200 * a1[15]
&& dword_862000[6] == 195 * a1[14]
+ 197 * a1[13]
+ 218 * a1[7]
+ 83 * a1[1]
+ 98 * a1[2]
+ 70 * a1[10]
+ 229 * a1[15]
+ 148 * a1[11]
+ 195 * *a1
+ 94 * a1[6]
+ 211 * a1[12]
+ 220 * a1[9]
+ 81 * a1[5]
+ 253 * a1[8]
+ 78 * a1[4]
+ 4 * a1[3]
&& dword_862000[14] == 3 * a1[4]
+ 136 * a1[7]
+ 156 * a1[3]
+ 189 * a1[1]
+ 244 * a1[12]
+ 157 * a1[15]
+ 83 * a1[9]
+ 6 * *a1
+ 113 * a1[6]
+ 63 * a1[14]
+ 35 * a1[2]
+ 22 * a1[8]
+ 26 * a1[10]
+ 62 * a1[11]
+ 98 * a1[5]
+ 110 * a1[13]
&& dword_862000[4] == 96 * a1[4]
+ 248 * a1[8]
+ 191 * a1[9]
+ 194 * a1[2]
+ 154 * a1[1]
+ 31 * a1[6]
+ 157 * a1[7]
+ 248 * a1[13]
+ 81 * a1[15]
+ 56 * a1[10]
+ 52 * *a1
+ 94 * a1[12]
+ 212 * a1[5]
+ 83 * a1[3]
+ 83 * a1[14]
+ 158 * a1[11]
&& dword_862000[1] == 67 * a1[4]
+ 220 * a1[2]
+ 123 * a1[11]
+ 168 * a1[5]
+ 23 * a1[12]
+ 148 * a1[7]
+ 127 * a1[10]
+ 194 * a1[1]
+ 132 * a1[8]
+ 44 * *a1
+ 60 * a1[13]
+ 98 * a1[15]
+ 38 * a1[14]
+ 245 * a1[9]
+ 159 * a1[6]
+ 146 * a1[3]
&& dword_862000[5] == 132 * a1[3]
+ 10 * a1[7]
+ 95 * *a1
+ 83 * a1[10]
+ 99 * a1[1]
+ 77 * a1[12]
+ 195 * a1[2]
+ 47 * a1[6]
+ 38 * a1[13]
+ 178 * a1[8]
+ 74 * a1[4]
+ 86 * a1[11]
+ 208 * a1[9]
+ 240 * a1[14]
+ 120 * a1[5]
+ 43 * a1[15]
&& dword_862000[9] == 172 * a1[1]
+ 110 * a1[2]
+ 92 * a1[7]
+ 126 * a1[15]
+ 91 * *a1
+ 77 * a1[6]
+ 207 * a1[5]
+ 249 * a1[11]
+ 240 * a1[12]
+ 129 * a1[10]
+ 6 * a1[13]
+ 100 * a1[3]
+ a1[14]
+ 76 * a1[9]
+ 127 * a1[4]
+ 4 * a1[8]
&& dword_862000[10] == 46 * a1[15]
+ 37 * *a1
+ 3 * a1[3]
+ 72 * a1[6]
+ 116 * a1[7]
+ 186 * a1[1]
+ 221 * a1[14]
+ 236 * a1[4]
+ 79 * a1[2]
+ 175 * a1[10]
+ 184 * a1[9]
+ 160 * a1[11]
+ 227 * a1[12]
+ 99 * a1[8]
+ 71 * a1[13]
+ 4 * a1[5]
&& dword_862000[0] == 203 * a1[3]
+ 31 * *a1
+ 11 * a1[14]
+ 149 * a1[7]
+ 215 * a1[5]
+ 206 * a1[1]
+ 245 * a1[6]
+ 9 * a1[11]
+ 16 * a1[10]
+ 241 * a1[13]
+ 110 * a1[8]
+ 175 * a1[2]
+ 38 * a1[4]
+ 227 * a1[9]
+ 208 * a1[12]
+ 8 * a1[15]
&& dword_862000[2] == 132 * a1[3]
+ 119 * a1[14]
+ 26 * a1[8]
+ 24 * a1[6]
+ 121 * a1[11]
+ 235 * a1[2]
+ 228 * a1[12]
+ 34 * a1[5]
+ 37 * a1[15]
+ 24 * a1[9]
+ 145 * a1[13]
+ 199 * a1[4]
+ 173 * a1[10]
+ 58 * *a1
+ 246 * a1[7]
+ 199 * a1[1];
}

解密

因为代码太多了,就不一一列举了,经过分析可以发现首先是用了Sbox进行字节代换,然后是进行32个多项式计算,也就是32个方程组,直接z3即可。

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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
import z3

s = z3.Solver()
eq1 = [
z3.IntVal(0x2A81A),
z3.IntVal(0x28D44),
z3.IntVal(0x22653),
z3.IntVal(0x2E993),
z3.IntVal(0x249B5),
z3.IntVal(0x24265),
z3.IntVal(0x3253D),
z3.IntVal(0x2D77B),
z3.IntVal(0x282C8),
z3.IntVal(0x22892),
z3.IntVal(0x2BD54),
z3.IntVal(0x2482E),
z3.IntVal(0x24C1F),
z3.IntVal(0x28127),
z3.IntVal(0x1E62E),
z3.IntVal(0x1F009),
]

eq2 = [
z3.IntVal(0x27FC8),
z3.IntVal(0x29049),
z3.IntVal(0x3336C),
z3.IntVal(0x2C6A7),
z3.IntVal(0x36CB0),
z3.IntVal(0x1F2BB),
z3.IntVal(0x35262),
z3.IntVal(0x2AEDF),
z3.IntVal(0x2955E),
z3.IntVal(0x2EE10),
z3.IntVal(0x2B057),
z3.IntVal(0x2FDE8),
z3.IntVal(0x29B92),
z3.IntVal(0x35842),
z3.IntVal(0x294D2),
z3.IntVal(0x2B984),
]

a1 = [z3.Int(f'flag_{i}') for i in range(16)]


s.add(eq1[12] == 199 * a1[9] + 98 * a1[7] + 192 * a1[8] + 23 * a1[12] + 79 * a1[14] + 77 * a1[10] + 185 * a1[13] + 135 *
a1[15] + 119 * a1[4] + 54 * a1[0] + 41 * a1[1] + 124 * a1[6] + 18 * a1[2] + 181 * a1[11] + 191 * a1[5] + 7 * a1[3])
s.add(eq1[3] == 210 * a1[11] + 26 * a1[15] + 169 * a1[0] + 177 * a1[13] + a1[6] + 205 * a1[8] + 223 * a1[10] + 32 *
a1[5] + 225 * a1[3] + 61 * a1[14] + 72 * a1[1] + 186 * a1[9] + 253 * a1[12] + 205 * a1[2] + 49 * a1[4] + 232 * a1[7])
s.add(eq1[13] == 192 * a1[3] + 22 * a1[10] + 175 * a1[1] + 184 * a1[7] + 116 * a1[15] + 70 * a1[13] + 153 * a1[14] + 119 *
a1[0] + 217 * a1[6] + 123 * a1[5] + 17 * a1[2] + 244 * a1[12] + 116 * a1[8] + 46 * a1[4] + 19 * a1[9] + 130 * a1[11])
s.add(eq1[7] == 41 * a1[12] + 71 * a1[7] + 185 * a1[1] + 69 * a1[11] + 142 * a1[8] + 221 * a1[5] + 24 * a1[3] + 208 *
a1[6] + 41 * a1[9] + 159 * a1[2] + 231 * a1[14] + 235 * a1[13] + 225 * a1[0] + (a1[4] * (64)) + 162 * a1[10] + 134 * a1[15])
s.add(eq1[11] == 36 * a1[12] + 220 * a1[4] + 110 * a1[13] + 45 * a1[7] + 123 * a1[9] + 133 * a1[1] + 101 * a1[5] +
137 * a1[10] + 102 * a1[0] + 227 * a1[14] + 94 * a1[15] + 18 * a1[2] + 22 * a1[6] + 189 * a1[11] + 218 * a1[8])
s.add(eq1[15] == 86 * a1[11] + 31 * a1[9] + 229 * a1[6] + 27 * a1[3] + 6 * a1[12] + 13 * a1[10] + 158 * a1[1] + 89 *
a1[7] + 35 * a1[15] + 126 * a1[8] + 165 * a1[13] + 220 * a1[0] + 138 * a1[5] + 100 * a1[4] + 84 * a1[14] + 175 * a1[2])
s.add(eq1[8] == 7 * a1[1] + 28 * a1[8] + 131 * a1[10] + 6 * a1[6] + 254 * a1[0] + 130 * a1[13] + 124 * a1[3] + 55 *
a1[12] + 157 * a1[14] + 175 * a1[5] + 140 * a1[4] + 241 * a1[9] + 11 * a1[11] + 211 * a1[2] + 121 * a1[7] + 200 * a1[15])
s.add(eq1[6] == 195 * a1[14] + 197 * a1[13] + 218 * a1[7] + 83 * a1[1] + 98 * a1[2] + 70 * a1[10] + 229 * a1[15] + 148 *
a1[11] + 195 * a1[0] + 94 * a1[6] + 211 * a1[12] + 220 * a1[9] + 81 * a1[5] + 253 * a1[8] + 78 * a1[4] + 4 * a1[3])
s.add(eq1[14] == 3 * a1[4] + 136 * a1[7] + 156 * a1[3] + 189 * a1[1] + 244 * a1[12] + 157 * a1[15] + 83 * a1[9] + 6 *
a1[0] + 113 * a1[6] + 63 * a1[14] + 35 * a1[2] + 22 * a1[8] + 26 * a1[10] + 62 * a1[11] + 98 * a1[5] + 110 * a1[13])
s.add(eq1[4] == 96 * a1[4] + 248 * a1[8] + 191 * a1[9] + 194 * a1[2] + 154 * a1[1] + 31 * a1[6] + 157 * a1[7] + 248 *
a1[13] + 81 * a1[15] + 56 * a1[10] + 52 * a1[0] + 94 * a1[12] + 212 * a1[5] + 83 * a1[3] + 83 * a1[14] + 158 * a1[11])
s.add(eq1[1] == 67 * a1[4] + 220 * a1[2] + 123 * a1[11] + 168 * a1[5] + 23 * a1[12] + 148 * a1[7] + 127 * a1[10] + 194 *
a1[1] + 132 * a1[8] + 44 * a1[0] + 60 * a1[13] + 98 * a1[15] + 38 * a1[14] + 245 * a1[9] + 159 * a1[6] + 146 * a1[3])
s.add(eq1[5] == 132 * a1[3] + 10 * a1[7] + 95 * a1[0] + 83 * a1[10] + 99 * a1[1] + 77 * a1[12] + 195 * a1[2] + 47 *
a1[6] + 38 * a1[13] + 178 * a1[8] + 74 * a1[4] + 86 * a1[11] + 208 * a1[9] + 240 * a1[14] + 120 * a1[5] + 43 * a1[15])
s.add(eq1[9] == 172 * a1[1] + 110 * a1[2] + 92 * a1[7] + 126 * a1[15] + 91 * a1[0] + 77 * a1[6] + 207 * a1[5] + 249 *
a1[11] + 240 * a1[12] + 129 * a1[10] + 6 * a1[13] + 100 * a1[3] + a1[14] + 76 * a1[9] + 127 * a1[4] + 4 * a1[8])
s.add(eq1[10] == 46 * a1[15] + 37 * a1[0] + 3 * a1[3] + 72 * a1[6] + 116 * a1[7] + 186 * a1[1] + 221 * a1[14] + 236 *
a1[4] + 79 * a1[2] + 175 * a1[10] + 184 * a1[9] + 160 * a1[11] + 227 * a1[12] + 99 * a1[8] + 71 * a1[13] + 4 * a1[5])
s.add(eq1[0] == 203 * a1[3] + 31 * a1[0] + 11 * a1[14] + 149 * a1[7] + 215 * a1[5] + 206 * a1[1] + 245 * a1[6] + 9 *
a1[11] + 16 * a1[10] + 241 * a1[13] + 110 * a1[8] + 175 * a1[2] + 38 * a1[4] + 227 * a1[9] + 208 * a1[12] + 8 * a1[15])
s.add(eq1[2] == 132 * a1[3] + 119 * a1[14] + 26 * a1[8] + 24 * a1[6] + 121 * a1[11] + 235 * a1[2] + 228 * a1[12] + 34 *
a1[5] + 37 * a1[15] + 24 * a1[9] + 145 * a1[13] + 199 * a1[4] + 173 * a1[10] + 58 * a1[0] + 246 * a1[7] + 199 * a1[1])

assert s.check() == z3.sat

m = s.model()
flag1 = [0] * 16
flag2 = [0] * 16

for i, v in enumerate(a1):
flag1[i] = m[v].as_long() & 0xff


s = z3.Solver()
a1 = [z3.Int(f'flag_{i}') for i in range(16)]
s.add(eq2[0] == 159 * a1[8] + 109 * a1[12] + 14 * a1[0] + 92 * a1[14] + 211 * a1[4] + 178 * a1[7] + 57 * a1[2] + 175 *
a1[5] + 170 * a1[11] + 59 * a1[6] + 200 * a1[9] + 5 * a1[15] + 48 * a1[13] + 28 * a1[3] + 18 * a1[10] + 228 * a1[1])
s.add(eq2[6] == 173 * a1[11] + 34 * a1[5] + 69 * a1[4] + 216 * a1[14] + 225 * a1[9] + 160 * a1[1] + 207 * a1[10] + 175 *
a1[7] + 121 * a1[0] + 122 * a1[2] + 179 * a1[12] + 91 * a1[13] + 181 * a1[8] + 93 * a1[3] + 121 * a1[6] + 12 * a1[15])
s.add(eq2[8] == 215 * a1[11] + 164 * a1[5] + 97 * a1[2] + 99 * a1[3] + 188 * a1[4] + (a1[9] * (128)) + 214 * a1[6] + 106 *
a1[8] + 169 * a1[0] + 28 * a1[14] + 18 * a1[12] + a1[1] + 177 * a1[10] + 114 * a1[7] + 176 * a1[15] + 25 * a1[13])
s.add(eq2[9] == 175 * a1[14] + 42 * a1[4] + 214 * a1[12] + 43 * a1[13] + 147 * a1[6] + 53 * a1[10] + 12 * a1[1] + 213 *
a1[7] + 241 * a1[9] + 223 * a1[5] + 65 * a1[3] + 42 * a1[15] + 131 * a1[2] + 81 * a1[0] + 92 * a1[11] + 110 * a1[8])
s.add(eq2[13] == 57 * a1[0] + 109 * a1[7] + 60 * a1[2] + 228 * a1[13] + 166 * a1[4] + 236 * a1[9] + 100 * a1[6] + 179 *
a1[11] + 20 * a1[12] + 45 * a1[8] + 204 * a1[3] + 182 * a1[14] + 84 * a1[10] + 170 * a1[15] + 199 * a1[5] + 138 * a1[1])
s.add(eq2[10] == 98 * a1[11] + 122 * a1[9] + 237 * a1[12] + 117 * a1[0] + 34 * a1[3] + 168 * a1[8] + 135 * a1[10] + 119 *
a1[6] + 91 * a1[2] + 161 * a1[15] + 152 * a1[7] + 186 * a1[4] + 187 * a1[13] + 72 * a1[14] + 36 * a1[5] + 171 * a1[1])
s.add(eq2[7] == 184 * a1[9] + 112 * a1[0] + 107 * a1[11] + 170 * a1[13] + 55 * a1[8] + 85 * a1[14] + 212 * a1[10] + 173 *
a1[15] + 166 * a1[12] + 142 * a1[4] + 202 * a1[5] + 63 * a1[2] + 30 * a1[7] + 175 * a1[3] + 217 * a1[6] + 63 * a1[1])
s.add(eq2[15] == (a1[7] * (64)) + 228 * a1[4] + 90 * a1[11] + 85 * a1[3] + 196 * a1[6] + 219 * a1[0] + 93 * a1[14] +
183 * a1[15] + 156 * a1[12] + 197 * a1[8] + 119 * a1[13] + 36 * a1[10] + 205 * a1[2] + 94 * a1[9] + 153 * a1[5])
s.add(eq2[5] == 9 * a1[4] + (a1[5] * (64)) + 62 * a1[1] + 58 * a1[7] + 100 * a1[13] + 137 * a1[11] + 6 * a1[0] + 119 *
a1[9] + 180 * a1[6] + 228 * a1[8] + 88 * a1[12] + 107 * a1[15] + 56 * a1[14] + 207 * a1[2] + 248 * a1[10] + 150 * a1[3])
s.add(eq2[3] == 38 * a1[7] + 194 * a1[4] + 105 * a1[0] + 150 * a1[6] + 75 * a1[1] + 89 * a1[15] + 99 * a1[14] + 98 *
a1[3] + 91 * a1[8] + 178 * a1[12] + 117 * a1[2] + 48 * a1[13] + 239 * a1[10] + 233 * a1[11] + 63 * a1[5] + 250 * a1[9])
s.add(eq2[11] == 30 * a1[8] + 13 * a1[5] + 206 * a1[3] + 234 * a1[15] + 71 * a1[7] + 239 * a1[12] + 141 * a1[10] + 179 *
a1[13] + 113 * a1[14] + 181 * a1[9] + 52 * a1[6] + 74 * a1[11] + 168 * a1[4] + 239 * a1[1] + 164 * a1[0] + 179 * a1[2])
s.add(eq2[14] == 211 * a1[1] + 74 * a1[5] + 144 * a1[8] + 234 * a1[0] + 241 * a1[2] + 157 * a1[11] + 25 * a1[15] + 6 *
a1[10] + 243 * a1[6] + 107 * a1[9] + 77 * a1[12] + 127 * a1[4] + 67 * a1[7] + 13 * a1[14] + 151 * a1[3] + 127 * a1[13])
s.add(eq2[2] == 209 * a1[9] + 110 * a1[7] + 22 * a1[10] + 102 * a1[11] + 187 * a1[1] + 58 * a1[8] + 236 * a1[6] + 146 *
a1[13] + 205 * a1[15] + 63 * a1[2] + 211 * a1[4] + 152 * a1[3] + 82 * a1[14] + 14 * a1[5] + 49 * a1[12] + 251 * a1[0])
s.add(eq2[12] == 230 * a1[0] + 27 * a1[3] + 186 * a1[10] + 58 * a1[7] + 121 * a1[1] + 59 * a1[14] + 90 * a1[12] + 40 *
a1[2] + 230 * a1[11] + 25 * a1[6] + 198 * a1[5] + 81 * a1[4] + 71 * a1[13] + 180 * a1[8] + 149 * a1[9] + 73 * a1[15])
s.add(eq2[4] == 188 * a1[5] + 80 * a1[1] + 221 * a1[6] + (a1[12] * (64)) + 230 * a1[3] + 123 * a1[8] + 124 * a1[11] + 253 *
a1[0] + 202 * a1[10] + 63 * a1[2] + 40 * a1[7] + 109 * a1[9] + 195 * a1[15] + 199 * a1[13] + 82 * a1[4] + 225 * a1[14])
s.add(eq2[1] == 236 * a1[15] + 44 * a1[14] + 214 * a1[13] + 52 * a1[8] + 37 * a1[6] + 101 * a1[9] + 244 * a1[10] + 238 *
a1[11] + 109 * a1[0] + 188 * a1[1] + 20 * a1[3] + 87 * a1[7] + 93 * a1[4] + 158 * a1[5] + 105 * a1[12] + 3 * a1[2])

assert s.check() == z3.sat

m = s.model()

for i, v in enumerate(a1):
flag2[i] = m[v].as_long() & 0xff



box_order = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29][::-1]
box = [None] * 30

box[2] = [
0x7A, 0x91, 0x9F, 0x23, 0x71, 0xD1, 0x63, 0xDB, 0x59, 0x0A,
0xEC, 0x69, 0xEE, 0x76, 0x5D, 0x64, 0x37, 0x42, 0x8C, 0x0B,
0x3C, 0x5C, 0x80, 0xAD, 0x6A, 0x03, 0x43, 0x93, 0xBC, 0xBF,
0xE3, 0xAF, 0x5A, 0x8A, 0x65, 0x0D, 0x31, 0xDF, 0x3E, 0xA7,
0xE4, 0xDD, 0xB4, 0xB0, 0x56, 0x1C, 0x12, 0xA4, 0x9E, 0xD8,
0x3D, 0x81, 0x60, 0x9A, 0xCB, 0xFA, 0xB1, 0xE0, 0xD3, 0xF4,
0xA2, 0x26, 0x68, 0x90, 0x4B, 0x45, 0x85, 0x20, 0x16, 0xDE,
0xED, 0x4C, 0x6F, 0x34, 0xDC, 0xBE, 0xD2, 0x46, 0x33, 0x14,
0x77, 0xC6, 0xCD, 0xF0, 0xC5, 0xAC, 0x1F, 0xD0, 0x95, 0x97,
0x3F, 0xD7, 0x52, 0xAE, 0xB9, 0xC9, 0x0C, 0xCA, 0x4E, 0xF1,
0xB7, 0x39, 0x7F, 0x27, 0x2B, 0x40, 0x4A, 0x51, 0xA1, 0xCC,
0xCE, 0x6E, 0x70, 0xFF, 0x0E, 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xB5, 0xD9, 0x92, 0xDE, 0x0D, 0xE3,
0xF3, 0xA4, 0xBD, 0x6F, 0xD3, 0x25, 0x88, 0x71, 0xFF, 0xA9,
0x36, 0xB1, 0x78, 0x24, 0x69, 0xAD, 0x19, 0xBF, 0xFD, 0xCD,
0x4A, 0xEA, 0x87, 0x91, 0xA8, 0x66, 0x82, 0x50, 0x0F, 0x99,
0x45, 0xF2, 0xD5, 0x9B, 0x94, 0x7D, 0xCE, 0xDB, 0xB9, 0x52,
0xE5, 0xF4, 0x01, 0x7F, 0xD4, 0x15, 0x2D, 0x3F, 0x1D, 0xA7,
0xC2, 0xFA, 0x40, 0xE8, 0xA0, 0x55, 0x6C, 0xF7, 0x1B, 0x58,
0x85, 0x56, 0x9E, 0xEC, 0x97, 0x23, 0xF0, 0x4D, 0xD0, 0xF8,
0x2A, 0x49, 0xB4, 0x76, 0x54, 0xDF
]

for i in range(len(box_order)):
b = box[box_order[i]]
for j, v in enumerate(flag1):
flag1[j] = b.index(v)

for i in range(len(box_order)):
b = box[box_order[i]]
for j, v in enumerate(flag2):
flag2[j] = b.index(v)

print(''.join(map(chr, flag1)), end='')
print(''.join(map(chr, flag2)))