飘云阁

 找回密码
 加入我们

QQ登录

只需一步,快速开始

查看: 6042|回复: 8

[原创] 一个.NET CM分析(ReWrit__s_Crackme__8)

  [复制链接]
  • TA的每日心情
    奋斗
    2015-10-29 08:08
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    发表于 2009-2-18 11:10:26 | 显示全部楼层 |阅读模式
    【文章标题】: 一个.NET CM分析(ReWrit__s_Crackme__8)
    【文章作者】: creantan
    【作者邮箱】: creantan@126.com
    【作者主页】: www.crack-me.com
    【下载地址】: www.crackmes.de
    【编写语言】: Microsoft Visual C# / Basic .NET
    【使用工具】: Reflector,ildasm,ilasm,UltraEdit
    【作者声明】: 只是感兴趣,没有其他目的。失误之处敬请诸位大侠赐教!
    --------------------------------------------------------------------------------
    【详细过程】
      第一次分析dotNET的CM。。呵呵。。。简单的一个CM无混淆适合对dotNet破解不熟的菜菜。。大鸟飞过。。
      crackmes.de随便找了个没人玩的CM

    1.   ReWrit's Crackme #8
    2.   
    3.   Kinda easy crackme...
    4.   you just have to patch it so it shows
    5.   the correct password in the (gray)textbox
    6.   and remove the nag...
    7.   
    复制代码
    CM作者叫我们patch这个CM使得正确的密码在灰色textbox中显示,同时去除NAG
      先运行程序看下什么情况,发现程序每个几秒NAG就会出现
      Reflector载入程序:
    1.jpg
      发现有两个窗口:FORM1和FORM2
      FORM1就是一开始出现的窗口了。。。
      FORM2就是第一次输入正确密码的时候点OK按钮后出现的第二个窗口
      我们先找NAG的信息
      双击FROM1中InitializeComponent()方法,反汇编窗口中显示如下:

    1.   private void InitializeComponent()
    2.   {
    3.       this.components = new Container();
    4.       ComponentResourceManager manager = new ComponentResourceManager(typeof(Form1));
    5.       this.button1 = new Button();
    6.       this.textBox1 = new TextBox();
    7.       this.label1 = new Label();
    8.       this.label2 = new Label();
    9.       this.textBox2 = new TextBox();
    10.       this.timer1 = new Timer(this.components);  //定义一个定时器
    11.       base.SuspendLayout();
    12.       manager.ApplyResources(this.button1, "button1");
    13.       this.button1.Name = "button1";
    14.       this.button1.UseVisualStyleBackColor = true;
    15.       this.button1.Click += new EventHandler(this.button1_Click);
    16.       manager.ApplyResources(this.textBox1, "textBox1");
    17.       this.textBox1.Name = "textBox1";
    18.       manager.ApplyResources(this.label1, "label1");
    19.       this.label1.Name = "label1";
    20.       manager.ApplyResources(this.label2, "label2");
    21.       this.label2.Name = "label2";
    22.       manager.ApplyResources(this.textBox2, "textBox2");
    23.       this.textBox2.Name = "textBox2";
    24.       this.textBox2.ReadOnly = true;
    25.       this.timer1.Interval = 0x2710;       //设置时间为10秒
    26.       this.timer1.Tick += new EventHandler(this.timer1_Tick);//这里双击timer1_Tick
    27.       manager.ApplyResources(this, "$this");
    28.       base.AutoScaleMode = AutoScaleMode.Font;
    29.       base.Controls.Add(this.textBox2);
    30.       base.Controls.Add(this.label2);
    31.       base.Controls.Add(this.label1);
    32.       base.Controls.Add(this.textBox1);
    33.       base.Controls.Add(this.button1);
    34.       base.FormBorderStyle = FormBorderStyle.FixedDialog;
    35.       base.MaximizeBox = false;
    36.       base.MinimizeBox = false;
    37.       base.Name = "Form1";
    38.       base.Load += new EventHandler(this.Form1_Load);
    39.       base.ResumeLayout(false);
    40.       base.PerformLayout();
    41.   }
    42.   
    复制代码

    1.   private void timer1_Tick(object sender, EventArgs e)
    2.   {
    3.       MessageBox.Show("NAG!", "NAG!");//NAG!找到了
    4.   }
    5.   
    6.   
    复制代码
    接下来找第一个密码:
      找到 button1_Click(object sender, EventArgs e)

    1.   private void button1_Click(object sender, EventArgs e)
    2.   {
    3.       int num = new Random().Next(0, 0x4c4b40);//取0-0x4c4b40之间的随机数。。。
    4.       if (this.textBox1.Text == num.ToString())//比较输入的数字和随机生成的数字比较是否相等
    5.       {
    6.           new Form2().Show();//相等第二个窗口出现
    7.       }
    8.       else
    9.       {
    10.           this.textBox1.Text = "Wrong Password!";//错误显示“Wrong Password!”
    11.       }
    12.   }
    13.   
    复制代码
    接下来再找第二个关键算法:
      展开FORM2窗口找到private void button1_Click(object sender, EventArgs e)

    1.   private void button1_Click(object sender, EventArgs e)
    2.   {
    3.       int length = this.textBox1.Text.Length;//取name的长度
    4.       int num2 = 0;
    5.       int num3 = 0;
    6.       for (int i = 0; i < length; i++)//一个小循环
    7.       {
    8.           num2 += this.textBox1.Text[i];
    9.           num2 *= i;
    10.       }
    11.       int num5 = new Random().Next(0, 0x1388);//取0-0x1388之间的随机数
    12.       num3 = num2 * num5;
    13.       if (this.textBox2.Text == num3.ToString())//判断输入的密码是否与算出的num3相等
    14.       {
    15.           MessageBox.Show("Good Job!", "Good Boy!");
    16.       }
    17.       else
    18.       {
    19.           MessageBox.Show("Wrong Password!", "Bad Boy!");
    20.       }
    21.   }
    22.   
    复制代码
    到这里关键的地方都找到了。。现在开始手动修改程序。。。
      
      打开ildasm,载入CM
      先ctrl+D dump出来生成中间代码文件,取名为cm.il
    2.jpg
      用UltraEdit打开cm.il
      在ildasm中找到timer1_Tick(object sender, EventArgs e)方法
       3.jpg
      然后复制一行去UltraEdit中搜索
       4.jpg

    1.   IL_0000:  ldstr      "NAG!"//直接ret就可以了:IL_0000:  ret这样NAG就解决了
    2.   
    复制代码
    随机生成的密码我们接下来就爆破吧。。
      ildasm中找到FORM1中button1_Click(object sender, EventArgs e)方法
       5.jpg
      找到关键点:

    1.     IL_0025:  call       bool [mscorlib]System.String::op_Equality(string,
    2.                                                                    string)//这里比较随机生成数字的与输入的数字是否相等
    3.     IL_002a:  b**lse.s  IL_0039//不等就跳向IL_0039
    4.     IL_002c:  newobj     instance void ReWrits_cm8.Form2::.ctor()
    5.     IL_0031:  stloc.2
    6.     IL_0032:  ldloc.2
    7.     IL_0033:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::Show()
    8.     IL_0038:  ret
    9.     IL_0039:  ldarg.0
    10.     IL_003a:  ldfld      class [System.Windows.Forms]System.Windows.Forms.TextBox ReWrits_cm8.Form1::textBox1
    11.     IL_003f:  ldstr      "Wrong Password!"
    12.     IL_0044:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)
    13.     IL_0049:  ret
    14.   
    15.   
    复制代码

    1.     IL_002a:  b**lse.s  IL_0039//这里跳往IL_002c就可以了:IL_002a:  b**lse.s  IL_002c
    2.   
    复制代码
    这里虽然爆破了可是还没达到作者的要求。。you just have to patch it so it shows
      the correct password in the (gray)textbox。。他要我们把正确的密码显示出来。。
      那我们就要手动添加代码了。。。
      UltraEdit中编辑:

    1.   IL_0025:  call       bool [mscorlib]System.String::op_Equality(string,
    2.                                                                    string)
    3.   IL_002a:  b**lse.s  IL_002c
    4.   IL_002c:  ldarg.0
    5.   IL_002d:  ldfld      class [System.Windows.Forms]System.Windows.Forms.TextBox ReWrits_cm8.Form1::textBox2//显示密码的控件
    6.   IL_0032:  ldloca.s   V_0 //V_0就是保存随机数的变量了
    7.   IL_0034:  call       instance string [mscorlib]System.Int32::ToString()//将随机生成的数字转化成字符串
    8.   IL_0039:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)//这就是textBox2.Text=V_0
    9.   IL_003e:  newobj     instance void ReWrits_cm8.Form2::.ctor()
    10.   IL_0043:  stloc.2
    11.   IL_0044:  ldloc.2
    12.   IL_0045:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::Show()
    13.   IL_004a:  ret
    14.   IL_004b:  ldarg.0
    15.   IL_004c:  ldfld      class [System.Windows.Forms]System.Windows.Forms.TextBox ReWrits_cm8.Form1::textBox1
    16.   IL_0051:  ldstr      "Wrong Password!"
    17.   IL_0056:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)
    18.   IL_006b:  ret
    19.   
    复制代码
    有人要问了V_0怎么就是保存随机数的变量了呢?
      看ildasm吧:

    1.   .method private hidebysig instance void  button1_Click(object sender,
    2.                                                          class [mscorlib]System.EventArgs e) cil managed
    3.   {
    4.     // 代码大小       74 (0x4a)
    5.     .maxstack  3
    6.     .locals init (class [mscorlib]System.Random V_0,
    7.              int32 V_1,
    8.              class ReWrits_cm8.Form2 V_2)//这里就是用到的局部变量:System.Random V_0
    9.   
    10.   
    复制代码
    现在来改第二个窗口:
      ildasm中找到FORM2中button1_Click(object sender, EventArgs e)方法
       6.jpg
      找到关键点:

    1.   IL_0066:  call       bool [mscorlib]System.String::op_Equality(string,
    2.                                                                    string)//关键比较
    3.     IL_006b:  b**lse.s  IL_007e//不等跳向错误提示
    4.     IL_006d:  ldstr      "Good Job!"
    5.     IL_0072:  ldstr      "Good Boy!"
    6.     IL_0077:  call       valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string,
    7.                                                                                                                                                        string)
    8.     IL_007c:  pop
    9.     IL_007d:  ret
    10.     IL_007e:  ldstr      "Wrong Password!"
    11.     IL_0083:  ldstr      "Bad Boy!"
    12.     IL_0088:  call       valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string,
    13.                                                                                                                                                        string)
    14.     IL_008d:  pop
    15.     IL_008e:  ret
    16.   
    17.   
    复制代码
    爆破点:

    1.   IL_006b:  b**lse.s  IL_007e//同样改成跳往下一句:IL_006b:  b**lse.s  IL_006d。。。不管相不相等都跳往下句
    2.   
    复制代码
    修改程序使得正确密码在textbox中显示。。。
      UltraEdit中编辑:

    1.   IL_006b:  b**lse.s  IL_006d
    2.   IL_006d:  ldarg.0
    3.   IL_006e:  ldfld      class [System.Windows.Forms]System.Windows.Forms.TextBox ReWrits_cm8.Form2::textBox3//显示正确密码的控件。。用Reflector可以在资源中看到textBox3为显示密码控件
    4.   IL_0073:  ldloca.s   V_2       //根据上下文可以看到V_2为正确密码
    5.   IL_0075:  call       instance string [mscorlib]System.Int32::ToString()//转化为字符串
    6.   IL_007a:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)
    7.   IL_007f:  ldstr      "Good Job!"
    8.   IL_0084:  ldstr      "Good Boy!"
    9.   IL_0089:  call       valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string,
    10.   IL_008e:  pop
    11.   IL_008f:  ret
    12.   IL_0090:  ldstr      "Wrong Password!"
    13.   IL_0095:  ldstr      "Bad Boy!"
    14.   IL_009a:  call       valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string,
    15.   IL_009f:  pop
    16.   IL_00a0:  ret
    17.   
    复制代码
    到这里这个CM基本上就解决了。。。
      现在用ilasm来编译:
      CMD中输入:ilasm /resource=cm.res cm.il
    7.jpg
      生成cm.exe文件
      运行下:
       8.jpg
      呵呵。。可以了。。。
      
      
      
      
    --------------------------------------------------------------------------------
    【版权声明】: 本文原创于creantan, 转载请注明作者并保持文章的完整, 谢谢!

                                                           2009年02月02日 10:04:18

    ReWrit__s_Crackme__8.zip

    39.62 KB, 下载次数: 16, 下载积分: 飘云币 -2 枚

    评分

    参与人数 1威望 +120 飘云币 +200 收起 理由
    Luckly + 120 + 200 非常好.图文并貌,牛!

    查看全部评分

    PYG19周年生日快乐!

    该用户从未签到

    发表于 2009-2-18 11:23:15 | 显示全部楼层
    继续研究 Net程序...

    现在的趋势是必须得研究它...
    PYG19周年生日快乐!

    该用户从未签到

    发表于 2009-2-18 12:26:41 | 显示全部楼层
    支持!.net程序看着确实不怎么舒服。。。
    PYG19周年生日快乐!
  • TA的每日心情

    2016-6-2 20:34
  • 签到天数: 10 天

    [LV.3]偶尔看看II

    发表于 2009-2-18 13:39:15 | 显示全部楼层
    好文,这样的图文看起来才舒服
    PYG19周年生日快乐!

    该用户从未签到

    发表于 2009-2-18 18:42:05 | 显示全部楼层
    GOOD 刚在看雪看完一个变KEYGENME为KEYGEN的DOTNET分析/:001
    PYG19周年生日快乐!

    该用户从未签到

    发表于 2009-2-18 19:09:36 | 显示全部楼层
    感谢老兄分享 精品文章 /:good
    PYG19周年生日快乐!

    该用户从未签到

    发表于 2009-2-19 10:54:51 | 显示全部楼层
    /:good /:good /:good
    C牛强大啊,谢谢分享!!!!!!!!!
    PYG19周年生日快乐!
  • TA的每日心情

    昨天 08:45
  • 签到天数: 2172 天

    [LV.Master]伴坛终老

    发表于 2010-12-23 20:34:58 | 显示全部楼层
    :loveliness:
    复制下来慢慢看
    多谢了
    PYG19周年生日快乐!
  • TA的每日心情
    开心
    2019-6-6 20:26
  • 签到天数: 20 天

    [LV.4]偶尔看看III

    发表于 2014-6-12 14:15:05 | 显示全部楼层
    感谢分享,写得很好
    PYG19周年生日快乐!
    您需要登录后才可以回帖 登录 | 加入我们

    本版积分规则

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