【发布时间】:2014-08-14 23:47:43
【问题描述】:
我想知道有没有办法用 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,重新启动并填写任何数据以“完成注册”。
这是 MyCrackMe 类的代码,带有 Main() 方法:
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 屏幕截图和消息
【问题讨论】:
-
“教我什么是 .Net 可执行文件,以便我可以破解一些许可”对于 SO 来说似乎有点过于宽泛(即使忽略道德问题)。
-
我相信学习反破解最好的方法就是知道如何破解。这只是我自己用于教育目的的项目。我什至在 OllyDbg 中使用“user32.dll”导入并调用 MsgBox API 进行显式调用,这样更容易破解,你认为有人会这样做而不是 MessageBox.Show("Hello world") 吗?我认为专业开发人员编写的应用程序不会像我的那样容易被破解。如果主题对于 StackOverflow 来说太大,请参考一些教程或操作方法。
标签: c# assembly ollydbg cracking