2019暑假任务———Encoder

Encoder

程序主要功能

将输入的文件进行特殊的加密后输出

主要步奏

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
signed __int64 __fastcall sub_402C77(const char *input)
{
char *v1; // rax
signed int i; // [rsp+18h] [rbp-1108h]
FILE *read_stream; // [rsp+20h] [rbp-1100h]
FILE *write_stream; // [rsp+28h] [rbp-10F8h]
char v6; // [rsp+30h] [rbp-10F0h]
char v7[16]; // [rsp+10D0h] [rbp-50h]
char s; // [rsp+10E0h] [rbp-40h]
__int64 v9; // [rsp+1100h] [rbp-20h]
__int64 v10; // [rsp+1108h] [rbp-18h]
char v11; // [rsp+1110h] [rbp-10h]
unsigned __int64 v12; // [rsp+1118h] [rbp-8h]

v12 = __readfsqword(0x28u);
memset(&s, 0, 0x11uLL);
v9 = 'kaf{galf'; // flag{fake_flag!}
v10 = '}!galf_e';
v11 = 0;
sub_4015F2();
sub_401611(&v9, 16, &v6);
read_stream = fopen(input, "rb+");
if ( !read_stream )
return 0xFFFFFFFFLL;
v1 = &input[strlen(input)];
*v1 = 'tpyrcne_';
*(v1 + 4) = 'de';
v1[10] = 0; // _encrypted
write_stream = fopen(input, "wb+");
if ( !write_stream )
return 0LL;
while ( sub_402C00(&s, 17, read_stream) ) // 读入16字符到s
{
encrypt(&v6, &s, v7);
for ( i = 0; i <= 15; ++i )
fputc(v7[i], write_stream);
}
fclose(read_stream);
fclose(write_stream);
return 1LL;
}

主要是由encrypt函数完成加密过程,可以看到函数传入一个加密使用的表

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
signed __int64 __fastcall sub_40190B(_DWORD *a1, unsigned __int16 *a2, __int64 a3)
{
unsigned int v3; // ST20_4
unsigned int v4; // ST24_4
int v5; // ST30_4
int v6; // ST34_4
unsigned int v7; // ST28_4
unsigned int v8; // ST2C_4
int v9; // ST30_4
int v10; // ST34_4
unsigned int v11; // ST20_4
unsigned int v12; // ST24_4
int v13; // ST30_4
int v14; // ST34_4
unsigned int v15; // ST28_4
unsigned int v16; // ST2C_4
int v17; // ST30_4
int v18; // ST34_4
unsigned int v19; // ST20_4
unsigned int v20; // ST24_4
int v21; // ST30_4
int v22; // ST34_4
unsigned int v23; // ST28_4
unsigned int v24; // ST2C_4
int v25; // ST30_4
int v26; // ST34_4
unsigned int v27; // ST20_4
unsigned int v28; // ST24_4
int v29; // ST30_4
int v30; // ST34_4
unsigned int v31; // ST28_4
unsigned int v32; // ST2C_4
int v33; // ST30_4
int v34; // ST34_4
unsigned int v35; // ST20_4
unsigned int v36; // ST24_4
int v37; // ST30_4
int v38; // ST34_4
unsigned int v39; // ST28_4
unsigned int v40; // ST2C_4
int v41; // ST30_4
int v42; // ST34_4
unsigned int v43; // ST20_4
unsigned int v44; // ST24_4
int v45; // ST30_4
int v46; // ST34_4
unsigned int v47; // ST28_4
unsigned int v48; // ST2C_4
int v49; // ST30_4
int v50; // ST34_4
unsigned int v51; // ST20_4
unsigned int v52; // ST24_4
int v53; // ST30_4
int v54; // ST34_4
unsigned int v55; // ST28_4
unsigned int v56; // ST2C_4
int v57; // ST30_4
int v58; // ST34_4
unsigned int v59; // ST20_4
unsigned int v60; // ST24_4
int v61; // ST30_4
int v62; // ST34_4
unsigned int v63; // ST28_4
unsigned int v64; // ST2C_4
int v65; // ST30_4
int v66; // ST34_4
int v67; // ST28_4
int v68; // ST2C_4
int v69; // ST20_4
int v70; // ST24_4
signed __int64 result; // rax

v3 = ((*(a2 + 3) << 24) | (*(a2 + 2) << 16) | *a2) ^ a1[1024];
v4 = ((*(a2 + 7) << 24) | (*(a2 + 6) << 16) | a2[2]) ^ a1[1025];
v5 = a1[BYTE1(v3) + 512LL] ^ a1[BYTE2(v3) + 256LL] ^ a1[v3 >> 24] ^ a1[v3 + 768LL];
v6 = a1[BYTE2(v4) + 512LL] ^ a1[(v4 >> 24) + 256LL] ^ a1[v4] ^ a1[BYTE1(v4) + 768LL];
v7 = __ROR4__((v6 + v5 + a1[1032]) ^ ((*(a2 + 11) << 24) | (*(a2 + 10) << 16) | a2[4]) ^ a1[1026], 1);
v8 = (v5 + 2 * v6 + a1[1033]) ^ __ROL4__(((*(a2 + 15) << 24) | (*(a2 + 14) << 16) | a2[6]) ^ a1[1027], 1);
v9 = a1[BYTE1(v7) + 512LL] ^ a1[BYTE2(v7) + 256LL] ^ a1[v7 >> 24] ^ a1[v7 + 768LL];
v10 = a1[BYTE2(v8) + 512LL] ^ a1[(v8 >> 24) + 256LL] ^ a1[v8] ^ a1[BYTE1(v8) + 768LL];
v11 = __ROR4__((v10 + v9 + a1[1034]) ^ v3, 1);
v12 = (v9 + 2 * v10 + a1[1035]) ^ __ROL4__(v4, 1);
v13 = a1[BYTE1(v11) + 512LL] ^ a1[BYTE2(v11) + 256LL] ^ a1[v11 >> 24] ^ a1[v11 + 768LL];
v14 = a1[BYTE2(v12) + 512LL] ^ a1[(v12 >> 24) + 256LL] ^ a1[v12] ^ a1[BYTE1(v12) + 768LL];
v15 = __ROR4__((v14 + v13 + a1[1036]) ^ v7, 1);
v16 = (v13 + 2 * v14 + a1[1037]) ^ __ROL4__(v8, 1);
v17 = a1[BYTE1(v15) + 512LL] ^ a1[BYTE2(v15) + 256LL] ^ a1[v15 >> 24] ^ a1[v15 + 768LL];
v18 = a1[BYTE2(v16) + 512LL] ^ a1[(v16 >> 24) + 256LL] ^ a1[v16] ^ a1[BYTE1(v16) + 768LL];
v19 = __ROR4__((v18 + v17 + a1[1038]) ^ v11, 1);
v20 = (v17 + 2 * v18 + a1[1039]) ^ __ROL4__(v12, 1);
v21 = a1[BYTE1(v19) + 512LL] ^ a1[BYTE2(v19) + 256LL] ^ a1[v19 >> 24] ^ a1[v19 + 768LL];
v22 = a1[BYTE2(v20) + 512LL] ^ a1[(v20 >> 24) + 256LL] ^ a1[v20] ^ a1[BYTE1(v20) + 768LL];
v23 = __ROR4__((v22 + v21 + a1[1040]) ^ v15, 1);
v24 = (v21 + 2 * v22 + a1[1041]) ^ __ROL4__(v16, 1);
v25 = a1[BYTE1(v23) + 512LL] ^ a1[BYTE2(v23) + 256LL] ^ a1[v23 >> 24] ^ a1[v23 + 768LL];
v26 = a1[BYTE2(v24) + 512LL] ^ a1[(v24 >> 24) + 256LL] ^ a1[v24] ^ a1[BYTE1(v24) + 768LL];
v27 = __ROR4__((v26 + v25 + a1[1042]) ^ v19, 1);
v28 = (v25 + 2 * v26 + a1[1043]) ^ __ROL4__(v20, 1);
v29 = a1[BYTE1(v27) + 512LL] ^ a1[BYTE2(v27) + 256LL] ^ a1[v27 >> 24] ^ a1[v27 + 768LL];
v30 = a1[BYTE2(v28) + 512LL] ^ a1[(v28 >> 24) + 256LL] ^ a1[v28] ^ a1[BYTE1(v28) + 768LL];
v31 = __ROR4__((v30 + v29 + a1[1044]) ^ v23, 1);
v32 = (v29 + 2 * v30 + a1[1045]) ^ __ROL4__(v24, 1);
v33 = a1[BYTE1(v31) + 512LL] ^ a1[BYTE2(v31) + 256LL] ^ a1[v31 >> 24] ^ a1[v31 + 768LL];
v34 = a1[BYTE2(v32) + 512LL] ^ a1[(v32 >> 24) + 256LL] ^ a1[v32] ^ a1[BYTE1(v32) + 768LL];
v35 = __ROR4__((v34 + v33 + a1[1046]) ^ v27, 1);
v36 = (v33 + 2 * v34 + a1[1047]) ^ __ROL4__(v28, 1);
v37 = a1[BYTE1(v35) + 512LL] ^ a1[BYTE2(v35) + 256LL] ^ a1[v35 >> 24] ^ a1[v35 + 768LL];
v38 = a1[BYTE2(v36) + 512LL] ^ a1[(v36 >> 24) + 256LL] ^ a1[v36] ^ a1[BYTE1(v36) + 768LL];
v39 = __ROR4__((v38 + v37 + a1[1048]) ^ v31, 1);
v40 = (v37 + 2 * v38 + a1[1049]) ^ __ROL4__(v32, 1);
v41 = a1[BYTE1(v39) + 512LL] ^ a1[BYTE2(v39) + 256LL] ^ a1[v39 >> 24] ^ a1[v39 + 768LL];
v42 = a1[BYTE2(v40) + 512LL] ^ a1[(v40 >> 24) + 256LL] ^ a1[v40] ^ a1[BYTE1(v40) + 768LL];
v43 = __ROR4__((v42 + v41 + a1[1050]) ^ v35, 1);
v44 = (v41 + 2 * v42 + a1[1051]) ^ __ROL4__(v36, 1);
v45 = a1[BYTE1(v43) + 512LL] ^ a1[BYTE2(v43) + 256LL] ^ a1[v43 >> 24] ^ a1[v43 + 768LL];
v46 = a1[BYTE2(v44) + 512LL] ^ a1[(v44 >> 24) + 256LL] ^ a1[v44] ^ a1[BYTE1(v44) + 768LL];
v47 = __ROR4__((v46 + v45 + a1[1052]) ^ v39, 1);
v48 = (v45 + 2 * v46 + a1[1053]) ^ __ROL4__(v40, 1);
v49 = a1[BYTE1(v47) + 512LL] ^ a1[BYTE2(v47) + 256LL] ^ a1[v47 >> 24] ^ a1[v47 + 768LL];
v50 = a1[BYTE2(v48) + 512LL] ^ a1[(v48 >> 24) + 256LL] ^ a1[v48] ^ a1[BYTE1(v48) + 768LL];
v51 = __ROR4__((v50 + v49 + a1[1054]) ^ v43, 1);
v52 = (v49 + 2 * v50 + a1[1055]) ^ __ROL4__(v44, 1);
v53 = a1[BYTE1(v51) + 512LL] ^ a1[BYTE2(v51) + 256LL] ^ a1[v51 >> 24] ^ a1[v51 + 768LL];
v54 = a1[BYTE2(v52) + 512LL] ^ a1[(v52 >> 24) + 256LL] ^ a1[v52] ^ a1[BYTE1(v52) + 768LL];
v55 = __ROR4__((v54 + v53 + a1[1056]) ^ v47, 1);
v56 = (v53 + 2 * v54 + a1[1057]) ^ __ROL4__(v48, 1);
v57 = a1[BYTE1(v55) + 512LL] ^ a1[BYTE2(v55) + 256LL] ^ a1[v55 >> 24] ^ a1[v55 + 768LL];
v58 = a1[BYTE2(v56) + 512LL] ^ a1[(v56 >> 24) + 256LL] ^ a1[v56] ^ a1[BYTE1(v56) + 768LL];
v59 = __ROR4__((v58 + v57 + a1[1058]) ^ v51, 1);
v60 = (v57 + 2 * v58 + a1[1059]) ^ __ROL4__(v52, 1);
v61 = a1[BYTE1(v59) + 512LL] ^ a1[BYTE2(v59) + 256LL] ^ a1[v59 >> 24] ^ a1[v59 + 768LL];
v62 = a1[BYTE2(v60) + 512LL] ^ a1[(v60 >> 24) + 256LL] ^ a1[v60] ^ a1[BYTE1(v60) + 768LL];
v63 = __ROR4__((v62 + v61 + a1[1060]) ^ v55, 1);
v64 = (v61 + 2 * v62 + a1[1061]) ^ __ROL4__(v56, 1);
v65 = a1[BYTE1(v63) + 512LL] ^ a1[BYTE2(v63) + 256LL] ^ a1[v63 >> 24] ^ a1[v63 + 768LL];
v66 = a1[BYTE2(v64) + 512LL] ^ a1[(v64 >> 24) + 256LL] ^ a1[v64] ^ a1[BYTE1(v64) + 768LL];
v67 = a1[1028] ^ v63;
v68 = a1[1029] ^ v64;
v69 = a1[1030] ^ __ROR4__((v66 + v65 + a1[1062]) ^ v59, 1);
v70 = a1[1031] ^ (v65 + 2 * v66 + a1[1063]) ^ __ROL4__(v60, 1);
*a3 = v67;
*(a3 + 1) = *(&v67 + 1);
*(a3 + 3) = HIBYTE(v67);
*(a3 + 4) = v68;
*(a3 + 8) = v69;
*(a3 + 12) = v70;
*(a3 + 14) = BYTE2(v70);
result = a3 + 15;
*(a3 + 15) = HIBYTE(v70);
return result;
}

只需要下断点然后将表dump出来就可以了

1
2
3
4
5
6
7
fp = open("C:\\Users\\0xEASONs\\Desktop\\byte.txt", "w")
add = 0x7FFE5D82BCC0

for i in range(1068):
fp.write("%s, "%(Dword(add+i*4)))
fp.close()
print("done")

然后直接逆加密函数就可以了

程序逻辑

ida 翻译的加密函数的伪代码有问题,看汇编可以看出来,正确的代码如下

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
v3 = (input[0]|input[1]<<8|input[2]<<16|input[3]<<24)^table[1024];
v4 = (input[4]|input[5]<<8|input[6]<<16|input[7]<<24)^table[1025];
v7 = (input[8]|input[9]<<8|input[10]<<16|input[11]<<24)^table[1026];
v8 = (input[12]|input[13]<<8|input[14]<<16|input[15]<<24)^table[1027];

/**********************************************************************************/
v5 = table[BYTE3(v3)]^table[BYTE2(v3)+256]^table[BYTE1(v3)+512]^table[BYTE0(v3)+768];
v6 = table[BYTE0(v4)]^table[BYTE3(v4)+256]^table[BYTE2(v4)+512]^table[BYTE1(v4)+768];
v7 ^= (table[1032]+v5+v6);
ROR(v7,1);
ROL(v8,1);
v8 ^= (table[1033]+2*v6+v5);

v5 = table[BYTE3(v7)]^table[BYTE2(v7)+256]^table[BYTE1(v7)+512]^table[BYTE0(v7)+768];
v6 = table[BYTE0(v8)]^table[BYTE3(v8)+256]^table[BYTE2(v8)+512]^table[BYTE1(v7)+768];
v3 ^= (table[1034]+v5+v6);
ROR(v3,1);
ROL(v4,1);
v4 ^= (table[1035]+2*v6+v5);
/***********************************************************************************/

/***********************************************************************************/
v5 = table[BYTE3(v3)]^table[BYTE2(v3)+256]^table[BYTE1(v3)+512]^table[BYTE0(v3)+768];
v6 = table[BYTE0(v4)]^table[BYTE3(v4)+256]^table[BYTE2(v4)+512]^table[BYTE1(v4)+768];
v7 ^= (table[1036]+v5+v6);
ROR(v7,1);
ROL(v8,1);
v8 ^= (table[1037]+2*v6+v5);

v5 = table[BYTE3(v7)]^table[BYTE2(v7)+256]^table[BYTE1(v7)+512]^table[BYTE0(v7)+768];
v6 = table[BYTE0(v8)]^table[BYTE3(v8)+256]^table[BYTE2(v8)+512]^table[BYTE1(v7)+768];
v3 ^= (table[1038]+v5+v6);
ROR(v3,1);
ROL(v4,1);
v4 ^= (table[1039]+2*v6+v5);
/**********************************************************************************/

/****table[1040]~table[1063]*******/

v7 ^= table[1028];
v8 ^= table[1029];
v3 ^= table[1030];
v4 ^= table[1031];

dest[0] = v7;
dest[1] = v8;
dest[2] = v3;
dest[3] = v4;

用C写程序验证

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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

unsigned int ROL(unsigned int *i)
{
*i = *i<<1|(*i>>31);
return *i;
}

unsigned int ROR(unsigned int *i)
{
*i = *i>>1|((*i&1)<<31);
return *i;
}

unsigned int BYTE0(unsigned int i)
{
return i&0xff;
}

unsigned int BYTE1(unsigned int i)
{
return (i>>8)&0xff;
}

unsigned int BYTE2(unsigned int i)
{
return (i>>16)&0xff;
}

unsigned int BYTE3(unsigned int i)
{
return (i>>24)&0xff;
}

unsigned int table[] = {380087468, 1203253039, 2922473062, 2314273025, 2584233285, 4254618194, 895667404, 1071543669, 1459084508, 1966259388, 1337073953, 2472125604, 65886296, 3096890058, 1030275778, 3798867743, 4201647373, 2942994825, 4013619705, 1737496343, 3077872539, 67438343, 2808121223, 3985395278, 1146451831, 3973554593, 3474112961, 4120009820, 3122691453, 1403597876, 536235341, 2292903662, 3304429463, 180140473, 2760761311, 1764338089, 4106859443, 1548445029, 3730649650, 199710294, 45529015, 3056563316, 4079086828, 1994384612, 3999340054, 714375553, 3273509064, 1872369945, 247054014, 3571551115, 4187837781, 1670713360, 1427801220, 3117229349, 3316545656, 132669279, 2384027230, 915379348, 424017405, 3878746103, 3212744085, 3371867806, 781289094, 1323945678, 876159779, 4173773498, 2100867762, 943073834, 2248017928, 4039947444, 1136470056, 1346661484, 3393988905, 3029976003, 3918088521, 3607942099, 3504639116, 90106088, 828885963, 1819754817, 404623890, 1158584472, 4146392043, 3741769181, 2648709658, 3145437842, 3460902446, 3049401388, 1526257109, 1292146326, 490797818, 3450107510, 1805590046, 2158026976, 2381579782, 3652545901, 2517060684, 2515145748, 2788911208, 1391647707, 1685933903, 2449623883, 335103044, 3585762404, 2605951658, 3839733679, 3326287904, 312650667, 2673257901, 3010567324, 3184009762, 2741338240, 1831644846, 606945087, 809247780, 3528604475, 1858205430, 2180714255, 2855559521, 336665371, 1009986861, 1657733119, 2182502231, 2849585465, 290452467, 981507485, 2539430819, 1886147668, 2782277680, 1604730173, 1224839569, 0, 1481532002, 1953059667, 2629563893, 735014510, 3811963120, 2360338921, 1926947811, 936672123, 2714974007, 2202908856, 1937837068, 471536917, 695851481, 2894582225, 3663213877, 1697030304, 1561365130, 1257032137, 2827146966, 1593692882, 3719326314, 3163803085, 269753372, 2982619947, 1270294054, 673330742, 1048943258, 3190127226, 2249412688, 112439472, 628543696, 3946839806, 2403512753, 3906119334, 2963064004, 266490193, 1281325433, 1899477947, 1618495560, 763158238, 4068082435, 1079013488, 22802415, 202311945, 2140013829, 580816783, 847942547, 2005142283, 4240686525, 402408259, 3596041276, 3850780736, 2060512749, 1629726631, 3706422661, 869366908, 801794409, 4213957346, 561240023, 2019973722, 156361185, 223667942, 2494692347, 447260069, 740766001, 2317113689, 647727240, 3932426513, 2127948522, 468929098, 1004237426, 514695842, 2722000751, 4053228379, 1122420679, 1413573483, 1724643576, 2427780348, 4281263589, 1791291889, 3259377447, 2693322968, 3382800753, 3439303065, 2086886749, 1494584717, 3865778200, 963495365, 600137824, 2225465319, 2876214926, 3783477063, 1470903091, 2989126515, 2336732854, 4269083146, 539506744, 3407333062, 2916892222, 1361019779, 3772295336, 4135519236, 2034087349, 357233908, 1752319558, 2581929245, 2072707586, 3340292047, 1189331136, 1213890174, 2562650866, 3639509634, 1091280799, 2651669058, 3236991120, 134876686, 3674462938, 666920807, 1537423930, 3540636884, 2269691839, 3249241983, 2448364307, 3518980963, 2610656439, 825304876, 3065399179, 2492763958, 2004309316, 690572490, 2122209864, 3991785594, 1145370899, 1499012234, 2374833497, 3840204662, 117900548, 2644344890, 3267520573, 640071499, 421108335, 3048553849, 2795950824, 2358043856, 3722249951, 1347425158, 84250239, 1734852647, 218984698, 3604382376, 3941258622, 2913818271, 1397975412, 2105352378, 1768540719, 1970658879, 370565614, 3688624722, 3503322661, 4278075371, 2560101957, 3183330300, 3486456007, 3216984199, 2728570142, 67403766, 589510964, 1246425883, 2459073467, 269522275, 2745392279, 2762234259, 606354480, 4160172263, 1313770733, 134807173, 1616954659, 1027450463, 1566401404, 1785376989, 1633760426, 1936927410, 3823360626, 724289457, 960092585, 3890718084, 2442199369, 943204384, 3166450293, 3452801980, 4261233945, 1448535819, 4193860335, 2998024317, 1701137244, 2408554018, 1229556201, 1532729329, 1381144829, 741130933, 2256965934, 3402274488, 185304183, 2088554803, 842161630, 993743570, 4210704413, 1549570805, 0, 1600120839, 3419105073, 3621221153, 707409464, 2021174981, 3435946549, 1819034704, 2880152082, 1094809452, 976921435, 3806473211, 3705468758, 909517352, 2054825406, 1650609752, 4092808977, 4008618632, 2139073473, 3233866566, 252705665, 2627498419, 404253670, 1920129851, 1667481553, 1515873912, 2896996118, 926405537, 3031747824, 2711738348, 454758676, 3907542533, 774785486, 2324303965, 2307484335, 1162152090, 1263207058, 3537042782, 2037997388, 2425417920, 33721211, 101119117, 50559730, 2206408529, 505323371, 2577006540, 3149608817, 3351766594, 320073617, 2543318468, 859024471, 2155898275, 2947538404, 2678000449, 1802191188, 16904585, 2189618904, 2341200340, 303177240, 892688602, 4059153514, 235801096, 437969053, 2779097114, 2071712823, 1077970661, 2930650221, 4042274275, 3334870987, 1431674361, 3772817536, 3250655951, 2509602495, 353704732, 1364320783, 2863289243, 2829637856, 2391699371, 2526413901, 3587569754, 4244419728, 1835906521, 3755969956, 3739122733, 1010587606, 2593817918, 2812748641, 151588620, 3553823959, 656885442, 1465325186, 623234489, 387420263, 1717973422, 1212708960, 3099086211, 1044307117, 202146163, 3132802808, 2981184143, 3115957258, 1414818928, 1111625118, 555856463, 2172752938, 3789639945, 2223250005, 4109650453, 3082270210, 3924406156, 3014904308, 1886408768, 3958056183, 3654908201, 4126522268, 2475919922, 1482222851, 4025441025, 757936956, 1195869153, 4143366510, 4294954594, 1684323029, 168457726, 1987486925, 3469666638, 2290653990, 471602192, 1179021928, 1280051094, 4227576212, 2273796263, 1330609508, 808507045, 3200170254, 1953771446, 791656519, 1583225230, 1061104932, 3385453642, 3520169900, 3638069408, 3974898163, 3873854477, 673758531, 1852755755, 488498585, 336915093, 522153698, 572704957, 2846435689, 1751661478, 4177054566, 3318050105, 875866451, 3284375988, 538985414, 2964370182, 4075994776, 3368558019, 1296954911, 3671720923, 1903272393, 3857002239, 3570665939, 3301219504, 2661219016, 1869561506, 1128528919, 2240146396, 2694850149, 286352618, 3821029091, 1619502944, 3834433764, 796177967, 1349533776, 4288269567, 76958980, 3644434905, 2195105922, 1479924312, 1518225498, 2959793584, 1796793963, 2539385239, 2708588961, 3480103887, 3927217642, 3072740279, 1906094961, 3981968365, 3922611945, 4132249590, 3472843470, 821552944, 2609391259, 828812849, 545110560, 1757560168, 908736566, 2441490065, 1841641837, 1702929253, 3311412165, 2455565714, 4094070260, 1667071075, 3090106296, 951221560, 2382725006, 2252400006, 2829392552, 416270104, 2986054833, 2838778793, 674766888, 3534153938, 3257710018, 3672339162, 2927150510, 3681696731, 3043875253, 4001552622, 989458234, 1601784927, 2729120418, 1118932802, 851211570, 2241478277, 4158412535, 786825006, 1433879637, 2044275065, 2278665351, 2699067552, 2479733907, 3173532605, 1592264030, 2529867926, 168691722, 3422054091, 2202526083, 4212097531, 759112749, 1097552961, 4181988345, 4081720307, 1787408234, 1542390107, 2102355069, 4036018416, 1554224988, 3384014025, 374833686, 657533991, 1341329743, 935031095, 4258422525, 2131031679, 1717205094, 3357720008, 3210990015, 3514577873, 244860174, 1657550178, 337383444, 1628892769, 2889045932, 648045862, 3843922405, 1373702481, 1009004604, 215209740, 398904087, 1090133312, 1817473132, 712225322, 3617713367, 1741369703, 2500879253, 3127170490, 1220511560, 1177010758, 2047079034, 64674563, 1879964272, 4174732024, 2073213819, 2215344004, 1463604823, 2000776311, 277503248, 3634946264, 1264933963, 1379652178, 3564845012, 4011037167, 2738510755, 996714043, 3784037601, 958608441, 1174214981, 619444004, 2867759274, 252251151, 3166243516, 3588914901, 1678895716, 3284008131, 1503957849, 454368283, 3719292125, 749628716, 2669570975, 314691346, 26298625, 84345861, 1073670975, 1917216882, 3065447094, 2660180638, 2324902538, 628801061, 1956362100, 164942601, 3881176039, 1303937869, 2295898248, 2165076865, 38507010, 3341529543, 3972614892, 4120364277, 2417452944, 858602547, 3695095260, 1227804233, 475630108, 1563614813, 3434410188, 1424362836, 361584917, 3254152897, 138779144, 2094935420, 2579739801, 3441801677, 4043409905, 504502302, 4204710138, 1403689811, 2491493012, 2303322505, 528699679, 2380244109, 4074459890, 3014657715, 3756291807, 3227985856, 3593512406, 2555575704, 324044307, 3153435835, 736295723, 573974562, 1047503422, 3898542056, 3759840736, 878815796, 2639657373, 286987281, 1035303229, 2018009208, 2157787776, 1126221379, 425627161, 2789040038, 0, 3871818470, 1993352566, 1871620975, 2913083053, 122459655, 2408855183, 904979253, 3334142150, 1203145543, 3732226014, 2877276587, 3505224400, 194986251, 3543638483, 3796963298, 1315067982, 499696413, 1257510218, 1147949124, 3304155844, 2585358234, 115203846, 2988527538, 2759249316, 2332195723, 2813073063, 3036450996, 4261971454, 2951318703, 1767076969, 3951418603, 1943478643, 3116240569, 3395891146, 2783413413, 2630135964, 569176865, 598171939, 222469645, 2123743102, 698968361, 1963654773, 1847583342, 1454219094, 1277807180, 2353982860, 3203569854, 444880154, 4232255484, 1324174988, 426711450, 3095640141, 2059303461, 1142113529, 2345962465, 2109373728, 3517763975, 1392333464, 3832997087, 3671841283, 1517836902, 4009881435, 2744623964, 2769986984, 109905652, 2275903328, 1267878658, 117704453, 3815957466, 260116475, 3251618066, 2842274089, 1542544279, 642459319, 1167738120, 2167046548, 4001951402, 2486604943, 2800264914, 2512360830, 4095079498, 1059340077, 3696680183, 4167497931, 2554697742, 3308897645, 25756145, 3752124301, 2953228467, 2546243573, 235408906, 2393607791, 1817209924, 534912878, 3225862371, 3975408673, 1649959502, 1442403741, 510336671, 4041470005, 3727548028, 3643398521, 1872916286, 2761139289, 2067233748, 853422685, 2637864320, 4050317764, 417732715, 3104487868, 1029651878, 354161947, 861352876, 3679640562, 184420981, 2195227374, 446503648, 4070109886, 2870127522, 3485978392, 2309982570, 3554136844, 3570652169, 4220844977, 1764714954, 41616011, 1958114351, 3884246949, 3070408630, 1848340175, 1020673111, 1205946243, 2143387563, 0, 2612501364, 1612931269, 3409038183, 83231871, 1638555956, 3492139126, 3426077794, 303567390, 2158198885, 1700554059, 2401406878, 4120704443, 3299919004, 1842965941, 1359958498, 151783695, 4237360308, 1993176740, 300552548, 2912922966, 2437517569, 2428539120, 2663948026, 328274927, 3401108118, 908604962, 750070978, 1909027233, 1568431459, 1117667853, 3766542496, 3858752814, 675489981, 824979751, 2887167143, 1916498651, 4284678094, 3062609479, 1088766086, 3377121772, 3579500024, 1443583719, 1284918279, 1755736123, 3461271273, 1594318824, 2118680154, 2321386000, 3609319283, 1293897206, 816132310, 632890829, 3451702675, 3808158251, 2978984258, 2284226715, 758918451, 1051541212, 2000975701, 1941074730, 1586388505, 1559583890, 3136862918, 1400132457, 234491248, 3958893348, 2862328403, 496573925, 1730635712, 2521667076, 3144792887, 2220196890, 2026207406, 558834098, 1792895664, 3634419848, 2994582072, 3335243287, 345314538, 2629016689, 733031367, 2833295576, 3187457475, 192351108, 979057315, 2808194851, 2580322815, 2587794053, 2719916717, 1181238898, 4246338885, 1476614381, 2362477796, 208866433, 4196268608, 1214269560, 3934186197, 3918326191, 607134780, 2716639703, 92210574, 3035673804, 3019158473, 1331974013, 1800694593, 3859670612, 3213344584, 582820552, 4078039887, 2469565322, 1240025481, 1097613687, 1350979603, 2461766267, 142936318, 590619449, 1502239004, 2951000029, 1691706554, 470817812, 3283403673, 3775521105, 2245821931, 1967093214, 2083749073, 392632208, 3343042534, 877868201, 2691014694, 2371456277, 3892701278, 3529429757, 1722705457, 708323894, 1243302643, 2203157279, 903492952, 667035462, 4134467265, 549855299, 1125598204, 2926423596, 2671877899, 3044652349, 66192250, 1674666943, 3368273949, 3984256464, 4276878911, 3601389186, 967391705, 384702049, 1416647788, 1003633490, 2251196049, 454302481, 3161832498, 3258827368, 4159174448, 793194424, 1883271248, 3188637369, 2035054943, 941635624, 274927765, 933312467, 701114700, 4193253690, 3722435846, 785264201, 1468159766, 2101441538, 2121407775, 2351011400, 1239206503, 2775603746, 1658051727, 1763220485, 3128633466, 2489517536, 1109509226, 2780120899, 2210271065, 168993450, 1280063977, 2395917734, 1643377964, 2548172666, 781822302, 4024534168, 483597733, 1164617145, 906116875, 3303870925, 47891485, 3888912641, 3977574561, 2498361734, 736266143, 1701165666, 640274470, 2150938828, 556586484, 3453533497, 2416193240, 925226908, 2305559619, 2078552113, 3008654349, 4252226453, 3241595826, 182822752, 32583, 6308224, 0};

void encrypt(unsigned int *a, unsigned int *b, unsigned int *c, unsigned int *d, unsigned int index)
{
unsigned int v5, v6;

v5 = table[BYTE3(*a)]^table[BYTE2(*a)+256]^table[BYTE1(*a)+512]^table[BYTE0(*a)+768];
v6 = table[BYTE0(*b)]^table[BYTE3(*b)+256]^table[BYTE2(*b)+512]^table[BYTE1(*b)+768];
*c ^= (table[index]+v5+v6);
ROR(c);
ROL(d);
*d ^= (table[index+1]+2*v6+v5);
}

bool myread(char *dest, int len, FILE *fp)
{
FILE *stream; // [rsp+8h] [rbp-28h]
int i; // [rsp+28h] [rbp-8h]
int v6; // [rsp+2Ch] [rbp-4h]

stream = fp;
memset(dest, 0, len);
for ( i = 0; len - 1 > i; ++i )
{
v6 = fgetc(stream);
if ( v6 == -1 )
return 0;
*(dest + i) = v6;
}
return 1;
}

int main()
{
FILE *fpr, *fpw;

fpr = fopen("C:\\Users\\0xEASONs\\Desktop\\flag.txt","rb");
fpw = fopen("C:\\Users\\0xEASONs\\Desktop\\flag.txt_encryt","wb");
char input[16];
char dest[16];
unsigned int v3, v4, v7, v8, i, index;

if(fpr == NULL)
{
puts("文件不存在");
system("pause");
exit(0);
}
if(fpw == NULL)
{
puts("写入失败");
system("pause");
exit(0);
}

while (myread(input,17,fpr))
{
v3 = (input[0]|input[1]<<8|input[2]<<16|input[3]<<24)^table[1024];
v4 = (input[4]|input[5]<<8|input[6]<<16|input[7]<<24)^table[1025];
v7 = (input[8]|input[9]<<8|input[10]<<16|input[11]<<24)^table[1026];
v8 = (input[12]|input[13]<<8|input[14]<<16|input[15]<<24)^table[1027];

/**********************************************************************************/
for(index = 1032; index<=1062; index+=2)
{
encrypt(&v3,&v4,&v7,&v8,index);
index+=2;
encrypt(&v7,&v8,&v3,&v4,index);
}
/***********************************************************************************/

v7 ^= table[1028];
v8 ^= table[1029];
v3 ^= table[1030];
v4 ^= table[1031];

dest[0] = BYTE0(v7);
dest[1] = BYTE1(v7);
dest[2] = BYTE2(v7);
dest[3] = BYTE3(v7);
dest[4] = BYTE0(v8);
dest[5] = BYTE1(v8);
dest[6] = BYTE2(v8);
dest[7] = BYTE3(v8);
dest[8] = BYTE0(v3);
dest[9] = BYTE1(v3);
dest[10] = BYTE2(v3);
dest[11] = BYTE3(v3);
dest[12] = BYTE0(v4);
dest[13] = BYTE1(v4);
dest[14] = BYTE2(v4);
dest[15] = BYTE3(v4);

for (i = 0; i <= 15; ++i)
fputc(dest[i], fpw);
}

fclose(fpr);
fclose(fpw);
}

直接逆

然后直接逆,贴出脚本

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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

unsigned int ROL(unsigned int *i)
{
*i = *i<<1|(*i>>31);
return *i;
}

unsigned int ROR(unsigned int *i)
{
*i = *i>>1|((*i&1)<<31);
return *i;
}

unsigned int BYTE0(unsigned int i)
{
return i&0xff;
}

unsigned int BYTE1(unsigned int i)
{
return (i>>8)&0xff;
}

unsigned int BYTE2(unsigned int i)
{
return (i>>16)&0xff;
}

unsigned int BYTE3(unsigned int i)
{
return (i>>24)&0xff;
}

unsigned int table[] = {380087468, 1203253039, 2922473062, 2314273025, 2584233285, 4254618194, 895667404, 1071543669, 1459084508, 1966259388, 1337073953, 2472125604, 65886296, 3096890058, 1030275778, 3798867743, 4201647373, 2942994825, 4013619705, 1737496343, 3077872539, 67438343, 2808121223, 3985395278, 1146451831, 3973554593, 3474112961, 4120009820, 3122691453, 1403597876, 536235341, 2292903662, 3304429463, 180140473, 2760761311, 1764338089, 4106859443, 1548445029, 3730649650, 199710294, 45529015, 3056563316, 4079086828, 1994384612, 3999340054, 714375553, 3273509064, 1872369945, 247054014, 3571551115, 4187837781, 1670713360, 1427801220, 3117229349, 3316545656, 132669279, 2384027230, 915379348, 424017405, 3878746103, 3212744085, 3371867806, 781289094, 1323945678, 876159779, 4173773498, 2100867762, 943073834, 2248017928, 4039947444, 1136470056, 1346661484, 3393988905, 3029976003, 3918088521, 3607942099, 3504639116, 90106088, 828885963, 1819754817, 404623890, 1158584472, 4146392043, 3741769181, 2648709658, 3145437842, 3460902446, 3049401388, 1526257109, 1292146326, 490797818, 3450107510, 1805590046, 2158026976, 2381579782, 3652545901, 2517060684, 2515145748, 2788911208, 1391647707, 1685933903, 2449623883, 335103044, 3585762404, 2605951658, 3839733679, 3326287904, 312650667, 2673257901, 3010567324, 3184009762, 2741338240, 1831644846, 606945087, 809247780, 3528604475, 1858205430, 2180714255, 2855559521, 336665371, 1009986861, 1657733119, 2182502231, 2849585465, 290452467, 981507485, 2539430819, 1886147668, 2782277680, 1604730173, 1224839569, 0, 1481532002, 1953059667, 2629563893, 735014510, 3811963120, 2360338921, 1926947811, 936672123, 2714974007, 2202908856, 1937837068, 471536917, 695851481, 2894582225, 3663213877, 1697030304, 1561365130, 1257032137, 2827146966, 1593692882, 3719326314, 3163803085, 269753372, 2982619947, 1270294054, 673330742, 1048943258, 3190127226, 2249412688, 112439472, 628543696, 3946839806, 2403512753, 3906119334, 2963064004, 266490193, 1281325433, 1899477947, 1618495560, 763158238, 4068082435, 1079013488, 22802415, 202311945, 2140013829, 580816783, 847942547, 2005142283, 4240686525, 402408259, 3596041276, 3850780736, 2060512749, 1629726631, 3706422661, 869366908, 801794409, 4213957346, 561240023, 2019973722, 156361185, 223667942, 2494692347, 447260069, 740766001, 2317113689, 647727240, 3932426513, 2127948522, 468929098, 1004237426, 514695842, 2722000751, 4053228379, 1122420679, 1413573483, 1724643576, 2427780348, 4281263589, 1791291889, 3259377447, 2693322968, 3382800753, 3439303065, 2086886749, 1494584717, 3865778200, 963495365, 600137824, 2225465319, 2876214926, 3783477063, 1470903091, 2989126515, 2336732854, 4269083146, 539506744, 3407333062, 2916892222, 1361019779, 3772295336, 4135519236, 2034087349, 357233908, 1752319558, 2581929245, 2072707586, 3340292047, 1189331136, 1213890174, 2562650866, 3639509634, 1091280799, 2651669058, 3236991120, 134876686, 3674462938, 666920807, 1537423930, 3540636884, 2269691839, 3249241983, 2448364307, 3518980963, 2610656439, 825304876, 3065399179, 2492763958, 2004309316, 690572490, 2122209864, 3991785594, 1145370899, 1499012234, 2374833497, 3840204662, 117900548, 2644344890, 3267520573, 640071499, 421108335, 3048553849, 2795950824, 2358043856, 3722249951, 1347425158, 84250239, 1734852647, 218984698, 3604382376, 3941258622, 2913818271, 1397975412, 2105352378, 1768540719, 1970658879, 370565614, 3688624722, 3503322661, 4278075371, 2560101957, 3183330300, 3486456007, 3216984199, 2728570142, 67403766, 589510964, 1246425883, 2459073467, 269522275, 2745392279, 2762234259, 606354480, 4160172263, 1313770733, 134807173, 1616954659, 1027450463, 1566401404, 1785376989, 1633760426, 1936927410, 3823360626, 724289457, 960092585, 3890718084, 2442199369, 943204384, 3166450293, 3452801980, 4261233945, 1448535819, 4193860335, 2998024317, 1701137244, 2408554018, 1229556201, 1532729329, 1381144829, 741130933, 2256965934, 3402274488, 185304183, 2088554803, 842161630, 993743570, 4210704413, 1549570805, 0, 1600120839, 3419105073, 3621221153, 707409464, 2021174981, 3435946549, 1819034704, 2880152082, 1094809452, 976921435, 3806473211, 3705468758, 909517352, 2054825406, 1650609752, 4092808977, 4008618632, 2139073473, 3233866566, 252705665, 2627498419, 404253670, 1920129851, 1667481553, 1515873912, 2896996118, 926405537, 3031747824, 2711738348, 454758676, 3907542533, 774785486, 2324303965, 2307484335, 1162152090, 1263207058, 3537042782, 2037997388, 2425417920, 33721211, 101119117, 50559730, 2206408529, 505323371, 2577006540, 3149608817, 3351766594, 320073617, 2543318468, 859024471, 2155898275, 2947538404, 2678000449, 1802191188, 16904585, 2189618904, 2341200340, 303177240, 892688602, 4059153514, 235801096, 437969053, 2779097114, 2071712823, 1077970661, 2930650221, 4042274275, 3334870987, 1431674361, 3772817536, 3250655951, 2509602495, 353704732, 1364320783, 2863289243, 2829637856, 2391699371, 2526413901, 3587569754, 4244419728, 1835906521, 3755969956, 3739122733, 1010587606, 2593817918, 2812748641, 151588620, 3553823959, 656885442, 1465325186, 623234489, 387420263, 1717973422, 1212708960, 3099086211, 1044307117, 202146163, 3132802808, 2981184143, 3115957258, 1414818928, 1111625118, 555856463, 2172752938, 3789639945, 2223250005, 4109650453, 3082270210, 3924406156, 3014904308, 1886408768, 3958056183, 3654908201, 4126522268, 2475919922, 1482222851, 4025441025, 757936956, 1195869153, 4143366510, 4294954594, 1684323029, 168457726, 1987486925, 3469666638, 2290653990, 471602192, 1179021928, 1280051094, 4227576212, 2273796263, 1330609508, 808507045, 3200170254, 1953771446, 791656519, 1583225230, 1061104932, 3385453642, 3520169900, 3638069408, 3974898163, 3873854477, 673758531, 1852755755, 488498585, 336915093, 522153698, 572704957, 2846435689, 1751661478, 4177054566, 3318050105, 875866451, 3284375988, 538985414, 2964370182, 4075994776, 3368558019, 1296954911, 3671720923, 1903272393, 3857002239, 3570665939, 3301219504, 2661219016, 1869561506, 1128528919, 2240146396, 2694850149, 286352618, 3821029091, 1619502944, 3834433764, 796177967, 1349533776, 4288269567, 76958980, 3644434905, 2195105922, 1479924312, 1518225498, 2959793584, 1796793963, 2539385239, 2708588961, 3480103887, 3927217642, 3072740279, 1906094961, 3981968365, 3922611945, 4132249590, 3472843470, 821552944, 2609391259, 828812849, 545110560, 1757560168, 908736566, 2441490065, 1841641837, 1702929253, 3311412165, 2455565714, 4094070260, 1667071075, 3090106296, 951221560, 2382725006, 2252400006, 2829392552, 416270104, 2986054833, 2838778793, 674766888, 3534153938, 3257710018, 3672339162, 2927150510, 3681696731, 3043875253, 4001552622, 989458234, 1601784927, 2729120418, 1118932802, 851211570, 2241478277, 4158412535, 786825006, 1433879637, 2044275065, 2278665351, 2699067552, 2479733907, 3173532605, 1592264030, 2529867926, 168691722, 3422054091, 2202526083, 4212097531, 759112749, 1097552961, 4181988345, 4081720307, 1787408234, 1542390107, 2102355069, 4036018416, 1554224988, 3384014025, 374833686, 657533991, 1341329743, 935031095, 4258422525, 2131031679, 1717205094, 3357720008, 3210990015, 3514577873, 244860174, 1657550178, 337383444, 1628892769, 2889045932, 648045862, 3843922405, 1373702481, 1009004604, 215209740, 398904087, 1090133312, 1817473132, 712225322, 3617713367, 1741369703, 2500879253, 3127170490, 1220511560, 1177010758, 2047079034, 64674563, 1879964272, 4174732024, 2073213819, 2215344004, 1463604823, 2000776311, 277503248, 3634946264, 1264933963, 1379652178, 3564845012, 4011037167, 2738510755, 996714043, 3784037601, 958608441, 1174214981, 619444004, 2867759274, 252251151, 3166243516, 3588914901, 1678895716, 3284008131, 1503957849, 454368283, 3719292125, 749628716, 2669570975, 314691346, 26298625, 84345861, 1073670975, 1917216882, 3065447094, 2660180638, 2324902538, 628801061, 1956362100, 164942601, 3881176039, 1303937869, 2295898248, 2165076865, 38507010, 3341529543, 3972614892, 4120364277, 2417452944, 858602547, 3695095260, 1227804233, 475630108, 1563614813, 3434410188, 1424362836, 361584917, 3254152897, 138779144, 2094935420, 2579739801, 3441801677, 4043409905, 504502302, 4204710138, 1403689811, 2491493012, 2303322505, 528699679, 2380244109, 4074459890, 3014657715, 3756291807, 3227985856, 3593512406, 2555575704, 324044307, 3153435835, 736295723, 573974562, 1047503422, 3898542056, 3759840736, 878815796, 2639657373, 286987281, 1035303229, 2018009208, 2157787776, 1126221379, 425627161, 2789040038, 0, 3871818470, 1993352566, 1871620975, 2913083053, 122459655, 2408855183, 904979253, 3334142150, 1203145543, 3732226014, 2877276587, 3505224400, 194986251, 3543638483, 3796963298, 1315067982, 499696413, 1257510218, 1147949124, 3304155844, 2585358234, 115203846, 2988527538, 2759249316, 2332195723, 2813073063, 3036450996, 4261971454, 2951318703, 1767076969, 3951418603, 1943478643, 3116240569, 3395891146, 2783413413, 2630135964, 569176865, 598171939, 222469645, 2123743102, 698968361, 1963654773, 1847583342, 1454219094, 1277807180, 2353982860, 3203569854, 444880154, 4232255484, 1324174988, 426711450, 3095640141, 2059303461, 1142113529, 2345962465, 2109373728, 3517763975, 1392333464, 3832997087, 3671841283, 1517836902, 4009881435, 2744623964, 2769986984, 109905652, 2275903328, 1267878658, 117704453, 3815957466, 260116475, 3251618066, 2842274089, 1542544279, 642459319, 1167738120, 2167046548, 4001951402, 2486604943, 2800264914, 2512360830, 4095079498, 1059340077, 3696680183, 4167497931, 2554697742, 3308897645, 25756145, 3752124301, 2953228467, 2546243573, 235408906, 2393607791, 1817209924, 534912878, 3225862371, 3975408673, 1649959502, 1442403741, 510336671, 4041470005, 3727548028, 3643398521, 1872916286, 2761139289, 2067233748, 853422685, 2637864320, 4050317764, 417732715, 3104487868, 1029651878, 354161947, 861352876, 3679640562, 184420981, 2195227374, 446503648, 4070109886, 2870127522, 3485978392, 2309982570, 3554136844, 3570652169, 4220844977, 1764714954, 41616011, 1958114351, 3884246949, 3070408630, 1848340175, 1020673111, 1205946243, 2143387563, 0, 2612501364, 1612931269, 3409038183, 83231871, 1638555956, 3492139126, 3426077794, 303567390, 2158198885, 1700554059, 2401406878, 4120704443, 3299919004, 1842965941, 1359958498, 151783695, 4237360308, 1993176740, 300552548, 2912922966, 2437517569, 2428539120, 2663948026, 328274927, 3401108118, 908604962, 750070978, 1909027233, 1568431459, 1117667853, 3766542496, 3858752814, 675489981, 824979751, 2887167143, 1916498651, 4284678094, 3062609479, 1088766086, 3377121772, 3579500024, 1443583719, 1284918279, 1755736123, 3461271273, 1594318824, 2118680154, 2321386000, 3609319283, 1293897206, 816132310, 632890829, 3451702675, 3808158251, 2978984258, 2284226715, 758918451, 1051541212, 2000975701, 1941074730, 1586388505, 1559583890, 3136862918, 1400132457, 234491248, 3958893348, 2862328403, 496573925, 1730635712, 2521667076, 3144792887, 2220196890, 2026207406, 558834098, 1792895664, 3634419848, 2994582072, 3335243287, 345314538, 2629016689, 733031367, 2833295576, 3187457475, 192351108, 979057315, 2808194851, 2580322815, 2587794053, 2719916717, 1181238898, 4246338885, 1476614381, 2362477796, 208866433, 4196268608, 1214269560, 3934186197, 3918326191, 607134780, 2716639703, 92210574, 3035673804, 3019158473, 1331974013, 1800694593, 3859670612, 3213344584, 582820552, 4078039887, 2469565322, 1240025481, 1097613687, 1350979603, 2461766267, 142936318, 590619449, 1502239004, 2951000029, 1691706554, 470817812, 3283403673, 3775521105, 2245821931, 1967093214, 2083749073, 392632208, 3343042534, 877868201, 2691014694, 2371456277, 3892701278, 3529429757, 1722705457, 708323894, 1243302643, 2203157279, 903492952, 667035462, 4134467265, 549855299, 1125598204, 2926423596, 2671877899, 3044652349, 66192250, 1674666943, 3368273949, 3984256464, 4276878911, 3601389186, 967391705, 384702049, 1416647788, 1003633490, 2251196049, 454302481, 3161832498, 3258827368, 4159174448, 793194424, 1883271248, 3188637369, 2035054943, 941635624, 274927765, 933312467, 701114700, 4193253690, 3722435846, 785264201, 1468159766, 2101441538, 2121407775, 2351011400, 1239206503, 2775603746, 1658051727, 1763220485, 3128633466, 2489517536, 1109509226, 2780120899, 2210271065, 168993450, 1280063977, 2395917734, 1643377964, 2548172666, 781822302, 4024534168, 483597733, 1164617145, 906116875, 3303870925, 47891485, 3888912641, 3977574561, 2498361734, 736266143, 1701165666, 640274470, 2150938828, 556586484, 3453533497, 2416193240, 925226908, 2305559619, 2078552113, 3008654349, 4252226453, 3241595826, 182822752, 32583, 6308224, 0};

void decrypt(unsigned int *a, unsigned int *b, unsigned int *c, unsigned int *d, unsigned int index)
{
unsigned int v5, v6;

v5 = table[BYTE3(*a)]^table[BYTE2(*a)+256]^table[BYTE1(*a)+512]^table[BYTE0(*a)+768];
v6 = table[BYTE0(*b)]^table[BYTE3(*b)+256]^table[BYTE2(*b)+512]^table[BYTE1(*b)+768];
*d ^= (table[index+1]+2*v6+v5);
ROR(d);
ROL(c);
*c ^= (table[index]+v5+v6);
}

int main()
{
FILE *fpr, *fpw;

fpr = fopen("C:\\Users\\0xEASONs\\Desktop\\secret_file.jpg_encrypted","rb");
fpw = fopen("C:\\Users\\0xEASONs\\Desktop\\secret_file.jpg","wb");
char input[16];
char dest[16];
unsigned int v3, v4, v7, v8, i, index;

if(fpr == NULL)
{
puts("文件不存在");
system("pause");
exit(0);
}
if(fpw == NULL)
{
puts("写入失败");
system("pause");
exit(0);
}

while (fread(input,1,16,fpr))
{
v7 = BYTE0(input[0])|BYTE0(input[1])<<8|BYTE0(input[2])<<16|BYTE0(input[3])<<24;
v8 = BYTE0(input[4])|BYTE0(input[5])<<8|BYTE0(input[6])<<16|BYTE0(input[7])<<24;
v3 = BYTE0(input[8])|BYTE0(input[9])<<8|BYTE0(input[10])<<16|BYTE0(input[11])<<24;
v4 = BYTE0(input[12])|BYTE0(input[13])<<8|BYTE0(input[14])<<16|BYTE0(input[15])<<24;

v7 ^= table[1028];
v8 ^= table[1029];
v3 ^= table[1030];
v4 ^= table[1031];

for(index = 1062; index>=1032; index-=2)
{
decrypt(&v7,&v8,&v3,&v4,index);
index-=2;
decrypt(&v3,&v4,&v7,&v8,index);
}

v3 ^= table[1024];
v4 ^= table[1025];
v7 ^= table[1026];
v8 ^= table[1027];

dest[0] = BYTE0(v3);
dest[1] = BYTE1(v3);
dest[2] = BYTE2(v3);
dest[3] = BYTE3(v3);
dest[4] = BYTE0(v4);
dest[5] = BYTE1(v4);
dest[6] = BYTE2(v4);
dest[7] = BYTE3(v4);
dest[8] = BYTE0(v7);
dest[9] = BYTE1(v7);
dest[10] = BYTE2(v7);
dest[11] = BYTE3(v7);
dest[12] = BYTE0(v8);
dest[13] = BYTE1(v8);
dest[14] = BYTE2(v8);
dest[15] = BYTE3(v8);

for (i = 0; i <= 15; ++i)
fputc(dest[i], fpw);
}


fclose(fpr);
fclose(fpw);
}

flag