介绍

观看了Lidnug的视频后,大约是.NET代码保护 http://secureteam.net/lidnug_recording/untitled.swf (尤其是从46:30到57:30),我要在我创建的EXE中找到对MessageBox的呼叫。

我的“ aprapp.exe”中唯一的逻辑是:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        MessageBox.Show("This is trial app");
    }
}

在发布配置上编译: http://rapidshare.com/files/392503054/trialapp.exe.html

我要做什么来找到电话

在WINDBG中运行该应用程序,并在出现消息框后休息。

获得CLR堆栈 !clrstack:

0040e840 5e21350b [InlinedCallFrame: 0040e840] System.Windows.Forms.SafeNativeMethods.MessageBox(System.Runtime.InteropServices.HandleRef, System.String, System.String, Int32)
0040e894 5e21350b System.Windows.Forms.MessageBox.ShowCore(System.Windows.Forms.IWin32Window, System.String, System.String, System.Windows.Forms.MessageBoxButtons, System.Windows.Forms.MessageBoxIcon, System.Windows.Forms.MessageBoxDefaultButton, System.Windows.Forms.MessageBoxOptions, Boolean)
0040e898 002701f0 [InlinedCallFrame: 0040e898] 
0040e934 002701f0 TrialApp.Form1.Form1_Load(System.Object, System.EventArgs)

获取MethodDESC结构(使用Form1_load的地址) !ip2md 002701f0

MethodDesc:   001762f8
Method Name:  TrialApp.Form1.Form1_Load(System.Object, System.EventArgs)
Class:        00171678
MethodTable:  00176354
mdToken:      06000005
Module:       00172e9c
IsJitted:     yes
CodeAddr:     002701d0
Transparency: Critical
Source file:  D:\temp\TrialApp\TrialApp\Form1.cs @ 22

倾倒此方法的IL(通过MethodDesc) !dumpil 001762f8

IL_0000: ldstr "This is trial app"
IL_0005: call System.Windows.Forms.MessageBox::Show 
IL_000a: pop 
IL_000b: ret 

因此,正如视频所述,呼吁 Show 从方法实现开始时为5个字节。

现在,我打开cffexplorer(就像在视频中一样),并获取form1_load方法的RVA: 00002083.

之后,我去地址转换器(再次在CFF Explorer中)并导航至偏移 00002083. 。我们有:

32 72 01 00 00 70 28 16 00 00 0A 26 2A 7A 03 2C
13 02 7B 02 00 00 04 2C 0B 02 7B 02 00 00 04 6F
17 00 00 0A 02 03 28 18 00 00 0A 2A 00 03 30 04 
00 67 00 00 00 00 00 00 00 02 28 19 00 00 0A 02

在视频中提到了前12个字节是用于方法标头的,所以我跳过它们

                                    2A 7A 03 2C
13 02 7B 02 00 00 04 2C 0B 02 7B 02 00 00 04 6F
17 00 00 0A 02 03 28 18 00 00 0A 2A 00 03 30 04 
00 67 00 00 00 00 00 00 00 02 28 19 00 00 0A 02

5个字节从实现开始之初就应该是方法调用(28)的OPCODE。不幸的是,不存在。

   02 7B 02 00 00 04 2C 0B 02 7B 02 00 00 04 6F
17 00 00 0A 02 03 28 18 00 00 0A 2A 00 03 30 04 
00 67 00 00 00 00 00 00 00 02 28 19 00 00 0A 02

问题:

  1. 我究竟做错了什么?
  2. 为什么在文件中的该位置没有方法调用?也许视频缺少一些信息...
  3. 为什么该视频中的那个人用9个零取代了电话?
有帮助吗?

解决方案

当我使用Ildasm.exe并查看IL时,带有显示字节打开的IL时,我看到了:

.method private hidebysig instance void  Form1_Load(object sender,
                                                    class [mscorlib]System.EventArgs e) cil managed
// SIG: 20 02 01 1C 12 15
{
  // Method begins at RVA 0x20f1
  // Code size       12 (0xc)
  .maxstack  8
  IL_0000:  /* 72   | (70)00000D       */ ldstr      "This is trial app"
  IL_0005:  /* 28   | (0A)00001E       */ call       valuetype [System.Windows.Forms]System.Windows.Forms.DialogResult [System.Windows.Forms]System.Windows.Forms.MessageBox::Show(string)
  IL_000a:  /* 26   |                  */ pop
  IL_000b:  /* 2A   |                  */ ret
} // end of method Form1::Form1_Load

转储中的令牌值不同,您似乎的程序似乎更大。但是您的转储中的IL从偏移1开始,而不是12。不确定为什么会关闭。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top