使用OllyDebug破解C#应用程序

我想知道是否有办法用OllyDebug破解C#Windows应用程序。 我用Visual C#2010 Express编写了一个简单的CrackMe应用程序。 当我用OllyDebug打开它并根据需要修改ASM代码时,OllyDebug中没有“复制到可执行文件”选项,因为我的注册表单窗口是用“new”运算符动态分配的(我相信,VirtualAlloc()函数调用在调试器中)。 虽然我能够修改ASM代码(这只是NOP’ing JE跳转),但是我无法用破解的代码保存我的.exe文件,看起来像OllyDbg“看到”数据段中的代码,当时该代码不存在应用程序启动并且仅动态分配。 任何人都可以帮我解决这个问题吗? 我认为至少有两种方法可以修改* .exe:

1)使用OllyDbg深入挖掘代码,找到分配前实际代码所在的位置(因为新的RegistrationForm实例不会神奇地超出空间,是吗?)

2)如果它允许在VS Express中快速创建应用程序并且不需要太多复杂的代码,则使用静态调用,因此每次单击“Register”时都会显示相同的RegistrationForm窗口(它将保存在应用程序的代码部分中,因此将在OllyDbg中修改。

可以指出如何重写代码并保持简单分配RegistrationForm(singleton?)的相同实例。 我唯一需要的是破解并保存* .exe,重新启动并填写任何数据以“完成注册”。

以下是使用Main()方法的MyCrackMe类的代码:

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyCrackMe { class MyCrackMe { public static void Main() { MyForm mainWindow = new MyForm(); System.Windows.Forms.Application.Run(mainWindow); } } } 

主窗口类:

 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace MyCrackMe { public partial class MyForm : Form { public MyForm() { InitializeComponent(); } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { Application.Exit(); } private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("All rights reserved", "Message"); } private void registerToolStripMenuItem_Click(object sender, EventArgs e) { RegistrationForm registrationForm = new RegistrationForm(); registrationForm.Show(); } } } 

报名表类:

 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace MyCrackMe { public partial class RegistrationForm : Form { // Use DllImport to import the Win32 MessageBox function. [DllImport("user32.dll", EntryPoint = "MessageBoxA", CharSet = CharSet.Ansi)] public static extern int MsgBox(int hWnd, String text, String caption, uint type); public RegistrationForm() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "lincoln" && textBox2.Text == "12345") { MsgBox(0, "Registration completed successfully!", "Registration Message", 0); } else { MsgBox(0, "Registration failed", "Message", 0); } } } } 

这是设置断点时出现的OllyDbg屏幕截图和消息 ollydbgscreenshot

更新:dnSpy可能是最适合此目的的。

.NET正在使用IL字节码,在运行应用程序时会将其编译为本机指令,因此它在.NET VM中运行,类似于java。 你现在用olly做的事情是自己调试框架,而不是你的JIT生成的本机代码。 (你想要的,如果我理解你的话)。 据我所知,保存已修补的.NET应用程序并不适用于olly。 但是,还有其他解决方案来操纵/观察MSIL代码。

  • dbgclr
  • ILDASM
  • Cordbg中
  • CFFExplorer

此外, PEBrowse也可以调试JIT生成的本机代码! PEBrowse

您可能也对这些论文感兴趣:

  • Shukhrat Nekbaev对.NET应用程序的反向代码工程

  • OWASP .NET调试

  • DOTNET

  • 在MSDN上重写MSIL

  • .NET内部和本机编译

Stackexchange网络有一个专门用于逆向工程的站点,请加入我们那里:)在那里你的问题可能已经有了答案 。

我记得在这个软件中有补丁选项。 你需要激活补丁function。 我希望现在能够奏效。 我正在做同样的事情