mips

点击此处获得更好的阅读体验


WriteUp来源

官方WP

题目描述

题目考点

  • mips指令集

  • 算法的逆向能力

解题思路

题目实际上要解的是一个迷宫,wasd分别对应上下左右 有三层关卡,通过了三层关卡之后才能够拿到最后正确信息

最后的输入内容是

1
sssssssdddddddsssssssssssddddddddddsddssddwddssssssdddssssdddss

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
#include<stdio.h>
#include<string.h>
#define N 15
#define M 3

int level = 0;
int x,y;
int map[M][N][N] = {
{ //
{1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,0,3,0,1,0,0,0,0,0,0},
{1,1,1,1,1,0,1,0,1,0,0,0,0,0,0},
{1,1,1,1,1,0,1,0,1,0,0,0,0,0,0},
{1,1,1,1,1,0,1,0,1,1,1,1,1,0,0},
{1,1,1,1,1,0,1,0,0,0,0,0,1,0,0},
{1,1,1,1,1,0,1,0,0,0,0,0,1,0,0},
{1,1,1,1,1,0,1,0,0,0,0,0,1,1,0},
{1,1,1,1,1,0,1,1,1,1,1,1,1,1,0},
{1,1,1,1,1,0,0,0,0,0,0,0,0,4,0},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1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,0,0,0,0,0,0,0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,4,0},
}
};//ddssddwddssssssdddssssdddss


//函数声明
void menu();
void find();
int move();
int Up();
int Down();
int Right();
int Left();


int main(void)
{
int flag = 0;
menu();
while(1)
{
flag = move();
if(flag == 1 || flag == -1)
return 0;
}
return 0;
}
//找到自己的位置
void find()
{

int i= 0,j = 0;
for(i = 0;i < N;i++)
{
for(j = 0;j < N;j++)
{
if(map[level][i][j] == 3)
{
x = i;
y = j;
break;
}
}
}
}
int move()
{
int flag = 0;
int index = 0;
char ans[512] = {0};
scanf("%s", ans);
while(1)
{
flag = 0;
find();
switch(ans[index])
{
case 'w':flag = Up();break;
case 'a':flag = Left();break;
case 's':flag = Down();break;
case 'd':flag = Right();break;
case 27:return -1;
}
index++;
if(flag == 1)
{
//pass
if(level == M-1)
{
printf("success! the flag is flag{md5(your input)}\n");
return 1;
}
else
{
level++;
}
}
}
}
int Up()
{
if(x != 0)
{
if(map[level][x-1][y] == 1)//可走
{
map[level][x-1][y] = 3;
map[level][x][y] = 1;
}
else if(map[level][x-1][y] == 4)
{
return 1;
}
}
return 0;
}
int Down()
{
if(x != N-1)
{
if(map[level][x+1][y] == 1)//可走
{
map[level][x+1][y] = 3;
map[level][x][y] = 1;
}
else if(map[level][x+1][y] == 4)
{
return 1;
}
}
return 0;
}
int Right()
{
if(y != N-1)
{
if(map[level][x][y+1] == 1)//可走
{
map[level][x][y+1] = 3;
map[level][x][y] = 1;
}
else if(map[level][x][y+1] == 4)
{
return 1;
}
}
return 0;
}
int Left()
{
if(y != 0)
{
if(map[level][x][y-1] == 1)//可走
{
map[level][x][y-1] = 3;
map[level][x][y] = 1;
}
else if(map[level][x][y-1] == 4)
{
return 1;
}
}
return 0;
}
void menu()
{
level = 0;
}

Flag

1
flag{999ea6aa6c365ab43eec2a0f0e5968d5}