我想知道是否有办法用 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 中快速创建应用程序并且不需要太多复杂的代码,请使用静态调用,以便每次单击“注册”时显示相同的 RegistrationForm 窗口(该窗口将保存在应用程序的代码部分中,因此可以在 OllyDbg 中修改)。
指出如何重写代码并保持分配相同的 RegistrationForm 实例(单例?)的简单性就可以了。我唯一需要的就是破解并保存*.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);
}
}
}
}
Here is OllyDbg screenshot and message which comes when setting breakpoints