二进制炸弹Binary Bomb第六关邪道速通法

文章介绍了一种在Ubuntu22.04系统下,使用VSCode和C++CompileRun插件通过深度优先搜索(DFS)策略暴力破解二进制炸弹游戏第六关的方法。前提需要知道前五关的密码。代码会生成所有可能的第六关输入并检测正确答案,最终找到解并给出了第六关的答案。此外,还提到该方法也可用于第四关的破解,以及使用Ghidra软件进行反编译辅助解题。
摘要由CSDN通过智能技术生成

坐标HIT,二进制炸弹第六关为众所周知的毒瘤点,今天来电大家想看的交作业邪道速通

先挂环境,Ubuntu22.04LTS系统,VS Code,编译插件C/C++ Compile Run

不说废话,直接贴代码

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;

int _dfs(int arr[], int depth, int check) {
    if (depth == 6) {
        if (check != 126)
            return 0;
        freopen("input.txt", "w", stdout);
        cout << "I am not part of the problem. I am a Republican.\n0 1 1 2 3 5\n1 809\n7 7\n9?1057\n";
        for (int i = 1; i <= 6; i ++) 
            cout << arr[i] << ' ';
        cout << endl;
        system("./bomb < input.txt > ans.txt");
        freopen("ans.txt", "r", stdin);
        char s[100] = { 0 };
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        scanf("%[^\n]", s); getchar();
        if (s[0] == 'C') {
            for (int i = 1; i <= 6; i ++)
                cout << arr[i] << ' ';
            exit(0);
        }
        return 0;
    }
    for (int i = 1; i <= 6; i ++) {
        arr[depth + 1] = i;
        _dfs(arr, depth + 1, check | (1 << i));
    }
}
int main() {
    int arr[10] = { 0 };
    _dfs(arr, 0, 0);
    return 0;
}

思路是硬搜,但是使用前提是知道前五关的密码(这个是白给)

由于总共只有720种情况,所以可以全部遍历一遍检测哪个是对的,其中

system("./bomb < input.txt > ans.txt");

这一行是把输入定向到input.txt,输出定向到ans.txt,这样只需要在input中枚举输入即可,最后答案文件如下所示

I am not part of the problem. I am a Republican.
0 1 1 2 3 5
1 809
7 7
9?1057
4 6 1 5 3 2 
4 6 1 5 3 2 

最后两行即为第六关结果,同理这个方法也可以用来暴力破解第四关

大家在用的时候记得把代码里面的前五关输出换成自己的,不会做的可以用Ghidra软件在Windows下跑反编译直接看,并且跑出来的代码可以问New Bing/ChatGPT

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值