这是一个关于炸弹的简短的 C 代码,了解思路即可哈!
参考资料
反汇编思路及过程:拆解二进制炸弹详解
phase_1 C语言代码
string input;
cin >> input;string answer = "Let's begin now!";
if (input == answer)return;
elseexplode_bomb();
phase_2 C语言代码
//假设 ID_num 为 11 位
int input[6];
for (int i = 0; i < 6; ++i)cin >> a[i];//爆炸点
if (a[0] != 1)explode_bomb();for (int i = 0; i < 5; ++i) {int ID = ID_num[10 - i];if (a[i] * ID != a[i + 1])explode_bomb();
}
phase_3 C语言代码
int a[2];
char c;
cin >> a[0] >> c >> a[1];int ID = 输入ID的最后一位
char c0;
int b;
switch (a[0]) {case 0 : {c0 = 'q';b = 777;if (ID * a[1] != b)explode_bomb();break;}case 1 : {c0 = 'b';b = 214;if (ID * a[1] != b)explode_bomb();break;}case 2 : {c0 = 'b';b = 755;if (ID * a[1] != b)explode_bomb();break;}case 3 : {c0 = 'k';b = 0;if (ID * a[1] != b)explode_bomb();break;}case 4 : {c0 = 'o';b = 228;if (ID * a[1] != b)explode_bomb();break;}case 5 : {c0 = 't';b = 513;if (ID * a[1] != b)explode_bomb();break;}case 6 : {c0 = 'v';b = 780;if (ID * a[1] != b)explode_bomb();break;}case 7 : {c0 = 'b';b = 824;if (ID * a[1] != b)explode_bomb();break;}default:explode_bomb();}if (c != c0)explode_bomb();
phase_4 C语言代码
int ID = 输入学号最后一位
int fun4(int x)
{if (x < 2)return 1;return fun4(x - 1) + fun4(x - 2);
}int x;
cin >> x;if (ID 为奇数) {if (fun4(x) != 8)explode_bomb();
}
else {if (fun4(x) != 13)explode_bomb();
}
phase_5 C语言代码
char S[16] = "isrveawhobpnutfg";
char answer[6] = "giants";char input[6];
cin >> input;char a[6];
for (int i = 0; i < 6; ++i) {int pos = str[i] & 15;a[i] = S[pos];
}for (int i = 0; i < 6; ++i) {if (a[i] != answer[i])explode_bomb();
}
phase_6 C语言代码
int a[6];
for (int i = 0;i < 6;i++)cin>>a[i];for (int i = 0;i < 6;i++) {if (!(i > 0 && i < 7) explode_bomb();for (int j = i + 1;j < 6;j++)if (a[i] == a[j]) explode_bomb();
}
chain c = {0x0fd, 0x2d5, 0x12d, 0x3e5, 0x0d4, 0x1b0};
chainNode res[6];
for (int i = 0;i < 6;i++) {chainNode *node = c.firstNode;for (int j = 1;j < a[i];j++)node = node->next;res[i] = node;
}chainNode *node = res[0];
for (int i = 1;i < 6;i++) {node->next = res[i];node = res[i];
}
node->next = null;
if (ID & 1) {node = c.firstNode;for (int i = 1;i < 6;i++)if (node->element < node->next->element)explode_bomb();
}
else {node = c.firstNode;for (int i = 1;i < 6;i++)if (node->element > node->next->element)explode_bomb();
}
隐藏炸弹的代码过段时间再进行补充。