拆炸弹wp
# 思路用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 == 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~array的值。对应的数字也就是你按钮的数字。
按了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 == 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()
});
}
}
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);
}
}
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;
}
}
}
}
```
# 题目下载
本帖最后由 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等方法中就行了。
页:
[1]