学逆向论坛

找回密码
立即注册

只需一步,快速开始

发新帖

484

积分

2

好友

29

主题

[Reverse] 拆炸弹wp

发表于 2019-5-14 16:11:22 | 查看: 4661| 回复: 1

相关题目:

♦ 拆炸弹

思路

用IDA反汇编发现使用C#编写的,所以直接把程序拖到ILSpycn反编译就可以看到程序了。

关键代码

//rev4.MainWindow
private void btn_Checker(int para)
{
    int[] array = new int[]
    {
        0,
        1,
        3,
        4,
        2,
        1,
        2,
        3,
        4
    };
    bool flag = this.hit < 8;
    if (flag)
    {
        int num = this.hit;
        this.hit = num + 1;
    }
    else
    {
        base.Close();
    }
    bool flag2 = this.first;
    if (flag2)
    {
        this.tb1.Text = "";
        this.first = false;
    }
    bool flag3 = array[this.hit] == para;
    if (flag3)
    {
        int num = this.correct;
        this.correct = num + 1;
    }
    bool flag4 = this.correct == 8;
    if (flag4)
    {
        MessageBox.Show("Succeed!");
        TextBlock textBlock = this.tb1;
        textBlock.Text = string.Concat(new string[]
        {
            textBlock.Text,
            this.sp1.Tag.ToString(),
            this.sp2.Tag.ToString(),
            this.sp3.Tag.ToString(),
            this.sp4.Tag.ToString()
        });
    }
}

分析

可以看到有个Succeed,所以要让程序走到这里。通过分析发现,要走到succeed,flag4就要为true,则Correct要等于8,而correct初始值为0,所以需要通过flag3那里来增加correct的值。最后得出的结论就是你输入的内容要为数组array[1]~array[8]的值。对应的数字也就是你按钮的数字。
按了8次后,会显示Succeed的对话框,并显示flag。

完整代码

using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;

namespace rev4
{
    public class MainWindow : Window, IComponentConnector
    {
        private bool first;

        private int hit;

        private int correct;//定义成员数据

        internal StackPanel sp1;

        internal StackPanel sp2;

        internal StackPanel sp3;

        internal StackPanel sp4;

        internal TextBlock tb1;

        internal Button bt1;

        internal Button bt2;

        internal Button bt3;

        internal Button bt4;//定义所有的键

        private bool _contentLoaded;

        public MainWindow() //初始化所有成员数据
        {
            this.InitializeComponent();
            this.first = true;
            this.hit = 0;
            this.correct = 0;
        }

        private void bt1_Click(object sender, RoutedEventArgs e)
        {
            this.btn_Checker(1);
        }

        private void bt2_Click(object sender, RoutedEventArgs e)
        {
            this.btn_Checker(2);
        }

        private void bt3_Click(object sender, RoutedEventArgs e)
        {
            this.btn_Checker(3);
        }

        private void bt4_Click(object sender, RoutedEventArgs e)  //以上相同功能设置每个按钮所传递的值
        {
            this.btn_Checker(4);
        } 

        private void btn_Checker(int para) 
        {
            int[] array = new int[]   //这里就是按动的按钮顺序
            {
                0,
                1,
                3,
                4,
                2,
                1,
                2,
                3,
                4
            };
            bool flag = this.hit < 8;  //比较按动次数是否为8次
            if (flag)
            {
                int num = this.hit;
                this.hit = num + 1;
            }
            else
            {
                base.Close();
            }
            bool flag2 = this.first;
            if (flag2)  
            {
                this.tb1.Text = "";
                this.first = false;
            }
            bool flag3 = array[this.hit] == para; //比较我按动按钮传递的值和数组中的数比较
            if (flag3)
            {
                int num = this.correct;
                this.correct = num + 1;
            }
            bool flag4 = this.correct == 8;          //当八个都按对,弹出成功,得到flag
            if (flag4)
            {
                MessageBox.Show("Succeed!");
                TextBlock textBlock = this.tb1;
                textBlock.Text = string.Concat(new string[]
                {
                    textBlock.Text,
                    this.sp1.Tag.ToString(),
                    this.sp2.Tag.ToString(),
                    this.sp3.Tag.ToString(),
                    this.sp4.Tag.ToString()
                });
            }
        }

        [GeneratedCode("PresentationBuildTasks", "4.0.0.0"), DebuggerNonUserCode]
        public void InitializeComponent()
        {
            bool contentLoaded = this._contentLoaded;
            if (!contentLoaded)
            {
                this._contentLoaded = true;
                Uri resourceLocator = new Uri("/rev4;component/mainwindow.xaml", UriKind.Relative);
                Application.LoadComponent(this, resourceLocator);
            }
        }

        [GeneratedCode("PresentationBuildTasks", "4.0.0.0"), EditorBrowsable(EditorBrowsableState.Never), DebuggerNonUserCode]
        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.sp1 = (StackPanel)target;
                break;
            case 2:
                this.sp2 = (StackPanel)target;
                break;
            case 3:
                this.sp3 = (StackPanel)target;
                break;
            case 4:
                this.sp4 = (StackPanel)target;
                break;
            case 5:
                this.tb1 = (TextBlock)target;
                break;
            case 6:
                this.bt1 = (Button)target;
                this.bt1.Click += new RoutedEventHandler(this.bt1_Click);
                break;
            case 7:
                this.bt2 = (Button)target;
                this.bt2.Click += new RoutedEventHandler(this.bt2_Click);
                break;
            case 8:
                this.bt3 = (Button)target;
                this.bt3.Click += new RoutedEventHandler(this.bt3_Click);
                break;
            case 9:
                this.bt4 = (Button)target;
                this.bt4.Click += new RoutedEventHandler(this.bt4_Click);
                break;
            default:
                this._contentLoaded = true;
                break;
            }
        }
    }
}

题目下载


拆炸弹.zip (31.9 KB, 下载次数: 2)
温馨提示:
1.如果您喜欢这篇帖子,请给作者点赞评分,点赞会增加帖子的热度,评分会给作者加学币。(评分不会扣掉您的积分,系统每天都会重置您的评分额度)。
2.回复帖子不仅是对作者的认可,还可以获得学币奖励,请尊重他人的劳动成果,拒绝做伸手党!
3.发广告、灌水回复等违规行为一经发现直接禁言,如果本帖内容涉嫌违规,请点击论坛底部的举报反馈按钮,也可以在【投诉建议】板块发帖举报。
嘿嘿
发表于 2020-8-11 17:21:41
本帖最后由 dc198488 于 2020-8-11 17:22 编辑

无需读算法,将
        MessageBox.Show("Succeed!");
        TextBlock textBlock = this.tb1;
        textBlock.Text = string.Concat(new string[]
        {
                textBlock.Text,
                this.sp1.Tag.ToString(),
                this.sp2.Tag.ToString(),
                this.sp3.Tag.ToString(),
                this.sp4.Tag.ToString()
        });
复制到bt1_Click或者btn_Checker等方法中就行了。

小黑屋|手机版|站务邮箱|学逆向论坛 ( 粤ICP备2021023307号 )|网站地图

GMT+8, 2024-4-17 00:16 , Processed in 0.120975 second(s), 48 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表