|
|
|
|
|
[求助]在DLL中用SetWindowsHookEx挂空钩子进行代码注入问题
因为你的MessageBox函数又触发了钩子回调函数 |
|
[求助]SetWindowsHookEx hook的原理是什么? 汇编层的!!
全局注入,---->SetWindowsHookEx-->向操作系统注册我们的相对应的钩子类型的回调函数,由操作系统来判断钩子类型的发生并且主动通知我们的钩子回调函数----->我们的钩子dll被操作系统强行映射入产生钩子的模块空间,并且进行执行钩子dl的DllMain函数,------>然后才是执行我们定义的钩子回调函数. |
|
[求助]SDK 代码区段被偷
我是真不懂脱壳,要不就帮帮你l了,我连PE格式都不懂,哎 |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
2.对于在钩子回调函数过程中,我始终无法成功HookApi,不知道哪里出错了. 刚才采用WH_MOUSE钩子安装,总算成功了,但是,结论还是上面的,只有被监视的exe触发我们安装的钩子类型,才会被操作系统映射我们的钩子dll到这个exe中,这个过程中,DLL首先被初始化,然后才是钩子函数的执行. 所以,用此类办法无法监视一个程序加载开始的API调用(因为此刻程序没有完全运行起来,所以没有消息循环,没有窗口过程,没有鼠标和键盘的消息产生,于是就无法向操作系统发出那些钩子类型的消息)???? 或者说有没有一种钩子类型是可以在一个程序被操作系统创建执行的时候向系统发送这个钩子呢? 晕,发觉自己越来越绕口~~~汗 再整理一下思路. 全局注入,---->SetWindowsHookEx-->向操作系统注册我们的相对应的钩子类型的回调函数,由操作系统来判断钩子类型的发生并且主动通知我们的钩子回调函数----->我们的钩子dll被操作系统强行映射入产生钩子的模块空间,并且进行执行钩子dl的DllMain函数,------>然后才是执行我们定义的钩子回调函数. |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
1.我把安装HookApi的代码放在DLL的初始化和卸载过程中,可以正常HookApi了,但是对于一些程序在没有完全启动以后,被Hook的函数是没有机会被改变的,因为这个时候SetWindowsHookEx的回调函数并没有被触发,所以我们的钩子DLL模块还没有被初始化,只有在程序完全运行起来以后,符合SetWindowsHookEx安装的钩子类型,此刻这个全局的dll才会被这个exe说载入,才会执行HookApi过程,这样就有一些遗憾,对于一些程序启动就调用的API是无法用这种方式记录调用参数的. BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { handle = hModule; switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: _asm cpuid; if (!pHookEnv) { pHookEnv = InstallHookApi("Kernel32.dll", "LoadLibraryA", My_LoadLibraryA); } break; case DLL_PROCESS_DETACH: if (pHookEnv) { UnInstallHookApi((PHOOKENVIRONMENT)pHookEnv); } break; default: break; } return TRUE; } LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam) { // // 安装ApiHook // if (!g_bOne) // { // pHookEnv = InstallHookApi("Kernel32.dll", "LoadLibraryA", My_LoadLibraryA); // // if (pHookEnv) // // { // // ::MessageBoxA(NULL,"1111111","Very Good!!",MB_ICONINFORMATION); // // } // g_bOne = TRUE; // // } return CallNextHookEx(g_hHook,nCode,wParam,lParam); } __declspec(dllexport) BOOL WINAPI InstallHook() { // 初始化挂钩函数 g_hHook=SetWindowsHookEx(5,KeyboardProc,(HINSTANCE)handle,0); if (!g_hHook) { return FALSE; } return TRUE; } 2.对于在钩子回调函数过程中,我始终无法成功HookApi,不知道哪里出错了. 3.结论,SetWindowsHookEx函数应该是向操作系统注册一个回调函数的处理过程,当有符合我们SetWindowsHookEx的钩子类型时刻,操作系统才把我们的钩子dll动态的映射入产生钩子事件的模块中(exe,dll),这个过程首先进行DLL的初始化,才接着运行我们向操作系统注册的SetWindowsHookEx的钩子回调函数. 不知道我讲的是否正确,请楼主指正! |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
晕,我这里死活不能成功,你可以把你的修改过的工程或者exe和dll给我发一份嘛? |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
感觉还是下面的代码没有安装成功ApiHook,因为我点击取消以后跟踪进UnHook,发觉pHookEnv是0.可是这里我不知道该怎么安装才能是正确的? LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam) { // 安装ApiHook if (!pHookEnv) //判断是否安装了ApiHook { pHookEnv = InstallHookApi("Kernel32.dll", "LoadLibraryA", My_LoadLibraryA); // if (pHookEnv) // { // ::MessageBoxA(NULL,"1111111","Very Good!!",MB_ICONINFORMATION); // } // } return CallNextHookEx(g_hHook,nCode,wParam,lParam); } 我还用了只HOOK一次的办法 BOOL g_bOne = FALSE; LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam) { // 安装ApiHook if (!g_bOne) { pHookEnv = InstallHookApi("Kernel32.dll", "LoadLibraryA", My_LoadLibraryA); // if (pHookEnv) // { // ::MessageBoxA(NULL,"1111111","Very Good!!",MB_ICONINFORMATION); // } // g_bOne = TRUE; } return CallNextHookEx(g_hHook,nCode,wParam,lParam); } |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
不管dll还是exe我都是用Release方式编译的,请问你那里编译执行成功了嘛? 我就是用OD跟踪的,到执行dll中的函数InstallHook完成后停下的,还没有FreeLib呢,这个时候我用OD打开别的程序,发觉要Hook的函数并没有改变. |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
我把exe和dll的工程给你发上来. |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
关键就是在这!钩子的回调函数只是一个形式而已,起什么名字都可以,具体的我安装的hook类型是WH_GETMESSAGE ,换成别的全局类型的钩子也是无效,所以很想弄明白是如何全局HookApi的. 我在里面检测了,如果已经hook了,就把钩子函数传递到下一个. #define WH_MIN (-1) #define WH_MSGFILTER (-1) #define WH_JOURNALRECORD 0 #define WH_JOURNALPLAYBACK 1 #define WH_KEYBOARD 2 #define WH_GETMESSAGE 3 #define WH_CALLWNDPROC 4 #define WH_CBT 5 #define WH_SYSMSGFILTER 6 #define WH_MOUSE 7 #if defined(_WIN32_WINDOWS) #define WH_HARDWARE 8 #endif #define WH_DEBUG 9 #define WH_SHELL 10 #define WH_FOREGROUNDIDLE 11 #if(WINVER >= 0x0400) #define WH_CALLWNDPROCRET 12 #endif /* WINVER >= 0x0400 */ #if (_WIN32_WINNT >= 0x0400) #define WH_KEYBOARD_LL 13 #define WH_MOUSE_LL 14 #endif // (_WIN32_WINNT >= 0x0400) |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
我贴的就是核心代码啊,晕死,还有什么代码??? |
|
[原创]Hook Api lib 0.5 - 2008.04.16更新
[QUOTE=海风月影;444120] pHookEnv = InstallHookApi("Kernel32.dll", "LoadLibraryA", My_LoadLibraryA); 你只挂了钩子,并没有hook[/QUOTE] 请看那个钩子函数的代码,在里面hook了啊 __declspec(dllexport) BOOL WINAPI InstallHook() { // 初始化挂钩函数 g_hHook=SetWindowsHookEx(3,KeyboardProc,(HINSTANCE)handle,0); if (!g_hHook) { return FALSE; } return TRUE; } LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam) { // 安装ApiHook if (!pHookEnv) { pHookEnv = InstallHookApi("Kernel32.dll", "LoadLibraryA", My_LoadLibraryA); if (pHookEnv) { ::MessageBoxA(NULL,"1111111","Very Good!!",MB_ICONINFORMATION); } } return CallNextHookEx(g_hHook,nCode,wParam,lParam); } |
|
[下载]Advanced.Windows.Debugging
上传到fs2you或者namipan都可以的. |
|
[求助]je不跳?
首先,那是比较的eax和edx的值,而不是他们说指的内存内容,当然不跳了(因为eax根本就不等于edx). 再次,想让它跳可以把je 00403BCA修改为jmp 00403bca |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值