欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

OllyDbg笔记-修改Messagebox的标题

发布时间:2025/3/15 编程问答 42 豆豆
生活随笔 收集整理的这篇文章主要介绍了 OllyDbg笔记-修改Messagebox的标题 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

目录

 

基本概念

实例


 

基本概念

调试逆向分为动态分析和静态分析;

动态分析:使用调试工具加载程序并且运行,随着程序运行调试者可以随时中断目标指令流程。

静态分析:很多不方便的场合运行软件。

OD(OllyDbg):动态调试工具;

IDA Pro:静态调试工具

OD相关的快捷键:

F2

下断点,也就是指定断点的地址

F3

加载一个可执行程序,进行调试分析

F4

程序执行到光标处

F5

缩小、还原当前窗口

F7

单步步入

F8

单步步过

F9

直接运行程序,遇到断点处,程序暂停

Ctrl+F2

重新运行程序到起始处,一般用于重新调试程序

Ctrl+F9

执行到函数返回处,用于跳出函数实现

Alt+F9

执行到用户代码处,用于快速跳出系统函数

Ctrl+G

输入十六进制地址,快速定位到该地址处

 

实例

这里不研究远程线程注入,在此直接把基址固定,

设置如下:

使用VS2012编写如下代码:

#include <windows.h> #include <iostream> #include <string> using namespace std;int WINAPI WinMain (HINSTANCE hinstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int iCmdShow) {while(1){MessageBoxA(NULL, "World", "Hello", 0);}return 0; }

这里先使用OD修改标题:

从这里可以看到,在汇编里面,一个函数的参数入栈,刚好是相反的。

原始运行截图如下:

这里直接进入0041CC7C地址就可以了。这里

修改为:

让他跑起来:

这个就是OD的基本做法,下面来写个程序去改!

这里有个知识点,就是有些进程页是只读的,不能修改,可以使用VirtualProtectEx这个函数改变其属性如下,把一个只读的改成可读可写的,但注意最后要改回来

DWORD dwPrev;if(!VirtualProtectEx(hProcess, (LPVOID)(offset - 0x1), 10, PAGE_EXECUTE_READWRITE, &dwPrev)){cout << "VirtualProtectEx failed " << GetLastError() << " " << dwPrev << endl;getchar();return 0;}.... .... .... ....if(!VirtualProtectEx(hProcess, (LPVOID)(offset), DWORD(sizeof(title)), dwPrev, &dwPrev)){cout << "VirtualProtectEx failed 2" << GetLastError() << " " << dwPrev << endl;getchar();return 0;}

这样其标题就是空白的了

完整代码如下:

#include <iostream> #include <windows.h> #include <string> #include <Psapi.h> using namespace std;int main(int argc, int *argv[]){HWND hwnd = FindWindowA(nullptr, "Hello");if(!hwnd){getchar();return 0;}DWORD pid = 0;GetWindowThreadProcessId(hwnd, &pid); //获取进程标识if (pid == 0){cout << "GetWindowThreadProcessId failed" << endl;getchar();return 0;}HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, pid);if(hProcess == NULL){cout << "OpenProcess failed" << endl;getchar();return 0;}DWORD offset = 0x0041CC7C;BYTE value[5] = {0};DWORD dwSize;DWORD title = 0x0;//if(ReadProcessMemory(hProcess, (LPVOID)offset, &value, sizeof(value) / sizeof(value[0]), &dwSize) == 0){// cout << "modify failed" << endl;// cout << value << endl;//}//else{// cout << "read : " << value << endl;//}DWORD dwPrev;if(!VirtualProtectEx(hProcess, (LPVOID)(offset - 0x1), 10, PAGE_EXECUTE_READWRITE, &dwPrev)){cout << "VirtualProtectEx failed " << GetLastError() << " " << dwPrev << endl;getchar();return 0;}if(WriteProcessMemory(hProcess, (LPVOID)offset, &title, DWORD(sizeof(title)), nullptr) == 0){cout << "failed" << endl;cout << GetLastError() << endl;getchar();return 0;}else{cout << "Finished" << endl;cout << value << endl;}if(!VirtualProtectEx(hProcess, (LPVOID)(offset), DWORD(sizeof(title)), dwPrev, &dwPrev)){cout << "VirtualProtectEx failed 2" << GetLastError() << " " << dwPrev << endl;getchar();return 0;}CloseHandle(hProcess);getchar();return 0; }

项目打包下载地址:

https://github.com/fengfanchen/CAndCPP/tree/master/HackMessageBox

总结

以上是生活随笔为你收集整理的OllyDbg笔记-修改Messagebox的标题的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。