basic-re-su

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
v4 = 2;
v5 = 3;
v6 = 2;
v7 = 1;
v8 = 4;
v9 = 7;
v10 = 4;
v11 = 5;
v12 = 10;
v13 = 11;
v14 = 10;
v15 = 9;
v16 = 14;
v17 = 15;
v18 = 12;
v19 = 13;
v20 = 16;
v21 = 19;
v22 = 16;
v23 = 17;
v24 = 20;
v25 = 23;
v26 = 22;
v27 = 19;
v28 = 28;
v29 = 25;
v30 = 30;
v31 = 31;
v32 = 28;
v33 = 25;
v34 = 26;
v35 = 31;
v36 = 36;
v37 = 33;
v38 = 34;
v39 = 39;
v40 = 36;
v41 = 33;
v42 = 34;
v43 = 35;
v44 = 40;
v45 = 41;
v46 = 46;
v47 = 43;
v48 = 36;
v49 = 45;
v50 = 38;
v51 = 47;
v52 = 56;
v53 = 49;
v54 = 58;
v55 = 59;
v56 = 52;
v57 = 61;
v58 = 62;
v59 = 55;
v60 = 48;
v61 = 57;
v62 = 50;
v63 = 59;
v64 = 60;
v65 = 53;
v66 = 54;
v67 = 55;
v68 = 72;
v69 = 73;
v70 = 66;
v71 = 66;
v72 = 68;
v73 = 68;
v74 = 70;
v75 = 71;
v76 = 72;
v77 = 73;
v78 = 74;
v79 = 74;
v80 = 77;
v81 = 77;
v82 = 79;
v83 = 78;
v84 = 80;
v85 = 80;
v86 = 82;
v87 = 83;
v88 = 85;
v89 = 84;
v90 = 86;
v91 = 87;
v92 = 89;
v93 = 89;
v94 = 90;
v95 = 91;
v96 = 92;
v97 = 93;
v98 = 94;
v99 = 94;
v100 = 96;
v101 = 96;
v102 = 99;
v103 = 99;
v104 = 100;
v105 = 101;
v106 = 103;
v107 = 103;
v108 = 105;
v109 = 105;
v110 = 107;
v111 = 107;
v112 = 108;
v113 = 109;
v114 = 110;
v115 = 110;
v116 = 112;
v117 = 112;
v118 = 114;
v119 = 115;
v120 = 116;
v121 = 117;
v122 = 119;
v123 = 119;
v124 = 120;
v125 = 121;
v126 = 123;
v127 = 123;
v128 = 125;
v129 = 125;
v130 = 127;
v131 = 127;
v132 = 129;
v133 = 129;
v134 = 131;
v135 = 131;
v136 = 140;
v137 = 141;
v138 = 142;
v139 = 143;
v140 = 136;
v141 = 137;
v142 = 138;
v143 = 139;
v144 = 140;
v145 = 141;
v146 = 142;
v147 = 135;
v148 = 152;
v149 = 145;
v150 = 146;
v151 = 147;
v152 = 148;
v153 = 149;
v154 = 150;
v155 = 151;
v156 = 152;
v157 = 153;
v158 = 154;
v159 = 154;
v160 = 156;
v161 = 156;
v162 = 158;
v163 = 158;
v164 = 160;
v165 = 160;
v166 = 162;
v167 = 162;
v168 = 164;
v169 = 164;
v170 = 166;
v171 = 166;
v172 = 168;
v173 = 168;
v174 = 170;
v175 = 170;
v176 = 172;
v177 = 172;
v178 = 174;
v179 = 174;
v180 = 176;
v181 = 177;
v182 = 178;
v183 = 179;
memset(v184, 0, 0x1Fui64);
sub_140011159(std::cout, "flag format: SUCTF{xxxxxxxxxxxxxxx}\n");
sub_140011159(std::cout, "Please Input Key:");
std::basic_istream<char,std::char_traits<char>>::operator>>(std::cin, &v186);
v186 %= 0x10000u;
v185 = 8;
while ( v185 )
{
--v185;
for ( j = 22; j; v184[j] |= v189 << v185 )
{
v188 = *(&v4 + 22 * v185 + --j);
v189 = (v188 >> ((v186 >> 2 * v185) & 3)) & 1;
}
}
sub_140011159(std::cout, v184);
system("pause");
sub_1400113A7((__int64)&v3, (__int64)&unk_14001AD10);
return 0i64;

这一题很简单,只是在爆破的时候遇到几个坑(因为自己的鶸),所以记录一下。

程序流程就是输入一个key,大小为0x0001~0xffff。经过运算后输出v184,给了flag格式直接爆破就是了。

但是ida初始化是,v4后面大于127的值都默认显示成了负数,这样是爆破不出来的,按两次h转换成正数。

其他就是爆破时的逻辑了,基本上照着原代码copy就行了。

爆破脚本:

1
2
3
4
5
6
7
8
9
10
11
value=[2,3,2,1,4,7,4,5,10,11,10,9,14,15,12,13,16,19,16,17,20,23,22,19,28,25,30,31,28,25,26,31,36,33,34,39,36,33,34,35,40,41,46,43,36,45,38,47,56,49,58,59,52,61,62,55,48,57,50,59,60,53,54,55,72,73,66,66,68,68,70,71,72,73,74,74,77,77,79,78,80,80,82,83,85,84,86,87,89,89,90,91,92,93,94,94,96,96,99,99,100,101,103,103,105,105,107,107,108,109,110,110,112,112,114,115,116,117,119,119,120,121,123,123,125,125,127,127,129,129,131,131,140,141,142,143,136,137,138,139,140,141,142,135,152,145,146,147,148,149,150,151,152,153,154,154,156,156,158,158,160,160,162,162,164,164,166,166,168,168,170,170,172,172,174,174,176,177,178,179]
for key in range(0xffff):
flagnc=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
for i in range(7,-1,-1):
for j in range(21,-1,-1):
v188=value[22*i+j]
v189=(v188>>((key>>2*i)&3))&1
flagnc[j]|=v189<<i
flag="".join([chr(ch) for ch in flagnc])
if ~flag.find("SUCTF{"):
print flag
文章目录
|