Skip to content

IAT Hooking POC (x86 / x64) - Hook functions through the IAT

Notifications You must be signed in to change notification settings

adamhlt/IAT-Hooking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

                          _______  ______   __  __            __   _            
                         /  _/   |/_  __/  / / / /___  ____  / /__(_)___  ____ _ 
                         / // /| | / /    / /_/ / __ \/ __ \/ //_/ / __ \/ __ `/
                       _/ // ___ |/ /    / __  / /_/ / /_/ / ,< / / / / / /_/ / 
                      /___/_/  |_/_/    /_/ /_/\____/\____/_/|_/_/_/ /_/\__, /
                                                                       /____/ 
                                                                          
                                                                          
                                     IAT Hooking POC (x86 / x64)
                                    Hook functions through the IAT

C++ Windows x86 x64

📖 Project Overview :

This project have been created to show how IAT hooking works.

You can easily hook any functions in the IAT, you can also change the module you want to target.

Note
This project can be compiled for x86 and x64 architecture.

🚀 Getting Started

Visual Studio :

  1. Open the solution file (.sln).
  2. Build the project in Release (x86 or x64)

Build for x86 / x64 (Debug and Realese).

🧪 Example

MessageBoxA Hook

using MessageBoxPtr = int(WINAPI*)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
MessageBoxPtr MessageBoxTest;

//MessageBoxA function hook.
int WINAPI MessageBoxHook(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
	printf("MessageBoxA have been called !\n");

	return MessageBoxTest(nullptr, "This function have been hooked !", "test", 0);
}

int main()
{
	//Hook the MessageBoxA function
	const LPVOID lpOrgFunction = IAT::Hook("user32.dll", "MessageBoxA", &MessageBoxHook);
	if (lpOrgFunction == nullptr)
		return -1;

	MessageBoxTest = (MessageBoxPtr)lpOrgFunction;

	MessageBoxA(nullptr, "This will never be displayed !", "test", 0);

	//Unhook the MessageBoxA function
	IAT::Hook("user32.dll", "MessageBoxA", lpOrgFunction);

	MessageBoxA(nullptr, "This function have been unhooked !", "test", 0);

	return 0;
}
Demonstration.mp4

About

IAT Hooking POC (x86 / x64) - Hook functions through the IAT

Topics

Resources

Stars

Watchers

Forks

Languages