OllyDbg笔记-修改Messagebox的标题

30 篇文章 0 订阅
7 篇文章 2 订阅

目录

 

基本概念

实例


 

基本概念

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

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

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

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

  • 37
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT1995

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值