首页
社区
课程
招聘
[原创]第二题 星际生物
发表于: 2024-8-17 00:03 1250

[原创]第二题 星际生物

2024-8-17 00:03
1250

题目是一个数独加一个迷宫

文件类型:PE32+ executable (console) x86-64 Mono/.Net assembly, for MS Windows

核心函数:

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
// Token: 0x06000003 RID: 3 RVA: 0x00001090 File Offset: 0x00000490
internal unsafe static int main()
{
    $ArrayType$$$BY0BAA@D $ArrayType$$$BY0BAA@D;
    initblk(ref $ArrayType$$$BY0BAA@D, 0, 256);
    <Module>.printf(ref <Module>.??_C@_0BJ@MNCFGMHN@Please?5input?5your?5flag?3?5?$AA@, __arglist());
    <Module>.scanf(ref <Module>.??_C@_05HPMPOKFN@?$CF?$FL?$FO?6?$FN?$AA@, __arglist((sbyte*)(&$ArrayType$$$BY0BAA@D)));
    sbyte* ptr = ref $ArrayType$$$BY0BAA@D;
    if ($ArrayType$$$BY0BAA@D != null)
    {
        do
        {
            ptr += 1L;
        }
        while (*ptr != 0);
    }
    if (ptr - (ref $ArrayType$$$BY0BAA@D) != 70U)
    {
        <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
        return -1;
    }
    // 102 108 97 103 123 125
    // flag{}
    if ($ArrayType$$$BY0BAA@D == 102 && *((ref $ArrayType$$$BY0BAA@D) + 1) == 108 && *((ref $ArrayType$$$BY0BAA@D) + 2) == 97 && *((ref $ArrayType$$$BY0BAA@D) + 3) == 103 && *((ref $ArrayType$$$BY0BAA@D) + 4) == 123 && *((ref $ArrayType$$$BY0BAA@D) + 69) == 125)
    {
        $ArrayType$$$BY0EA@E $ArrayType$$$BY0EA@E;
        cpblk(ref $ArrayType$$$BY0EA@E, (ref $ArrayType$$$BY0BAA@D) + 5, 64);
        uint num = 0U;
        uint num2 = 0U;
        $ArrayType$$$BY188E* ptr2 = &<Module>.sudoku;
        do
        {
            uint num3 = 0U;
            $ArrayType$$$BY188E* ptr3 = ptr2;
            do
            {
                if (*(byte*)ptr3 == 15)
                {
                    byte b = *((ulong)num + (ref $ArrayType$$$BY0EA@E));
                    if (b < 48 || b > 57)  // 0 9
                    {
                        goto IL_109;
                    }
                    *(byte*)ptr3 = b - 48;
                    num += 1U;
                }
                num3 += 1U;
                ptr3 += 1L / (long)sizeof($ArrayType$$$BY188E);
            }
            while (num3 < 9U);
            num2 += 1U;
            ptr2 += 9L / (long)sizeof($ArrayType$$$BY188E);
        }
        while (num2 < 9U);
        uint num4 = 1U;
        uint num5 = 1U;
        uint num6 = 0U;
        long num7 = 0L;
        while (num4 == 1U)
        {
            long num8 = 0L;
            uint num9 = 1U;
            while (num4 == 1U)
            {
                uint num10 = num9;
                if (num9 < 9U)
                {
                    long num11 = (long)((ulong)num9);
                    byte b2 = *(num7 + num8 + (ref <Module>.sudoku));
                    num4 = 1U;
                    $ArrayType$$$BY188E* ptr4 = num7 + num11 + (ref <Module>.sudoku);
                    while (b2 != *(byte*)ptr4)
                    {
                        num10 += 1U;
                        ptr4 += 1L / (long)sizeof($ArrayType$$$BY188E);
                        if (num10 >= 9U)
                        {
                            goto IL_17F;
                        }
                    }
                    num4 = 0U;
                }
                IL_17F:
                num9 += 1U;
                num8 += 1L;
                if (num9 - 1U >= 9U)
                {
                    break;
                }
            }
            num6 += 1U;
            num7 += 9L;
            if (num6 >= 9U)
            {
                break;
            }
        }
        uint num12 = 0U;
        long num13 = 0L;
        while (num5 == 1U)
        {
            uint num14 = 1U;
            $ArrayType$$$BY188E* ptr5 = num13 + (ref <Module>.sudoku);
            while (num5 == 1U)
            {
                uint num15 = num14;
                if (num14 < 9U)
                {
                    $ArrayType$$$BY188E* ptr6 = num14;
                    byte b3 = *(byte*)ptr5;
                    num5 = 1U;
                    $ArrayType$$$BY188E* ptr7 = ptr6 * 9L + num13 / (long)sizeof($ArrayType$$$BY188E) + (ref <Module>.sudoku) / sizeof($ArrayType$$$BY188E);
                    while (b3 != *(byte*)ptr7)
                    {
                        num15 += 1U;
                        ptr7 += 9L / (long)sizeof($ArrayType$$$BY188E);
                        if (num15 >= 9U)
                        {
                            goto IL_209;
                        }
                    }
                    num5 = 0U;
                }
                IL_209:
                num14 += 1U;
                ptr5 += 9L / (long)sizeof($ArrayType$$$BY188E);
                if (num14 - 1U >= 9U)
                {
                    break;
                }
            }
            num12 += 1U;
            num13 += 1L;
            if (num12 >= 9U)
            {
                break;
            }
        }
        if (num4 == 1U && num5 == 1U)
        {
            $ArrayType$$$BY133E $ArrayType$$$BY133E = 33;  // !
            *((ref $ArrayType$$$BY133E) + 1) = 45;  // -
            *((ref $ArrayType$$$BY133E) + 2) = 63;  // ?
            *((ref $ArrayType$$$BY133E) + 3) = 43;  // +
            *((ref $ArrayType$$$BY133E) + 4) = 43;
            *((ref $ArrayType$$$BY133E) + 5) = 43;
            *((ref $ArrayType$$$BY133E) + 6) = 45;
            *((ref $ArrayType$$$BY133E) + 7) = 43;
            *((ref $ArrayType$$$BY133E) + 8) = 45;
            *((ref $ArrayType$$$BY133E) + 9) = 43;
            *((ref $ArrayType$$$BY133E) + 10) = 43;
            *((ref $ArrayType$$$BY133E) + 11) = 43;
            *((ref $ArrayType$$$BY133E) + 12) = 43;
            *((ref $ArrayType$$$BY133E) + 13) = 45;
            *((ref $ArrayType$$$BY133E) + 14) = 45;
            *((ref $ArrayType$$$BY133E) + 15) = 43;
            byte b4 = 0;
            byte b5 = 0;
            uint num16 = 0U;
            do
            {
                int num17 = (int)(*((ulong)num + (ref $ArrayType$$$BY0EA@E)));
                num += 1U;
                if (num17 != 65)  // A
                {
                    if (num17 != 68)  // D
                    {
                        if (num17 != 83)  // S
                        {
                            if (num17 == 87)  // W
                            {
                                if (b4 == 0)
                                {
                                    goto IL_323;
                                }
                                b4 -= 1;
                            }
                        }
                        else
                        {
                            if (b4 == 3)
                            {
                                goto IL_330;
                            }
                            b4 += 1;
                        }
                    }
                    else
                    {
                        if (b5 == 3)
                        {
                            goto IL_33D;
                        }
                        b5 += 1;
                    }
                }
                else
                {
                    if (b5 == 0)
                    {
                        goto IL_34A;
                    }
                    b5 -= 1;
                }
                if (*((ulong)b5 + (ref $ArrayType$$$BY133E) + (ulong)b4 * 4UL) == 45)  // -
                {
                    goto IL_357;
                }
                num16 += 1U;
            }
            while (num16 < 8U);
            if (*((ulong)b5 + (ref $ArrayType$$$BY133E) + (ulong)b4 * 4UL) == 63)  // ?
            {
                <Module>.printf(ref <Module>.??_C@_0BB@MGPKLNCH@You?5are?5winner?$CB?6?$AA@, __arglist());
                return 0;
            }
            goto IL_381;
            IL_323:
            <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
            return -1;
            IL_330:
            <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
            return -1;
            IL_33D:
            <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
            return -1;
            IL_34A:
            <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
            return -1;
            IL_357:
            <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
            return -1;
        }
        goto IL_381;
        IL_109:
        <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
        return -1;
    }
    IL_381:
    <Module>.printf(ref <Module>.??_C@_0M@IIPHMAMA@Try?5again?$CB?6?$AA@, __arglist());
    return -1;
}

开头规定了格式:flag{<64个字符>}
没找到 &<Module>.sudoku 初始化的位置,调试可以得到初始值为:

1
[15,15,2,15,15,7,15,15,15,15,6,15,9,15,15,4,15,15,15,9,15,2,5,15,15,15,3,15,15,15,4,15,15,1,15,15,7,3,15,15,6,15,15,15,15,15,15,9,5,3,15,15,6,15,15,15,6,3,4,15,15,7,15,8,15,15,15,15,15,15,15,9,15,15,15,15,15,15,15,5,15]

结合逻辑,如果值为15,就会被输入的一个字符替换,这里会用掉输入的56个字符,解这个数独就可以得到56个字符:

1
34689155813271746868579324125982187492581517263447389126

$ArrayType$$$BY133E 初始化了一个迷宫:

1
2
3
4
!-?+
++-+
-+++
+--+

使用"ADSW"控制方向,从"!"沿着"+"走到"?",不能走"-",这样可以得到最后8个字符:

1
SDSDDWWA

拼接最终flag为:

1
flag{34689155813271746868579324125982187492581517263447389126SDSDDWWA}

[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回
//