生活随笔
收集整理的這篇文章主要介紹了
利用detours实现API劫持
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一直想玩黑客技術,今天正好找到一個detours的庫,這是微軟的出品的用來搞這類活動的庫,下載下來,用了一下,把messagebox給劫持了,感覺各種好happy,23333333333
這里需要特別注意的一點是,一定要在release模式下使用,否則是顯示不出效果的。
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "detours.h"
#include "detver.h"
#pragma comment(lib, "detours.lib")static int (WINAPI *OldMessageBoxA)(
HWND hWnd,
LPCWSTR lpText,
LPCWSTR lpCaption,
UINT uType) = MessageBoxA;
int WINAPI NewMessageBoxA(
HWND hWnd,
LPCWSTR lpText,
LPCWSTR lpCaption,
UINT uType)
{printf(
"哈哈,你的函數被我劫持了哦<^_^>\n");
return 0;
}VOID Hook()
{DetourRestoreAfterWith();DetourTransactionBegin();DetourUpdateThread(GetCurrentThread());DetourAttach((
void **)&OldMessageBoxA, NewMessageBoxA);DetourTransactionCommit();
}VOID UnHook()
{DetourTransactionBegin();DetourUpdateThread(GetCurrentThread());DetourDetach((
void **)&OldMessageBoxA, NewMessageBoxA);DetourTransactionCommit();}
void main()
{MessageBoxA(
0,
"鋤禾日當午1",
"學C真辛苦",
0);Hook();MessageBoxA(
0,
"鋤禾日當午2",
"學C真辛苦",
0);
}
總結
以上是生活随笔為你收集整理的利用detours实现API劫持的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。