OllyDbg笔记-修改Messagebox的标题
发布日期:2021-06-30 10:40:54 浏览次数:2 分类:技术文章

本文共 2823 字,大约阅读时间需要 9 分钟。

目录

 


 

基本概念

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

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

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

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

IDA Pro:静态调试工具

OD相关的快捷键:

F2

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

F3

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

F4

程序执行到光标处

F5

缩小、还原当前窗口

F7

单步步入

F8

单步步过

F9

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

Ctrl+F2

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

Ctrl+F9

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

Alt+F9

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

Ctrl+G

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

 

实例

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

设置如下:

使用VS2012编写如下代码:

#include 
#include
#include
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 
#include
#include
#include
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://it1995.blog.csdn.net/article/details/103369259 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Java工作笔记-Java函数参传值传引用问题
下一篇:SQL工作笔记-达梦(MySQL)将一个模式(库)中的一个表迁入到其他模式(库)

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月17日 09时02分45秒